BRep_Tool::Triangulation return null

Hello, I've tried to get the Poly_Triangulation from every face of my shape, but for 2 faces it return a null triangulation... I created the shape with makePrism and I can't get the Poly_Triangulation of 2 the profile faces. I think the problem is in the prism building , because with other shapes the triangulation works. Thanks for your attention.

This is my code:

Handle(ShapeExtend_WireData) edges = new ShapeExtend_WireData();
for (TopTools_ListIteratorOfListOfShape iterator(listOfEdge); iterator.More(); iterator.Next()){
TopoDS_Edge currentEdge = TopoDS::Edge(iterator.Value());

//create a ShapeFix_Wire to be sure that all edges are in order, connected and create a closed wire

ShapeFix_Wire fixWire;
cout fixWire.FixReorder();
fixWire.FixConnected(); //to ensure vertices are shared btw edges
TopoDS_Wire profileWire = fixWire.WireAPIMake();

//I use GProp_PEquation to be sure that my edges are coplanars
//coplanarPoints is the points array I used to create the edges
GProp_PEquation peq(coplanarPoints, 0.1);

//I use the mean plane to create the face
BRepBuilderAPI_MakeFace mkFace(peq.Plane(), profileWire);
printf("mkFace error: %d\n", mkFace.Error());
TopoDS_Face myFaceProfile = mkFace.Face();

//extrusion vector
SbVec3f profTrans = profileTranslation->translation.getValue();
gp_Vec extrusionVec(profTrans[0],profTrans[1],profTrans[2]);

BRepPrimAPI_MakePrism mkPrism(myFaceProfile , extrusionVec, true);
//printf("mkPrism error: %d\n", mkPrism.Error());
TopoDS_Shape myShape = mkPrism.Shape();

BRepMesh_IncrementalMesh MESH(myShape,deflection);
TopExp_Explorer ex;
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
TopLoc_Location aLoc; //è una transizione composita
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
if(aPoly.IsNull()) error++; //for 2 faces I have a null triangulation
else { //continue

max_rome's picture

Maybe the problem are some edges.
I've tried to make a not closed wire and the BRepPrimAPI_MakePrism constructor create a solid with also the 2 basis face that the explorer found, but the 2 basis don't exist so I can't make triangulation.

My profile is created with some segments that I build with:
TopoDS_Edge currentEdge = BRepBuilderAPI_MakeEdge(startPoint,endPoint);

And with some arcs of circle described with 3 coordinates (center, startPoint and endPoint) and a normal. The draw sense is determined with the right-hand rule.

To create the edge from the arc I made two algorithm, one is more accurate but when I build the prism I haven't the 2 basis, the second is less accurate (the arc traced have a little translation of the center), but the prism is build correctly.

The 1st algorithm (no prism basis):

gp_Pnt c = coplanarPoints(cIndex);
gp_Pnt p1 = coplanarPoints(p1Index);
gp_Pnt p2 = coplanarPoints(p2Index);
gp_Vec normal = sbVec3f2gp_Vec(arcsNormals[i]);
gp_Dir normalDir(normal);
Standard_Real radius = c.Distance(p1);
gce_MakeCirc circ(c, normalDir, radius);
Handle(Geom_TrimmedCurve) arcOfCircle = GC_MakeArcOfCircle (circ, p1, p2, true);
TopoDS_Edge arcEdge = BRepBuilderAPI_MakeEdge(arcOfCircle);
//another strange thing of this algorithm is that if I change the last parameter of GC_MakeArcOfCircle the sense of the traced arc doesn't change.

The 2nd algorithm (prism basis exist):

gp_Pnt c = coplanarPoints(cIndex);
gp_Pnt p1 = coplanarPoints(p1Index);
gp_Pnt p2 = coplanarPoints(p2Index);
gp_Vec p1c(p1.XYZ()-c.XYZ());
gp_Vec tangent = sbVec3f2gp_Vec(prev2dStep->arcsNormals[i]) ^ p1c;
Handle(Geom_TrimmedCurve) arcOfCircle = GC_MakeArcOfCircle(p1,tangent ,p2);
TopoDS_Edge arcEdge = BRepBuilderAPI_MakeEdge(arcOfCircle);

I prefer the first algorithm because it's more accurate, but I can't understand why this edge doesnt'like to makeprism constructor.

Thanks for your attention.