From fd6003fb87a7a5d8c5030f65ac0c5f383b85807e Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 7 Mar 2019 16:18:59 +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. (cherry picked from commit 967d2f4f301c079f3cbe689d88dad155bae2dada) (cherry picked from commit 3d9cd0b2f2f8dfb1242de19cb0d04399eebd66b9) --- src/BRepMesh/BRepMesh_ShapeVisitor.cxx | 7 +- src/IMeshTools/IMeshTools_ShapeExplorer.cxx | 76 +++++++++------------ tests/bugs/mesh/bug25364 | 2 +- tests/bugs/moddata_3/bug30497 | 11 ++- 4 files changed, 42 insertions(+), 54 deletions(-) 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 ba7636f08c..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 : @@ -51,19 +77,10 @@ void IMeshTools_ShapeExplorer::Accept ( const Handle (IMeshTools_ShapeVisitor)& theVisitor) { // Explore all free edges in shape. - TopExp_Explorer aFreeEdgesIt (GetShape (), TopAbs_EDGE, TopAbs_FACE); - for (; aFreeEdgesIt.More(); aFreeEdgesIt.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge (aFreeEdgesIt.Current()); - if (!BRep_Tool::IsGeometric(aEdge)) - { - continue; - } - - theVisitor->Visit (aEdge); - } + visitEdges (theVisitor, GetShape (), TopAbs_EDGE, TopAbs_FACE); // 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; @@ -80,46 +97,15 @@ 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; } - TopExp_Explorer anEdgesExp (aFace, TopAbs_EDGE); - for (; anEdgesExp.More(); anEdgesExp.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge (anEdgesExp.Current()); - if (!BRep_Tool::IsGeometric(aEdge)) - { - continue; - } - - theVisitor->Visit (aEdge); - } - } - - // Explore faces - aFaceMap.Clear(); - - // make array of faces suitable for processing (excluding faces without surface) - aFaceIter.Init (aFaceList); - for (; aFaceIter.More (); aFaceIter.Next ()) - { - TopoDS_Shape aFaceNoLoc = aFaceIter.Value (); - aFaceNoLoc.Location (aEmptyLoc); - if (!aFaceMap.Add(aFaceNoLoc)) - { - continue; // already processed - } - - 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 index 239b481730..0fb0e7f0b9 100644 --- a/tests/bugs/moddata_3/bug30497 +++ b/tests/bugs/moddata_3/bug30497 @@ -1,13 +1,10 @@ puts "=======" -puts "0030497" +puts "0030497 \[REGRESSION\] Mesh - wrong Poly_Polygon3D within local selection of located shape" puts "=======" puts "" -################################################## -# [REGRESSION] Mesh - wrong Poly_Polygon3D within local selection of located shape -################################################## -pload XDE VISUALIZATION -testreadstep as1-oc-214-mat.stp s +pload XDE +testreadstep [locate_data_file as1-oc-214-mat.stp] s vclear vinit View1 @@ -16,3 +13,5 @@ vdisplay s -dispmode 1 vfit vselmode 2 1 vmoveto 150 201 + +vdump ${imagedir}/${casename}.png -- 2.39.5