Hello, i am working on a small CAD importer. I have the XCAF doc of the file and while browsing the shapes, I'm getting lots of TopoDS_Faces which i know how to translate.
Other than TopoDS_Faces in the document there are a number of Compounds grouping inside other compounds or edges.
I'd like to convert these edges in TopoDS_Faces. Browsing the forum I'v found the BRepBuilderAPI_MakeWire and BRepBuilderAPI_MakeFace classes. So I wrote down a little funcion to collect the edges and to fill a face vector:
void facesFromCompounds (const TopoDS_Shape &Shape, std::vector &topoFaceVector)
{
// if the compound is made of other compunds... i go down one level in the recursion
for(TopoDS_Iterator iter(Shape); iter.More(); iter.Next())
{
if(iter.Value ().ShapeType()==TopAbs_COMPOUND)
facesFromCompounds (iter.Value (), topoFaceVector);
}
// if the compound holds the edges, i extract them and then feed em to the builder
std::vector edgeVector;
for(TopoDS_Iterator iter(Shape); iter.More(); iter.Next())
{
if(iter.Value ().ShapeType()==TopAbs_EDGE)
{
TopoDS_Edge edge = TopoDS::Edge(iter.Value());
edgeVector.push_back (edge);
}
}
if (edgeVector.size ()!=0)
{
BRepBuilderAPI_MakeWire wireMaker (edgeVector[0]);
for (int i=1;i
wireMaker.Add (edgeVector[i]);
//wireMaker.Build ();
TopoDS_Wire wire = wireMaker.Wire();
BRepBuilderAPI_MakeFace faceMaker (wire);
faceMaker.Build ();
TopoDS_Shape geoFace = faceMaker.Face();
topoFaceVector.push_back (geoFace);
}
}
this function crashes everytime in the
TopoDS_Wire wire = wireMaker.Wire();
instruction. Am i applying it to the wrong edges?
Is there a way to check if the builder is doing fine before it crashes?
Thanks