Bug in BRepMesh_BaseAlgo (and BRepMesh_NodeInsertionMeshAlgo)

I think I've found an "old" bug in the meshing algorithm when internal vertices (TopAbs_IN) are forced to be included in the tesselation of a Face (InternalVerticesMode = true). I was getting very odd behavior - the first N vertices of a triangulation being uninitialized doubles (-6.277E+66), where N is the number of internal TopoDS_Vertex objects, present on the TopoDS_Face. The attached shape 'intpt_mesh_current_780.brep' has the invalid triangulation saved inside the shape, the triangulation looks like this with degenerate self intersecting mesh:

After going through the entire algorithm chain in the debugger i realized that up to the final transfer of the mesh into Poly_Triangulation everything is as expected. Looking further I found that the input nodes, representing the internal TopoDS_Vertex (TopAbs_IN) are inserted in myNodeMap but NOT bound to myUsedNodes. See code snips with my comments below, I've also attached the modified code files from 'src\BRepMesh'.

From 'BRepMesh_NodeInsertionMeshAlgo.cxx":

From 'BRepMesh_BaseMeshAlgo.cxx":

It would seem that i overdid it, as it would be totally fine only to change the line about inserting the new record if the node is not present in the map with its actual index, but I could argue that registering the internal vertex (which has a 'Fixed' D.O.F) from the start is better.

After recompiling and some testing in my own code everything works as expected. I loaded the above .brep file in DRAW and executed the following:

restore intpt_mesh_current_780.brep aShape
tclean aShape -force
vdisplay -dispMode 1 aShape
vfit
vaspects aShape -drawEdges 1

Which produces the expected result:

I hope some of the developers can look into this and verify, hopefully we will see this fixed in future releases :)

P.S. When researching the issue of internal vertices i reached this post, mentioning "degenerate triangles" when internal vertices are included in the mesh, which motivated me to dig deeper.

Dmitrii Pasukhin's picture

Hello,

Thank you for your research. I will create an issue and analyzed your fix.

Best regards, Dmitrii.