From 8724eaed3613667a38373b13ca9e9002cf1f35b4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 17 Nov 2016 15:40:22 +0100 Subject: [PATCH] use indexed map to avoid iterating a face twice in case of a compsolid --- src/Mod/Part/Gui/ViewProviderExt.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index c0598d4f7e..7f61d16482 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -911,9 +911,10 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) cShape.Location(aLoc); // count triangles and nodes in the mesh - TopExp_Explorer Ex; - for (Ex.Init(cShape,TopAbs_FACE);Ex.More();Ex.Next()) { - Handle (Poly_Triangulation) mesh = BRep_Tool::Triangulation(TopoDS::Face(Ex.Current()), aLoc); + TopTools_IndexedMapOfShape faceMap; + TopExp::MapShapes(cShape, TopAbs_FACE, faceMap); + for (int i=1; i <= faceMap.Extent(); i++) { + Handle (Poly_Triangulation) mesh = BRep_Tool::Triangulation(TopoDS::Face(faceMap(i)), aLoc); // Note: we must also count empty faces if (!mesh.IsNull()) { numTriangles += mesh->NbTriangles(); @@ -922,7 +923,7 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) } TopExp_Explorer xp; - for (xp.Init(Ex.Current(),TopAbs_EDGE);xp.More();xp.Next()) + for (xp.Init(faceMap(i),TopAbs_EDGE);xp.More();xp.Next()) faceEdges.insert(xp.Current().HashCode(INT_MAX)); numFaces++; } @@ -982,9 +983,9 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) norms[i]= SbVec3f(0.0,0.0,0.0); int ii = 0,faceNodeOffset=0,faceTriaOffset=0; - for (Ex.Init(cShape, TopAbs_FACE); Ex.More(); Ex.Next(),ii++) { + for (int i=1; i <= faceMap.Extent(); i++, ii++) { TopLoc_Location aLoc; - const TopoDS_Face &actFace = TopoDS::Face(Ex.Current()); + const TopoDS_Face &actFace = TopoDS::Face(faceMap(i)); // get the mesh of the shape Handle (Poly_Triangulation) mesh = BRep_Tool::Triangulation(actFace,aLoc); if (mesh.IsNull()) continue;