From 37f90ecfa35f52dcfe2bccd139b7c7b7fcf99ba8 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 24 Oct 2018 18:55:11 +0300 Subject: [PATCH] Fixes for the issue #2375 model with dump/import script --- src/Model/Model_ResultConstruction.cpp | 13 ++++++++----- src/Selector/Selector_Selector.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 6ad810f2e..0c2e4cac9 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -275,14 +276,15 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap std::list > aFaces; GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), aWirePtr->norm(), aWirePtr, aFaces); - NCollection_DataMap aNewIndices; // edges indices + // order is important to store faces in the same order if sketch is created from scratch + NCollection_IndexedDataMap aNewIndices; // edges indices std::list >::iterator aFIter = aFaces.begin(); for (; aFIter != aFaces.end(); aFIter++) { std::shared_ptr aFace(new GeomAPI_Face(*aFIter)); // put them to a label, trying to keep the same faces on the same labels if (aFace.get() && !aFace->isNull()) { TopoDS_Face aTopoFace = TopoDS::Face(aFace->impl()); - aNewIndices.Bind(aTopoFace, TColStd_ListOfInteger()); + aNewIndices.Add(aTopoFace, TColStd_ListOfInteger()); // keep new indices of sub-elements used in this face for (TopExp_Explorer anEdges(aTopoFace, TopAbs_EDGE); anEdges.More(); anEdges.Next()) { TopoDS_Edge anEdge = TopoDS::Edge(anEdges.Current()); @@ -292,7 +294,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap int anIndex = aCurvesIndices.Find(aCurve); if ((aFirst > aLast) != (anEdge.Orientation() == TopAbs_REVERSED)) anIndex = -anIndex; - aNewIndices.ChangeFind(aTopoFace).Append(anIndex); + aNewIndices.ChangeFromKey(aTopoFace).Append(anIndex); } } } @@ -300,7 +302,8 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap NCollection_DataMap aFacesOrder; // faces -> tag where they must be set NCollection_List anUnorderedFaces; // faces that may be located at any index // searching for the best new candidate to old location - NCollection_DataMap::Iterator aNewIter(aNewIndices); + NCollection_IndexedDataMap::Iterator + aNewIter(aNewIndices); for (; aNewIter.More(); aNewIter.Next()) { double aBestFound = 0, aBestNotFound = 1.e+100; int aBestTag = 0; @@ -369,7 +372,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap aFaceBuilder.Generated(aFaceToPut); // store also indices of the new face edges Handle(TDataStd_IntPackedMap) aNewMap = TDataStd_IntPackedMap::Set(aLab); - const TColStd_ListOfInteger& aNewInd = aNewIndices.Find(aFaceToPut); + const TColStd_ListOfInteger& aNewInd = aNewIndices.FindFromKey(aFaceToPut); std::stringstream aName; aName<<"Face"; TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE); diff --git a/src/Selector/Selector_Selector.cpp b/src/Selector/Selector_Selector.cpp index 1f4fff984..d4b1f2319 100644 --- a/src/Selector/Selector_Selector.cpp +++ b/src/Selector/Selector_Selector.cpp @@ -943,8 +943,11 @@ std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) { std::list::iterator aSubSel = mySubSelList.begin(); for(; aSubSel != mySubSelList.end(); aSubSel++, aLevel++) { aResult += "(" + aSubSel->name(theNameGenerator) + ")"; - if (*aLevel > 1) - aResult += *aLevel; + if (*aLevel > 1) { + std::ostringstream aLevelStr; + aLevelStr<<*aLevel; + aResult += aLevelStr.str(); + } } return aResult; } -- 2.30.2