]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #1728 : order of shapes in NamingShapes sometimes was changed,...
authormpv <mpv@opencascade.com>
Wed, 7 Sep 2016 06:41:54 +0000 (09:41 +0300)
committermpv <mpv@opencascade.com>
Wed, 7 Sep 2016 06:41:54 +0000 (09:41 +0300)
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_BodyBuilder.cpp
src/Model/Model_ResultPart.cpp

index 3a9d350c7267d7bd07309d5169ab19f753f88b31..1de8bcb7e9595e1ca948ad4424fe0c115fee9afb 100644 (file)
@@ -55,7 +55,6 @@
 #include <TDataStd_Name.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopoDS_Iterator.hxx>
-#include <TNaming_Iterator.hxx>
 #include <BRep_Builder.hxx>
 #include <ModelAPI_Session.h>
 
index 856db04473f8860fe7d6c5f7152ecba4d4a0ba10..0dc8d7bd6fda2d74a65c950082795c11004c2b4e 100644 (file)
@@ -20,6 +20,7 @@
 #include <BRep_Tool.hxx>
 #include <TNaming_Builder.hxx>
 #include <TNaming_Iterator.hxx>
+#include <NCollection_List.hxx>
 
 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<TopoDS_Shape> aOlds;
+  NCollection_List<TopoDS_Shape> aNews;
+  NCollection_List<TNaming_Evolution> 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<TopoDS_Shape>::Iterator aOldIter(aOlds);
+  NCollection_List<TopoDS_Shape>::Iterator aNewIter(aNews);
+  NCollection_List<TNaming_Evolution>::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;
index 56d22c8c16ad58faaa8d17cd1f29108238e67b48..c8d20dbeee3044eb9e378a575cdf81e5110b781f 100755 (executable)
@@ -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<TopoDS_Shape, TopoDS_Shape>
+      // iterator goes in reversed order relatively to the Builder, to, make the list reversed
+      aShapePairs.push_front(std::pair<TopoDS_Shape, TopoDS_Shape>
         (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++;
         }
index a396e0dd07be17cb9f128fce3102b5e467fea324..f1e51b21f208fa684e288af6d21b2684635d222c 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <TNaming_Tool.hxx>
 #include <TNaming_NamedShape.hxx>
-#include <TNaming_Iterator.hxx>
 #include <TDataStd_Name.hxx>
 #include <TopoDS_Compound.hxx>
 #include <BRep_Builder.hxx>