Skip to content

Commit

Permalink
use indexed map to avoid iterating a face twice in case of a compsolid
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 17, 2016
1 parent 83444cc commit 8724eae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Mod/Part/Gui/ViewProviderExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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++;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8724eae

Please sign in to comment.