From 85bf3ab9f4b07199f798589f07ecdd770c9659b1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 18 Mar 2014 11:11:08 +0100 Subject: [PATCH] + make sure to keep the same order of lines inside a line set as the edge order --- src/Mod/Part/Gui/ViewProviderExt.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 52623e0f8256..2d8fff9d9f31 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -680,9 +680,10 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) TopTools_IndexedMapOfShape edgeMap; TopExp::MapShapes(cShape, TopAbs_EDGE, edgeMap); - std::set edgeIdxSet; - std::vector indxVector; - std::vector edgeVector; + // key is the edge number, value the coord indexes. This is needed to keep the same order as the edges. + std::map > lineSetMap; + std::set edgeIdxSet; + std::vector edgeVector; // count and index the edges for (int i=1; i <= edgeMap.Extent(); i++) { @@ -708,8 +709,6 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) } } } - // reserve some memory - indxVector.reserve(numEdges*8); // handling of the vertices TopTools_IndexedMapOfShape vertexMap; @@ -823,7 +822,7 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) for (Standard_Integer i=indices.Lower();i <= indices.Upper();i++) { int nodeIndex = indices(i); int index = faceNodeOffset+nodeIndex-1; - indxVector.push_back(index); + lineSetMap[edgeIndex].push_back(index); // usually the coordinates for this edge are already set by the // triangles of the face this edge belongs to. However, there are @@ -835,7 +834,6 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) p.Transform(myTransf); verts[index].setValue((float)(p.X()),(float)(p.Y()),(float)(p.Z())); } - indxVector.push_back(-1); // remove the handled edge index from the set edgeIdxSet.erase(edgeIndex); @@ -876,10 +874,9 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) pnt.Transform(myTransf); int index = faceNodeOffset+j-1; verts[index].setValue((float)(pnt.X()),(float)(pnt.Y()),(float)(pnt.Z())); - indxVector.push_back(index); + lineSetMap[i].push_back(index); } - indxVector.push_back(-1); faceNodeOffset += nbNodesInEdge; } } @@ -896,13 +893,19 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) for (int i = 0; i< numNorms ;i++) norms[i].normalize(); + std::vector lineSetCoords; + for (std::map >::iterator it = lineSetMap.begin(); it != lineSetMap.end(); ++it) { + lineSetCoords.insert(lineSetCoords.end(), it->second.begin(), it->second.end()); + lineSetCoords.push_back(-1); + } + // preset the index vector size - numLines = indxVector.size(); + numLines = lineSetCoords.size(); lineset ->coordIndex .setNum(numLines); int32_t* lines = lineset ->coordIndex .startEditing(); int l=0; - for (std::vector::const_iterator it=indxVector.begin();it!=indxVector.end();++it,l++) + for (std::vector::const_iterator it=lineSetCoords.begin();it!=lineSetCoords.end();++it,l++) lines[l] = *it; // end the editing of the nodes