From df18769ea6e62f7b4e998feea187bf722489266a Mon Sep 17 00:00:00 2001 From: oan Date: Thu, 20 Oct 2016 16:34:29 +0300 Subject: [PATCH] 0027959: BRepMesh_Delaun produces mesh with gaps on internal edges Check both sides of internal link for adjusted triangle and process left and right polygons separately Small correction of test case for issue CR27959 --- src/BRepMesh/BRepMesh_Delaun.cxx | 49 ++++++++++++++++++++++++++------ src/BRepMesh/BRepMesh_Delaun.hxx | 3 ++ tests/bugs/mesh/bug27959 | 21 ++++++++++++++ 3 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 tests/bugs/mesh/bug27959 diff --git a/src/BRepMesh/BRepMesh_Delaun.cxx b/src/BRepMesh/BRepMesh_Delaun.cxx index edd8a5c539..a7e8b4896f 100644 --- a/src/BRepMesh/BRepMesh_Delaun.cxx +++ b/src/BRepMesh/BRepMesh_Delaun.cxx @@ -508,25 +508,56 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices( createTriangles( aVertexIdx, aLoopEdges ); } } - // Check that internal edges are not crossed by triangles + + insertInternalEdges(); + + // Adjustment of meshes to boundary edges + frontierAdjust(); +} + +//======================================================================= +//function : insertInternalEdges +//purpose : +//======================================================================= +void BRepMesh_Delaun::insertInternalEdges() +{ BRepMesh::HMapOfInteger anInternalEdges = InternalEdges(); // Destruction of triancles intersecting internal edges // and their replacement by makeshift triangles + Standard_Integer e[3]; + Standard_Boolean o[3]; BRepMesh::MapOfInteger::Iterator anInernalEdgesIt( *anInternalEdges ); for ( ; anInernalEdgesIt.More(); anInernalEdgesIt.Next() ) { - Standard_Integer aNbC; - aNbC = myMeshData->ElementsConnectedTo( anInernalEdgesIt.Key() ).Extent(); - if ( aNbC == 0 ) + const Standard_Integer aLinkIndex = anInernalEdgesIt.Key(); + const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo(aLinkIndex); + + // Check both sides of link for adjusted triangle. + Standard_Boolean isGo[2] = { Standard_True, Standard_True }; + for (Standard_Integer aTriangleIt = 1; aTriangleIt <= aPair.Extent(); ++aTriangleIt) { - meshLeftPolygonOf( anInernalEdgesIt.Key(), Standard_True ); - meshLeftPolygonOf( anInernalEdgesIt.Key(), Standard_False ); + GetTriangle(aPair.Index(aTriangleIt)).Edges(e, o); + for (Standard_Integer i = 0; i < 3; ++i) + { + if (e[i] == aLinkIndex) + { + isGo[o[i] ? 0 : 1] = Standard_False; + break; + } + } + } + + if (isGo[0]) + { + meshLeftPolygonOf(aLinkIndex, Standard_True); + } + + if (isGo[1]) + { + meshLeftPolygonOf(aLinkIndex, Standard_False); } } - - // Adjustment of meshes to boundary edges - frontierAdjust(); } //======================================================================= diff --git a/src/BRepMesh/BRepMesh_Delaun.hxx b/src/BRepMesh/BRepMesh_Delaun.hxx index 37db10c277..e8fcba595e 100755 --- a/src/BRepMesh/BRepMesh_Delaun.hxx +++ b/src/BRepMesh/BRepMesh_Delaun.hxx @@ -320,6 +320,9 @@ private: const Standard_Integer theStartIndex, const Standard_Integer theEndIndex) const; + //! Performs insertion of internal edges into mesh. + void insertInternalEdges(); + private: Handle(BRepMesh_DataStructureOfDelaun) myMeshData; diff --git a/tests/bugs/mesh/bug27959 b/tests/bugs/mesh/bug27959 new file mode 100644 index 0000000000..cdf6fb101d --- /dev/null +++ b/tests/bugs/mesh/bug27959 @@ -0,0 +1,21 @@ +puts "==========" +puts "OCC27959" +puts "==========" +puts "" +####################################################################### +# BRepMesh_Delaun produces mesh with gaps on internal edges +####################################################################### +# test for #27959: check that resulting mesh does not contain gaps. + +restore [locate_data_file bug27959_ms.brep] result + +tclean result +checkview -display result -3d -path ${imagedir}/${test_image}.png + +set log [tricheck result] +if { [llength $log] != 0 } { + puts "Error : Mesh contains gaps" +} else { + puts "OK : Mesh produced without gaps" +} +