DiscussionsIssue archiveModeling Data and Algorithms

Archived discussion

Display a Sequence of Faces

Modeling Data and AlgorithmsSat, 06/22/2019 - 01:595 replies

Browse this forum
QuestionAuthor

Hello, 

I have a propriertary file format which stores a 3D object by its faces. Every face is its own section in the file and contains the edges displayed by the coordinates of its points which will construct the faces.
I was able to extract all the vertices from the file, create the edges, wires and faces. 

If I 'sew' the faces together I get a perfect object. As the objects are quite large this is horribly slow. 
For my project I don't need a single 'sewed' object. I just want to display all the shapes I have created. 

Is there a possibility to display a sequence of faces ?
My faces are all stored in: 

NCollection_Sequence<TopoDS_Face> myFaces;

As I need a Handle for each of these faces I would like to put them together in a single Interactive_Object, which I can display but WITHOUT any algorithms running over it. 

Thanks in advance and kindest regards

Discussion

5 archived replies

Posts are displayed in their archived order.

01Commenter-1

You can create TopoDS_Compound from your NCollection_Sequence<TopoDS_Face> (e.g. using BRep_Builder) and display it.

02Author

Thank you for your help - I tried this in the same manner with BRep_Builder to create a TopoDS_Shell - however this always encounters a segmentation fault. I think I'm doing something wrong there..
Following is the code I tried with your solution but it encounters a segmentation fault as well: 

NCollection_Sequence<TopoDS_Face> faces;

BRepBuilderAPI_Sewing mkSew;
for (int s = 1; s <= faces.Length(); s++) {
    mkSew.Add(faces.Value(s));
}
mkSew.Perform(); // this works but is very slow

BRep_Builder builder;
TopoDS_Compound compound;
builder.MakeCompound(compound);
for (int s = 1; s <=faces.Length(); s++) {
    builder.Add(compound, faces.Value(s)); // segmentation fault
}

Am I using the builder incorrectly ? Would appreciate your help. 
 

03Commenter-1

I can imagine this to crash only in case if some of TopoDS_Face in your sequence are NULL.

04Author

Oh wow!!! Thank you very much. This works like a charm. 

Checked if the current face is NULL and skipped it if true. 
Now the creation of the shape only takes 2ms instead of almost 6seconds. And it looks exactly the way I wanted it. 

Thank you again!!

05Commenter-1

Now the creation of the shape only takes 2ms instead of almost 6seconds. And it looks exactly the way I wanted it.

Sewing is a shape healing operation, which is expectedly consumes time, because it has to compare all faces in your sequence.
In case if your input geometry is really connected, then the proper solution is connected Edges of Faces at construction time.