]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_ResultConstruction.cpp
Salome HOME
Fix for Test2514.py : vertices of the sketch element is renamed with rename of the...
[modules/shaper.git] / src / Model / Model_ResultConstruction.cpp
index b1ec3c9fc5aba4f71078d9e47c78f842c2d79ec3..76706aa41e2f1da6973354ec75f082fdbc23332d 100644 (file)
@@ -23,6 +23,7 @@
 #include <Model_Data.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
+#include <GeomAPI_Tools.h>
 #include <ModelAPI_Events.h>
 #include <Model_Document.h>
 #include <GeomAPI_PlanarEdges.h>
@@ -73,10 +74,6 @@ void Model_ResultConstruction::setShape(std::shared_ptr<GeomAPI_Shape> theShape)
       ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
     }
     myShape = theShape;
-    if (myShape.get() && myShape->shapeType() == GeomAPI_Shape::COMPOUND &&
-      std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(myShape).get() == NULL) {
-      int a= 10;
-    }
   }
 }
 
@@ -134,7 +131,7 @@ bool Model_ResultConstruction::updateShape()
         // just restore shape
         GeomShapePtr aGShape(new GeomAPI_Shape);
         aGShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aShape));
-        myShape = aGShape; // restore the sketch sub-components
+        myShape = GeomAPI_Tools::getTypedShape(aGShape); // restore the sketch sub-components
         return true;
       }
     }
@@ -400,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;
@@ -423,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++;