From 80d659a5a6cda0489457b71a6124e3d7f797fde0 Mon Sep 17 00:00:00 2001 From: oan Date: Fri, 21 Nov 2014 14:15:34 +0300 Subject: [PATCH] 0025469: BRepMesh corrupts triangulation of another not connected shape Do not clean polygons that are created for different faces not connected with current shape. Remove old code producing additional points for BSpline curves due to fix #24959. Test cases fir issue CR25469 Revert changes producing additional points for BSpline curves with C1 continuity Test cases fir issue CR25469 Correction of test cases for issue CR25469 --- src/BRepMesh/BRepMesh_EdgeTessellator.cxx | 2 +- src/BRepMesh/BRepMesh_IncrementalMesh.cxx | 28 +++++++++++++-- tests/bugs/mesh/bug23631 | 4 +-- tests/bugs/mesh/bug25469_1 | 30 ++++++++++++++++ tests/bugs/mesh/bug25469_2 | 34 ++++++++++++++++++ tests/bugs/mesh/bug25469_3 | 42 +++++++++++++++++++++++ tests/bugs/mesh/bug25479 | 33 ++++++++++++++++++ tests/bugs/modalg_4/bug22383 | 2 +- 8 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 tests/bugs/mesh/bug25469_1 create mode 100644 tests/bugs/mesh/bug25469_2 create mode 100755 tests/bugs/mesh/bug25469_3 create mode 100644 tests/bugs/mesh/bug25479 diff --git a/src/BRepMesh/BRepMesh_EdgeTessellator.cxx b/src/BRepMesh/BRepMesh_EdgeTessellator.cxx index 2347a2840f..1a4f4d4a51 100644 --- a/src/BRepMesh/BRepMesh_EdgeTessellator.cxx +++ b/src/BRepMesh/BRepMesh_EdgeTessellator.cxx @@ -97,7 +97,7 @@ BRepMesh_EdgeTessellator::BRepMesh_EdgeTessellator( } } } - + // PTv, chl/922/G9, Take into account internal vertices // it is necessary for internal edges, which do not split other edges, by their vertex TopExp_Explorer aVertexIt(theEdge, TopAbs_VERTEX); diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx index 7460b1cf95..9c614e9fb4 100644 --- a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx +++ b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx @@ -374,6 +374,30 @@ void BRepMesh_IncrementalMesh::update(const TopoDS_Edge& theEdge) { continue; } + else + { + // Check that triangulation relies to face of the given shape. + const TopTools_IndexedDataMapOfShapeListOfShape& aMapOfSharedFaces = + myMesh->SharedFaces(); + + const TopTools_ListOfShape& aSharedFaces = + aMapOfSharedFaces.FindFromKey(theEdge); + + Standard_Boolean isCurrentShape = Standard_False; + TopTools_ListIteratorOfListOfShape aSharedFaceIt(aSharedFaces); + for (; aSharedFaceIt.More() && !isCurrentShape; aSharedFaceIt.Next()) + { + TopLoc_Location aLoc; + const TopoDS_Face& aFace = TopoDS::Face(aSharedFaceIt.Value()); + Handle(Poly_Triangulation) aFaceTriangulation = + BRep_Tool::Triangulation(aFace, aLoc); + + isCurrentShape = (aFaceTriangulation == aTriangulation); + } + + if (!isCurrentShape) + continue; + } myModified = Standard_True; BRepMesh_ShapeTool::NullifyEdge(theEdge, aTriangulation, aLoc); @@ -397,7 +421,7 @@ Standard_Boolean BRepMesh_IncrementalMesh::toBeMeshed( const Standard_Boolean isWithCheck) { TopLoc_Location aLoc; - Handle(Poly_Triangulation) aTriangulation = + const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(theFace, aLoc); if (aTriangulation.IsNull()) @@ -514,7 +538,7 @@ void BRepMesh_IncrementalMesh::commitEdges(const TopoDS_Face& theFace) return; } - TopLoc_Location aLoc = aFace.Location(); + TopLoc_Location aLoc; Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLoc); if (aTriangulation.IsNull()) diff --git a/tests/bugs/mesh/bug23631 b/tests/bugs/mesh/bug23631 index e80c600b9d..41ff351fdc 100644 --- a/tests/bugs/mesh/bug23631 +++ b/tests/bugs/mesh/bug23631 @@ -16,8 +16,8 @@ triangles result set tri 0 set nod 0 -set good_tri 31 -set good_nod 33 +set good_tri 38 +set good_nod 40 set tri_info [trinfo result] regexp { +([-0-9.+eE]+) +triangles} $tri_info full tri diff --git a/tests/bugs/mesh/bug25469_1 b/tests/bugs/mesh/bug25469_1 new file mode 100644 index 0000000000..54ea29ae32 --- /dev/null +++ b/tests/bugs/mesh/bug25469_1 @@ -0,0 +1,30 @@ +puts "=========" +puts "CR25469" +puts "=========" +puts "" +############################################### +# BRepMesh corrupts triangulation of another not connected shape +############################################### + +restore [locate_data_file bug25469_common_edge.brep] a + +explode a + +incmesh a_1 0.04 +set report [tricheck a_1] +if {$report != ""} { + puts "Error: incorrect meshing of shape 1" +} + +incmesh a_2 0.04 +set report [tricheck a_1] +if {$report != ""} { + puts "Error: meshing of shape 2 corrupts mesh of shape 1" +} + +vinit +vsetdispmode 1 +vdisplay a_1 a_2 +vfit + +set only_screen 1 diff --git a/tests/bugs/mesh/bug25469_2 b/tests/bugs/mesh/bug25469_2 new file mode 100644 index 0000000000..64b16f4d22 --- /dev/null +++ b/tests/bugs/mesh/bug25469_2 @@ -0,0 +1,34 @@ +puts "=========" +puts "CR25469" +puts "=========" +puts "" +############################################### +# BRepMesh corrupts triangulation of another not connected shape +############################################### + +restore [locate_data_file bug25469_common_edge.brep] a + +explode a +explode a_1 +explode a_2 + +ttranslate a_2_1 -100 -220 0 + +incmesh a_1_1 0.04 +set report [tricheck a_1_1] +if {$report != ""} { + puts "Error: incorrect meshing of shape 1" +} + +incmesh a_2_1 0.04 +set report [tricheck a_1_1 a_2_1] +if {$report != ""} { + puts "Error: meshing of shape 2 corrupts mesh of shape 1" +} + +vinit +vsetdispmode 1 +vdisplay a_1_1 a_2_1 +vfit + +set only_screen 1 diff --git a/tests/bugs/mesh/bug25469_3 b/tests/bugs/mesh/bug25469_3 new file mode 100755 index 0000000000..b8c5e66de3 --- /dev/null +++ b/tests/bugs/mesh/bug25469_3 @@ -0,0 +1,42 @@ +puts "TODO CR25469 ALL: Error : Colors are not equal in default coordinate and in the near coordinates too" + +puts "=========" +puts "CR25469" +puts "=========" +puts "" +############################################### +# BRepMesh corrupts triangulation of another not connected shape +############################################### + +pload QAcommands + +restore [locate_data_file bug25469_bad_tria.brep] a +tclean a +incmesh a 0.001 +triangles a +isos a 0 + +donly a +top +fit + +vinit +vsetdispmode 1 +vdisplay a +vtop +vfit +vmoveto 200 150 + +dlog reset +dlog off +checkcolor 64 200 1 0.72549021244049072 0.12941177189350128 +dlog on + +if { ${stat} == 1} { + puts "Error : Bad triangulation" +} else { + puts "OK : Good triangulation" +} + +xwd ${imagedir}/${test_image}_1.png +vdump ${imagedir}/${test_image}_2.png diff --git a/tests/bugs/mesh/bug25479 b/tests/bugs/mesh/bug25479 new file mode 100644 index 0000000000..d5a69c62bf --- /dev/null +++ b/tests/bugs/mesh/bug25479 @@ -0,0 +1,33 @@ +puts "=========" +puts "CR25479" +puts "=========" +puts "" +############################################### +# BRepTools::Clean() cleans all edge polygons, even related to different shapes +############################################### + +restore [locate_data_file bug25469_common_edge.brep] a + +tclean a +incmesh a 0.004 + +explode a + +incmesh a_1 0.04 +set report [tricheck a_1] +if {$report != ""} { + puts "Error: incorrect meshing of shape" +} + +tclean a_2 +set report [tricheck a_1] +if {$report != ""} { + puts "Error: cleaning mesh of shape 2 corrupts mesh of shape 1" +} + +vinit +vsetdispmode 1 +vdisplay a_1 a_2 +vfit + +set only_screen 1 diff --git a/tests/bugs/modalg_4/bug22383 b/tests/bugs/modalg_4/bug22383 index 7980b02b0c..995ddce3ba 100755 --- a/tests/bugs/modalg_4/bug22383 +++ b/tests/bugs/modalg_4/bug22383 @@ -29,7 +29,7 @@ puts $nbpoints ## must be less than number on clear occ651 set status 0 -if {$nbpoints < $good_trip} { +if {$nbpoints <= $good_trip} { set status 1 }