]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for Test2514.py : vertices of the sketch element is renamed with rename of the...
authormpv <mpv@opencascade.com>
Thu, 1 Nov 2018 11:30:21 +0000 (14:30 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
src/Model/Model_Document.cpp
src/Model/Model_ResultConstruction.cpp

index 1dda5514cf2ff7d8d9ec297c5fdbbd921375e035..4c584ea7782798ee426295b2ebb89574e8482caa 100755 (executable)
@@ -1422,6 +1422,17 @@ void Model_Document::changeNamingName(const std::string theOldName,
         } else { // remove from the list
           aFind->second.erase(aLabIter);
         }
+        // check the sketch vertex name located under renamed sketch line
+        TDF_ChildIDIterator aChild(theLabel, TDataStd_Name::GetID());
+        for(; aChild.More(); aChild.Next()) {
+          Handle(TDataStd_Name) aSubName = Handle(TDataStd_Name)::DownCast(aChild.Value());
+          std::string aName = TCollection_AsciiString(aSubName->Get()).ToCString();
+          if (aName.find(theOldName) == 0) { // started from parent name
+            std::string aNewSubName = theNewName + aName.substr(theNewName.size());
+            changeNamingName(aName, aNewSubName, aSubName->Label());
+            aSubName->Set(aNewSubName.c_str());
+          }
+        }
         return;
       }
     }
index 6dc346aa0d27bdc5a8dd6da55b90db06609b2467..76706aa41e2f1da6973354ec75f082fdbc23332d 100644 (file)
@@ -255,15 +255,6 @@ void Model_ResultConstruction::storeShape(std::shared_ptr<GeomAPI_Shape> theShap
         TNaming_Builder aBuilder(aSubLab);
         aBuilder.Generated(anExp.Current());
         std::string aVertexName = aMyName + "_" + (anIndex == 1 ? "StartVertex" : "EndVertex");
-        // check this name is already used
-        ResultPtr aThisRes;
-        do {
-          static std::string anEmpty;
-          static bool aUnique;
-          aThisRes = aMyDoc->findByName(aVertexName, anEmpty, aUnique);
-          if (aThisRes.get() && aThisRes.get() != this)
-            aVertexName += "x";
-        } while(aThisRes.get() && aThisRes.get() != this);
         TDataStd_Name::Set(aSubLab, aVertexName.c_str());
         aMyDoc->addNamingName(aSubLab, aVertexName);
       }
@@ -406,7 +397,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr<GeomAPI_Shape> theShap
           std::stringstream aName;
           aName<<"Face";
           TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE);
-          TNaming_Builder* anEdgesBuilder = 0;
+          TNaming_Builder *anEdgesBuilder = 0, *aVerticesBuilder = 0;
           for(TColStd_ListOfInteger::Iterator anIter(aNewInd); anIter.More(); anIter.Next()) {
             int anIndex = anIter.Value();
             int aModIndex = anIndex > 0 ? anIndex : -anIndex;
@@ -429,20 +420,43 @@ void Model_ResultConstruction::storeShape(std::shared_ptr<GeomAPI_Shape> theShap
               }
               anEdgesBuilder->Modify(anEdgeIndices.Find(aModIndex), aPutEdges.Current());
             }
+            // put also modified vertices, otherwise vertex of original edge has no history
+            if (anEdgeIndices.IsBound(aModIndex)) {
+              TopExp_Explorer aVExpOld(anEdgeIndices.Find(aModIndex), TopAbs_VERTEX);
+              TopExp_Explorer aVExpNew(aPutEdges.Current(), TopAbs_VERTEX);
+              for(; aVExpNew.More() && aVExpOld.More(); aVExpNew.Next(), aVExpOld.Next()) {
+                if (!aVExpOld.Current().IsSame(aVExpNew.Current())) {
+                  if (!aVerticesBuilder) {
+                    TDF_Label aVertLabel = aLab.FindChild(2);
+                    aVerticesBuilder = new TNaming_Builder(aVertLabel);
+                    std::ostringstream aSubName;
+                    // tag is needed for Test1922 to distinguish sub-edges of different faces
+                    aSubName<<"SubVertex_"<<aCurrentTag;
+                    TDataStd_Name::Set(aVertLabel, aSubName.str().c_str());
+                  }
+                  aVerticesBuilder->Modify(aVExpOld.Current(), aVExpNew.Current());
+
+                }
+              }
+            }
             aPutEdges.Next();
           }
+          if (anEdgesBuilder)
+            delete anEdgesBuilder;
+          if (aVerticesBuilder)
+            delete aVerticesBuilder;
           TDataStd_Name::Set(aLab, TCollection_ExtendedString(aName.str().c_str()));
           aMyDoc->addNamingName(aLab, aName.str());
           // put also wires to sub-labels to correctly select them instead of collection by edges
-          int aWireTag = 2; // first tag is for SubEdge-s
+          int aWireTag = 3; // first tag is for SubEdge-s, second - for vertices
           for(TopExp_Explorer aWires(aFaceToPut, TopAbs_WIRE); aWires.More(); aWires.Next()) {
             TDF_Label aWireLab = aLab.FindChild(aWireTag);
             TNaming_Builder aWireBuilder(aWireLab);
             aWireBuilder.Generated(aWires.Current());
             std::ostringstream aWireName;
             aWireName<<aName.str()<<"_wire";
-            if (aWireTag > 2)
-              aWireName<<"_"<<aWireTag - 1;
+            if (aWireTag > 3)
+              aWireName<<"_"<<aWireTag - 2;
             TDataStd_Name::Set(aWireLab, aWireName.str().c_str());
             aMyDoc->addNamingName(aWireLab, aWireName.str());
             aWireTag++;