From 967d2f4f301c079f3cbe689d88dad155bae2dada Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 28 Feb 2019 09:55:53 +0300 Subject: [PATCH] 0030497: [REGRESSION] Mesh - wrong Poly_Polygon3D within local selection of located shape The previous code has a condition to avoid processing the same faces if the face has a location. The similar condition should be applied during the edges processing. If not doing this, in the previous implementation, IMeshData_Edge instances are created for all edges(even located), but edges of faces located are not filled with curves. As a result we had wrong local selection of edges. Limit addition of edges to data model by ones with unique TShape and location using edges map already available in BRepMesh_ShapeVisitor. --- src/BRepMesh/BRepMesh_ShapeVisitor.cxx | 7 ++- src/IMeshTools/IMeshTools_ShapeExplorer.cxx | 52 ++++++++++++++------- tests/bugs/mesh/bug25364 | 2 +- tests/bugs/moddata_3/bug30497 | 17 +++++++ 4 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 tests/bugs/moddata_3/bug30497 diff --git a/src/BRepMesh/BRepMesh_ShapeVisitor.cxx b/src/BRepMesh/BRepMesh_ShapeVisitor.cxx index 791810b7d2..0705c13cf0 100644 --- a/src/BRepMesh/BRepMesh_ShapeVisitor.cxx +++ b/src/BRepMesh/BRepMesh_ShapeVisitor.cxx @@ -57,8 +57,11 @@ BRepMesh_ShapeVisitor::~BRepMesh_ShapeVisitor () //======================================================================= void BRepMesh_ShapeVisitor::Visit(const TopoDS_Edge& theEdge) { - myModel->AddEdge(theEdge); - myDEdgeMap.Bind(theEdge, myModel->EdgesNb() - 1); + if (!myDEdgeMap.IsBound (theEdge)) + { + myModel->AddEdge (theEdge); + myDEdgeMap.Bind (theEdge, myModel->EdgesNb () - 1); + } } //======================================================================= diff --git a/src/IMeshTools/IMeshTools_ShapeExplorer.cxx b/src/IMeshTools/IMeshTools_ShapeExplorer.cxx index 4df32b0b8c..2dc244a73c 100644 --- a/src/IMeshTools/IMeshTools_ShapeExplorer.cxx +++ b/src/IMeshTools/IMeshTools_ShapeExplorer.cxx @@ -25,6 +25,32 @@ #include #include +namespace +{ + //======================================================================= + // Function: visitEdges + // Purpose : Explodes the given shape on edges according to the specified + // criteria and visits each one in order to add it to data model. + //======================================================================= + void visitEdges (const Handle (IMeshTools_ShapeVisitor)& theVisitor, + const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theToFind, + const TopAbs_ShapeEnum theToAvoid = TopAbs_SHAPE) + { + TopExp_Explorer aEdgesIt (theShape, theToFind, theToAvoid); + for (; aEdgesIt.More (); aEdgesIt.Next ()) + { + const TopoDS_Edge& aEdge = TopoDS::Edge (aEdgesIt.Current ()); + if (!BRep_Tool::IsGeometric (aEdge)) + { + continue; + } + + theVisitor->Visit (aEdge); + } + } +} + //======================================================================= // Function: Constructor // Purpose : @@ -50,28 +76,15 @@ IMeshTools_ShapeExplorer::~IMeshTools_ShapeExplorer () void IMeshTools_ShapeExplorer::Accept ( const Handle (IMeshTools_ShapeVisitor)& theVisitor) { - // Explore all edges in shape - either free or related to some face. - TopTools_IndexedMapOfShape aEdges; - TopExp::MapShapes (GetShape (), TopAbs_EDGE, aEdges); + // Explore all free edges in shape. + visitEdges (theVisitor, GetShape (), TopAbs_EDGE, TopAbs_FACE); - TopTools_IndexedMapOfShape::Iterator aEdgeIt (aEdges); - for (; aEdgeIt.More (); aEdgeIt.Next ()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge (aEdgeIt.Value ()); - if (!BRep_Tool::IsGeometric(aEdge)) - { - continue; - } - - theVisitor->Visit (aEdge); - } - - // Explore faces + // Explore all related to some face edges in shape. + // make array of faces suitable for processing (excluding faces without surface) TopTools_ListOfShape aFaceList; BRepLib::ReverseSortFaces (GetShape (), aFaceList); TopTools_MapOfShape aFaceMap; - // make array of faces suitable for processing (excluding faces without surface) TopLoc_Location aDummyLoc; const TopLoc_Location aEmptyLoc; TopTools_ListIteratorOfListOfShape aFaceIter (aFaceList); @@ -84,13 +97,16 @@ void IMeshTools_ShapeExplorer::Accept ( continue; // already processed } - TopoDS_Face aFace = TopoDS::Face (aFaceIter.Value ()); + const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Value ()); const Handle (Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aDummyLoc); if (aSurf.IsNull()) { continue; } + // Explore all edges in face. + visitEdges (theVisitor, aFace, TopAbs_EDGE); + // Store only forward faces in order to prevent inverse issue. theVisitor->Visit (TopoDS::Face (aFace.Oriented (TopAbs_FORWARD))); } diff --git a/tests/bugs/mesh/bug25364 b/tests/bugs/mesh/bug25364 index 0ef6bc404e..a4544ad76d 100755 --- a/tests/bugs/mesh/bug25364 +++ b/tests/bugs/mesh/bug25364 @@ -68,7 +68,7 @@ set mem_delta_private 200 set mem_delta_swap 120 set mem_delta_swappeak 250 set mem_delta_wset 200 -set mem_delta_wsetpeak 220 +set mem_delta_wsetpeak 300 set mem_delta_virt 220 set mem_delta_heap 80 diff --git a/tests/bugs/moddata_3/bug30497 b/tests/bugs/moddata_3/bug30497 new file mode 100644 index 0000000000..0fb0e7f0b9 --- /dev/null +++ b/tests/bugs/moddata_3/bug30497 @@ -0,0 +1,17 @@ +puts "=======" +puts "0030497 \[REGRESSION\] Mesh - wrong Poly_Polygon3D within local selection of located shape" +puts "=======" +puts "" + +pload XDE +testreadstep [locate_data_file as1-oc-214-mat.stp] s + +vclear +vinit View1 +vaxo +vdisplay s -dispmode 1 +vfit +vselmode 2 1 +vmoveto 150 201 + +vdump ${imagedir}/${casename}.png