Crash on Poly_Triangulation

The sample code below crashes on the given line when NbNodes() of Poly_Triangulation is called. No matter which of the 3 given Boolean operations you use, it crashes in all cases.
I can provide more examples if needed.

Please give me feedback on the problem and possible solutions.

Thank you very much in advance,
Hannes Kaufmann

TopoDS_Shape Shape1, Shape2;
{
gp_Pnt middlePoint = gp_Pnt(0.335179, -0.219682, 0.071117);
Shape1 = BRepPrimAPI_MakeSphere(middlePoint, 0.100187);
}
{
gp_Pnt middlePoint = gp_Pnt(0.26183, -0.264555, -0.0453328);
gp_Dir direction = gp_Dir(0.157224, 0.143615, 0.256371);
gp_Ax2 Ax2 = gp_Ax2(middlePoint, direction);
Shape2 = BRepPrimAPI_MakeCone(Ax2, 0.0711757, 0, 0.333273);
}

// No matter which operation you use, it crashes for all three!
//TopoDS_Shape Shape = BRepAlgoAPI_Cut(Shape1, Shape2);
TopoDS_Shape Shape = BRepAlgoAPI_Fuse(Shape1, Shape2);
//TopoDS_Shape Shape = BRepAlgoAPI_Common(Shape1, Shape2);

BRepMesh::Mesh(Shape, 1);
for(TopExp_Explorer ex(Shape,TopAbs_FACE); ex.More(); ex.Next())
{

TopoDS_Face F = TopoDS::Face(ex.Current());

TopLoc_Location L;

Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);

// Crash happens in next line !

int NumNodes = facing->NbNodes(); // --> CRASHES HERE

const TColgp_Array1OfPnt& NodesArray = facing->Nodes();

int NumTri = facing->NbTriangles();

const Poly_Array1OfTriangle& TriArray = facing->Triangles();
}

This was submitted as a bug report too.

Christophe ATTANASIO's picture

Hello Hannes,

The method BRep_Tool::Triangulation(F,L) returns the Triangulation of the face. It is a null handle if there is no triangulation.
(read the CDL file : BRep_Tool.cdl)

So the Face F have not triangulation !!
Why : because you try to mesh the Shape with a chordal deviation equal to 1mm but I think that the bounding box of this shape is less than 1mm !

Try to decrease the deviation.

Christophe.