]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Basing on the issue #1757 make extrusion-cut that
authormpv <mpv@opencascade.com>
Wed, 21 Nov 2018 05:31:50 +0000 (08:31 +0300)
committermpv <mpv@opencascade.com>
Wed, 21 Nov 2018 05:32:19 +0000 (08:32 +0300)
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h
src/Model/Model_BodyBuilder.cpp
src/Model/Model_BodyBuilder.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/ModelAPI/ModelAPI_BodyBuilder.h
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_ResultBody.h
src/Selector/Selector_FilterByNeighbors.cpp

index 398ff651c0fff8e61ac5518d76c62fa545c7718e..272b43001f51c77bfcd0cd5563caf18ec39b9d64 100644 (file)
@@ -39,7 +39,8 @@
 #include <map>
 #include <sstream>
 
-static void storeSubShape(ResultBodyPtr theResultBody,
+static void storeSubShape(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+                          ResultBodyPtr theResultBody,
                           const GeomShapePtr theShape,
                           const GeomAPI_Shape::ShapeType theType,
                           const std::string& theName);
@@ -337,18 +338,20 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes
   std::list<std::shared_ptr<GeomAlgoAPI_MakeSweep> >::iterator aSweep = aSweeps.begin();
   for(; aSweep != aSweeps.end(); aSweep++) {
     // Store from shapes.
-    storeShapes(theResultBody, aBaseShapeType, (*aSweep)->fromShapes(), "From_");
+    storeShapes(theMakeShape, theResultBody, aBaseShapeType, (*aSweep)->fromShapes(), "From_");
 
     // Store to shapes.
-    storeShapes(theResultBody, aBaseShapeType, (*aSweep)->toShapes(), "To_");
+    storeShapes(theMakeShape, theResultBody, aBaseShapeType, (*aSweep)->toShapes(), "To_");
   }
 }
 
 //=================================================================================================
-void FeaturesPlugin_CompositeSketch::storeShapes(ResultBodyPtr theResultBody,
-                              const GeomAPI_Shape::ShapeType theBaseShapeType,
-                              const ListOfShape& theShapes,
-                              const std::string theName)
+void FeaturesPlugin_CompositeSketch::storeShapes(
+  const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+  ResultBodyPtr theResultBody,
+  const GeomAPI_Shape::ShapeType theBaseShapeType,
+  const ListOfShape& theShapes,
+  const std::string theName)
 {
   GeomAPI_Shape::ShapeType aShapeTypeToExplore = GeomAPI_Shape::FACE;
   std::string aShapeTypeStr = "Face";
@@ -382,25 +385,31 @@ void FeaturesPlugin_CompositeSketch::storeShapes(ResultBodyPtr theResultBody,
 
     if(aShapeTypeToExplore == GeomAPI_Shape::COMPOUND) {
       std::string aName = theName + (aShape->shapeType() == GeomAPI_Shape::EDGE ? "Edge" : "Face");
-      storeSubShape(theResultBody, aShape, aShape->shapeType(), aName);
+      storeSubShape(theMakeShape, theResultBody, aShape, aShape->shapeType(), aName);
     } else {
       std::string aName = theName + aShapeTypeStr;
-      storeSubShape(theResultBody, aShape, aShapeTypeToExplore, aName);
+      storeSubShape(theMakeShape, theResultBody, aShape, aShapeTypeToExplore, aName);
       if (theBaseShapeType == GeomAPI_Shape::WIRE) { // issue 2289: special names also for vertices
         aName = theName + "Vertex";
-        storeSubShape(theResultBody, aShape, GeomAPI_Shape::VERTEX, aName);
+        storeSubShape(theMakeShape, theResultBody, aShape, GeomAPI_Shape::VERTEX, aName);
       }
     }
   }
 }
 
-void storeSubShape(ResultBodyPtr theResultBody,
-                   const GeomShapePtr theShape,
-                   const GeomAPI_Shape::ShapeType theType,
-                   const std::string& theName)
+void storeSubShape(
+  const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+  ResultBodyPtr theResultBody,
+  const GeomShapePtr theShape,
+  const GeomAPI_Shape::ShapeType theType,
+  const std::string& theName)
 {
   for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
     GeomShapePtr aSubShape = anExp.current();
-    theResultBody->generated(aSubShape, theName);
+    if (!theResultBody->generated(aSubShape, theName)) {
+      // store from/to shapes as primitives and then store modification of them by the boolean
+      theResultBody->generated(aSubShape, theName, false);
+      theResultBody->loadModifiedShapes(theMakeShape, aSubShape, theType);
+    }
   }
 }
index 074def66b82d6dbe5093c2bed24de2c62d9ed34d..e4774bde88458bf02d52b6ce613e7afc0ef1db1b 100644 (file)
@@ -96,8 +96,9 @@ protected:
                               const GeomShapePtr theBaseShape,
                               const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
 
-  /// Used to store from and to shapes.
-  void storeShapes(ResultBodyPtr theResultBody,
+  /// Used to store from and to shapes: generated, or in common modified tag
+  void storeShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+                   ResultBodyPtr theResultBody,
                    const GeomAPI_Shape::ShapeType theBaseShapeType,
                    const ListOfShape& theShapes,
                    const std::string theName);
index 8446d00cb0d548dc711a9de6c1da1a3868e86d05..9c51617f123342e7acef38dd23383c727a82fd27 100755 (executable)
@@ -317,14 +317,16 @@ void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
 
   TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str());
 }
-void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
-                                  const std::string& theName)
+bool Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
+                                  const std::string& theName,
+                                  const bool theCheckIsInResult)
 {
   GeomShapePtr aResultShape = shape();
-
-  bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
-  if (aNewShapeIsNotInResultShape) {
-    return;
+  if (theCheckIsInResult) {
+    bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
+    if (aNewShapeIsNotInResultShape) {
+      return false;
+    }
   }
 
   TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
@@ -349,6 +351,7 @@ void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
     buildName(myFreePrimitiveTag, aName);
   }
   ++myFreePrimitiveTag;
+  return true;
 }
 
 void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape,
index 78aac03490d176709bc78b2f3ab1fc2cca75e6de..440791b6971e38a0274567785210f3f7ab4505d3 100755 (executable)
@@ -66,8 +66,9 @@ public:
 
   /// Records the subshape newShape which was generated during a topological construction.
   /// As an example, consider the case of a face generated in construction of a box.
-  MODEL_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
-                                      const std::string& theName) override;
+  /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
+  MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
+    const std::string& theName, const bool theCheckIsInResult = true) override;
 
   /// Records the shape newShape which was generated from the shape oldShape during a topological
   /// construction. As an example, consider the case of a face generated from an edge in
index cfc9ff6e306d1b28ba1b12614e4def24dca8e0ac..8b736b3390be79340d546aceab0e8125992e375c 100644 (file)
@@ -52,20 +52,24 @@ Model_ResultBody::~Model_ResultBody()
   delete myBuilder;
 }
 
-void Model_ResultBody::generated(const GeomShapePtr& theNewShape,
-                                 const std::string& theName)
+bool Model_ResultBody::generated(const GeomShapePtr& theNewShape,
+  const std::string& theName, const bool theCheckIsInResult)
 {
+  bool aResult = false;
   if (mySubs.size()) { // consists of subs
     for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
          aSubIter != mySubs.cend();
          ++aSubIter)
     {
       const ResultBodyPtr& aSub = *aSubIter;
-      aSub->generated(theNewShape, theName);
+      if (aSub->generated(theNewShape, theName, theCheckIsInResult))
+        aResult = true;
     }
   } else { // do for this directly
-    myBuilder->generated(theNewShape, theName);
+    if (myBuilder->generated(theNewShape, theName, theCheckIsInResult))
+      aResult = true;
   }
+  return aResult;
 }
 
 void Model_ResultBody::loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
index 62817a9bf08f9eaefd9eaa3f6d0da4602dfe5ddb..95cb798c8de25cfd3c44794050429c93c28eddeb 100644 (file)
@@ -51,8 +51,8 @@ public:
 
   /// Records the subshape newShape which was generated during a topological construction.
   /// As an example, consider the case of a face generated in construction of a box.
-  MODEL_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
-                                      const std::string& theName) override;
+  MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
+    const std::string& theName, const bool theCheckIsInResult = true) override;
 
   /// load generated shapes
   MODEL_EXPORT
index b44e0d2b9916f16954afec2ec2ffd6f8c285d921..d551a0104b10cc9f5695c1c249286ae65008ee8d 100755 (executable)
@@ -62,8 +62,9 @@ public:
 
   /// Records the subshape newShape which was generated during a topological construction.
   /// As an example, consider the case of a face generated in construction of a box.
-  virtual void generated(const GeomShapePtr& theNewShape,
-                         const std::string& theName) = 0;
+  /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
+  virtual bool generated(const GeomShapePtr& theNewShape,
+    const std::string& theName, const bool theCheckIsInResult = true) = 0;
 
   /// Records the shape newShape which was generated from the shape oldShape during a topological
   /// construction. As an example, consider the case of a face generated from an edge in
index 806df516e21668514e1acb4ab1a4b0b9d1da20bb..96507db5743de1a1db4b9637767f94d5f9336e80 100644 (file)
@@ -98,10 +98,10 @@ GeomShapePtr ModelAPI_ResultBody::shape()
   return myBuilder->shape();
 }
 
-void ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape,
-                                    const std::string& theName)
+bool ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape,
+  const std::string& theName, const bool theCheckIsInResult)
 {
-  myBuilder->generated(theNewShape, theName);
+  return myBuilder->generated(theNewShape, theName, theCheckIsInResult);
 }
 
 void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
index aaf1bbecc6f3a7b6a06681905a660a7bafd280a2..8cb8afdf169227906a31a91791889350818ea88d 100644 (file)
@@ -115,8 +115,9 @@ public:
 
   /// Records the subshape newShape which was generated during a topological construction.
   /// As an example, consider the case of a face generated in construction of a box.
-  MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
-                                         const std::string& theName);
+  /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
+  MODELAPI_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
+    const std::string& theName, const bool theCheckIsInResult = true);
 
   /// Records the shape newShape which was generated from the shape oldShape during a topological
   /// construction. As an example, consider the case of a face generated from an edge in
index 41049e877f606a0b20a7b3c28255381056c64a68..06ae4785f03dafcb113b3c3452f2f1daee9f661a 100644 (file)
@@ -260,7 +260,7 @@ bool Selector_FilterByNeighbors::restore()
       break; // some empty label left in the end
     }
   }
-  return true;
+  return myNBLevel.size() == list().size();
 }
 
 TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName,