From: mpv Date: Wed, 7 Sep 2016 06:41:54 +0000 (+0300) Subject: Fix for the issue #1728 : order of shapes in NamingShapes sometimes was changed,... X-Git-Tag: V_2.5.0~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=43a02140c75a93aecbc6a5cf45f60ce3e2f33703;p=modules%2Fshaper.git Fix for the issue #1728 : order of shapes in NamingShapes sometimes was changed, that produced instability in naming of saved or dumped studies --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 3a9d350c7..1de8bcb7e 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #include #include diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 856db0447..0dc8d7bd6 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace std; @@ -97,27 +98,38 @@ static void CopyNS(const Handle(TNaming_NamedShape)& theFrom, TDF_Label aLab = theTo->Label(); TNaming_Builder B(aLab); - TNaming_Iterator It (theFrom); - for ( ;It.More() ; It.Next()) { - const TopoDS_Shape& OS = It.OldShape(); - const TopoDS_Shape& NS = It.NewShape(); - TNaming_Evolution Status = It.Evolution(); + // TNaming_Iterator iterates in reversed way than it was put in Builder, so, keep it in container + // and iterate from end to begin + NCollection_List aOlds; + NCollection_List aNews; + NCollection_List aStatuses; - switch (Status) { + TNaming_Iterator anIt (theFrom); + for ( ;anIt.More() ; anIt.Next()) { + aOlds.Prepend(anIt.OldShape()); + aNews.Prepend(anIt.NewShape()); + aStatuses.Prepend(anIt.Evolution()); + } + + NCollection_List::Iterator aOldIter(aOlds); + NCollection_List::Iterator aNewIter(aNews); + NCollection_List::Iterator aStatIter(aStatuses); + for(; aOldIter.More(); aOldIter.Next(), aNewIter.Next(), aStatIter.Next()) { + switch (aStatIter.Value()) { case TNaming_PRIMITIVE : - B.Generated(NS); + B.Generated(aNewIter.Value()); break; case TNaming_GENERATED : - B.Generated(OS, NS); + B.Generated(aOldIter.Value(), aNewIter.Value()); break; case TNaming_MODIFY : - B.Modify(OS, NS); + B.Modify(aOldIter.Value(), aNewIter.Value()); break; case TNaming_DELETE : - B.Delete (OS); + B.Delete (aOldIter.Value()); break; case TNaming_SELECTED : - B.Select(NS, OS); + B.Select(aNewIter.Value(), aOldIter.Value()); break; default: break; diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 56d22c8c1..c8d20dbee 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -66,9 +66,10 @@ static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) { } else { TDataStd_Integer::Set(theLab, anEvolution); } - + for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) { - aShapePairs.push_back(std::pair + // iterator goes in reversed order relatively to the Builder, to, make the list reversed + aShapePairs.push_front(std::pair (anIter.OldShape(), anIter.NewShape())); } } @@ -464,7 +465,6 @@ void Model_BodyBuilder::loadAndOrientGeneratedShapes ( TNaming_Builder aBuilder(aChildLabel); aBuilder.Generated(aRoot, anExp.Current()); TCollection_AsciiString aChildName = TCollection_AsciiString((theName + "_").c_str()) + aTag; - //aDoc->addNamingName(aChildLabel, aChildName.ToCString()); TDataStd_Name::Set(aChildLabel, aChildName.ToCString()); aTag++; } diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index a396e0dd0..f1e51b21f 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include