]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fast try to fix 2241 due to customized movement of Group to the end, not standard... Dev_2241_research
authormpv <mpv@opencascade.com>
Mon, 11 Sep 2017 08:34:55 +0000 (11:34 +0300)
committermpv <mpv@opencascade.com>
Mon, 11 Sep 2017 08:34:55 +0000 (11:34 +0300)
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/FeaturesPlugin/Test/Test2240.py
src/Model/Model_BodyBuilder.cpp
src/Model/Model_BodyBuilder.h
src/Model/Model_ResultCompSolid.cpp
src/Model/Model_ResultCompSolid.h
src/ModelAPI/ModelAPI_BodyBuilder.h
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_ResultBody.h

index afb763fc614e09bd5a30eb49f3ba37afc0a40ac4..f557e6bc3e282768123ad3848a5dc02668c0d733 100755 (executable)
@@ -181,7 +181,23 @@ void FeaturesPlugin_Partition::storeResult(
   int aModTag = aSubTag + 10000;
   const std::string aModName = "Modified";
 
-  aResultBody->storeModified(aBaseShape, theResultShape, aSubTag);
+  // issue #2241 : make result of partition modified from all input objects (except planes)
+  bool aIsModifierStored = false;
+  for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) {
+    GeomShapePtr anObjectShape = *anIt;
+    GeomShapePtr aCandidate =
+      findBase(anObjectShape, theResultShape, GeomAPI_Shape::VERTEX, theMakeShape);
+    if(!aCandidate.get()) {
+      aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::EDGE, theMakeShape);
+    }
+    if (!aCandidate.get())
+      aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::FACE, theMakeShape);
+
+    if(aCandidate.get()) {
+      aResultBody->storeModified(aCandidate, theResultShape, aSubTag, !aIsModifierStored);
+      aIsModifierStored = true;
+    }
+  }
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = theMakeShape->mapOfSubShapes();
   theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end());
index 5317ea29b425ba88ba9c1d704b8619285afc9b17..2277cebea430b99265cde1d9a8c2e82a2576acd0 100644 (file)
@@ -97,13 +97,13 @@ Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-Sketc
 Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_9f-SketchLine_10r-SketchArc_1_2f-SketchArc_2_2r")])
 Face_3 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2")])
 Face_4 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")])
-Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1")])
 Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")])
 Group_1.result().setName("eau")
 Group_1.result().setColor(0, 170, 255)
 Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_4_1")])
 Group_2.result().setName("acier")
 Group_2.result().setColor(170, 85, 0)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1")])
 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOY"))
 SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0)
 SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "Partition_1_1_1/Modified_Edge_15_6&Partition_1_1_1/Modified_Edge_15_5"))
index ad63bee3e9e1dc9dc5598558dd95326372b62e14..3a8ddb11f3398c37a6f95f9064ab45ac6dd5d4aa 100755 (executable)
@@ -203,15 +203,16 @@ void Model_BodyBuilder::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& the
 }
 
 void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag,
+  const bool theClean)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   if (aData) {
-    TDF_Label& aShapeLab = aData->shapeLab();
     // clean builders
-    clean();
+    if (theClean)
+      clean();
     // store the new shape as primitive
-    TNaming_Builder aBuilder(aShapeLab);
+    TNaming_Builder* aBuilder = builder(0);
     if (!theOldShape || !theNewShape)
       return;  // bad shape
     TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
@@ -220,15 +221,15 @@ void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theO
     TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
     if (aShapeNew.IsNull())
       return;  // null shape inside
-    aBuilder.Modify(aShapeOld, aShapeNew);
-    if(!aBuilder.NamedShape()->IsEmpty()) {
+    aBuilder->Modify(aShapeOld, aShapeNew);
+    if(!aBuilder->NamedShape()->IsEmpty()) {
       Handle(TDataStd_Name) anAttr;
-      if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+      if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
         std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
         if(!aName.empty()) {
           std::shared_ptr<Model_Document> aDoc =
             std::dynamic_pointer_cast<Model_Document>(document());
-          aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
+          aDoc->addNamingName(aBuilder->NamedShape()->Label(), aName);
         }
       }
     }
@@ -275,7 +276,8 @@ TNaming_Builder* Model_BodyBuilder::builder(const int theTag)
   std::map<int, TNaming_Builder*>::iterator aFind = myBuilders.find(theTag);
   if (aFind == myBuilders.end()) {
     std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
-    myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
+    TDF_Label aLab = theTag == 0 ? aData->shapeLab() : aData->shapeLab().FindChild(theTag);
+    myBuilders[theTag] = new TNaming_Builder(aLab);
     aFind = myBuilders.find(theTag);
   }
   return aFind->second;
index 983c03a7564f5f7564d0e9a48c8641d721a1589a..b94dc483df32d62f2d7f3c51b663559703dfc915 100755 (executable)
@@ -55,7 +55,8 @@ public:
   ///          theNewShape is compound of solids, if zero it is not used
   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
                                                const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-                                          const int theDecomposeSolidsTag = 0);
+                                          const int theDecomposeSolidsTag = 0,
+                                          const bool theClean = true);
 
   /// Stores the shape without naming support
   /// \param theShape shape to store
index 0fa8b4fd188ec6fb7dc949a3af1c2ad2653e1adf..dcda320fc79797aea44d9f2831e574c2b6f2d93f 100755 (executable)
@@ -59,9 +59,11 @@ void Model_ResultCompSolid::storeGenerated(const std::shared_ptr<GeomAPI_Shape>&
 }
 
 void Model_ResultCompSolid::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag,
+    const bool theClean)
 {
-  ModelAPI_ResultCompSolid::storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+  ModelAPI_ResultCompSolid::storeModified(theOldShape, theNewShape, theDecomposeSolidsTag,
+    theClean);
   updateSubs(theNewShape);
 }
 
index 7fcf5cc59bae616da02259d634912179528e381b..0e0f0d02074cad21aecfc05a43652857ddd682fb 100755 (executable)
@@ -55,7 +55,8 @@ public:
 
   /// Stores the modified shape.  Creates sub-results for compsolid.
   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0,
+    const bool theClean = true);
 
   /// load and orient modified shapes for sub-objects
   MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
index 8524cc31d83b15576be3791b6fdd0e9f632221b1..a2dd16513be0d450c4ee2a206617d4e902526d58 100755 (executable)
@@ -52,7 +52,8 @@ public:
   /// Stores the modified shape (called by the execution method).
   virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
                                  const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-                            const int theDecomposeSolidsTag = 0) = 0;
+                            const int theDecomposeSolidsTag = 0,
+                            const bool theClean = true) = 0;
 
   /// Stores the shape without naming support
   virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
index 4025d17b769b0a4e744586473d1c764982a9026e..11dc5f3ce6ccb5dbfd723d480f3aee58ff512ef6 100644 (file)
@@ -66,9 +66,9 @@ void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& t
 
 void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
                                  const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-                            const int theDecomposeSolidsTag)
+                            const int theDecomposeSolidsTag, const bool theClean)
 {
-  myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+  myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag, theClean);
   myConnect = ConnectionNotComputed;
 
   static Events_Loop* aLoop = Events_Loop::loop();
index 98a4b6a290c53f76da28f7e60c94c1f3d8597b3f..35b66104f3e8a4d18a85005e51d61e7d618daf85 100644 (file)
@@ -86,7 +86,8 @@ public:
 
   /// Stores the modified shape (called by the execution method).
   MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0,
+    const bool theClean = true);
 
   /// Stores the shape without naming support
   MODELAPI_EXPORT virtual void storeWithoutNaming(