]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
GeomAlgoAPI_Boolean now derived from GeomAlgoAPI_MakeShape
authordbv <dbv@opencascade.com>
Wed, 23 Dec 2015 15:13:51 +0000 (18:13 +0300)
committerdbv <dbv@opencascade.com>
Thu, 24 Dec 2015 07:57:26 +0000 (10:57 +0300)
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h

index 6a9e9392910deaa12c63215ad17528248acb242a..7425816a64612668e075c8bd22f24978379f9380 100644 (file)
@@ -151,7 +151,7 @@ void FeaturesPlugin_Boolean::execute()
 
         if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-7) {
           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-          loadNamingDS(aResultBody, anObject, aTools, aBoolAlgo.shape(), *aBoolAlgo.makeShape(), *aBoolAlgo.mapOfShapes());
+          loadNamingDS(aResultBody, anObject, aTools, aBoolAlgo.shape(), aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
@@ -178,33 +178,33 @@ void FeaturesPlugin_Boolean::execute()
           }
         }
 
-        GeomAlgoAPI_Boolean aBoolAlgo(aUsedInOperationSolids, aTools, aType);
+        std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aUsedInOperationSolids, aTools, aType));
 
         // Checking that the algorithm worked properly.
-        if(!aBoolAlgo.isDone()) {
+        if(!aBoolAlgo->isDone()) {
           static const std::string aFeatureError = "Boolean algorithm failed";
           setError(aFeatureError);
           return;
         }
-        if(aBoolAlgo.shape()->isNull()) {
+        if(aBoolAlgo->shape()->isNull()) {
           static const std::string aShapeError = "Resulting shape is Null";
           setError(aShapeError);
           return;
         }
-        if(!aBoolAlgo.isValid()) {
+        if(!aBoolAlgo->isValid()) {
           std::string aFeatureError = "Warning: resulting shape is not valid";
           setError(aFeatureError);
           return;
         }
 
         GeomAlgoAPI_MakeShapeList aMakeShapeList;
-        aMakeShapeList.appendAlgo(aBoolAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aBoolAlgo);
         GeomAPI_DataMapOfShapeShape aMapOfShapes;
-        aMapOfShapes.merge(aBoolAlgo.mapOfShapes());
+        aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
 
         // Add result to not used solids from compsolid.
         ListOfShape aShapesToAdd = aNotUsedSolids;
-        aShapesToAdd.push_back(aBoolAlgo.shape());
+        aShapesToAdd.push_back(aBoolAlgo->shape());
         GeomAlgoAPI_PaveFiller aFillerAlgo(aShapesToAdd, true);
         if(!aFillerAlgo.isDone()) {
           std::string aFeatureError = "PaveFiller algorithm failed";
@@ -270,12 +270,12 @@ void FeaturesPlugin_Boolean::execute()
         for(ListOfShape::iterator anIt = anOriginalSolids.begin(); anIt != anOriginalSolids.end(); anIt++) {
           ListOfShape aOneObjectList;
           aOneObjectList.push_back(*anIt);
-          GeomAlgoAPI_Boolean aCutAlgo(aOneObjectList, aNotUsedSolids, GeomAlgoAPI_Boolean::BOOL_CUT);
+          std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(aOneObjectList, aNotUsedSolids, GeomAlgoAPI_Boolean::BOOL_CUT));
 
-          if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo.shape()) > 1.e-7) {
-            aSolidsToFuse.push_back(aCutAlgo.shape());
-            aMakeShapeList.appendAlgo(aCutAlgo.makeShape());
-            aMapOfShapes.merge(aCutAlgo.mapOfShapes());
+          if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-7) {
+            aSolidsToFuse.push_back(aCutAlgo->shape());
+            aMakeShapeList.appendAlgo(aCutAlgo);
+            aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
           }
         }
       }
@@ -286,28 +286,28 @@ void FeaturesPlugin_Boolean::execute()
       aTools = aSolidsToFuse;
 
       // Fuse all objects and all tools.
-      GeomAlgoAPI_Boolean aFuseAlgo(anObjects, aTools, aType);
+      std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects, aTools, aType));
 
       // Checking that the algorithm worked properly.
-      if(!aFuseAlgo.isDone()) {
+      if(!aFuseAlgo->isDone()) {
         static const std::string aFeatureError = "Boolean algorithm failed";
         setError(aFeatureError);
         return;
       }
-      if(aFuseAlgo.shape()->isNull()) {
+      if(aFuseAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Resulting shape is Null";
         setError(aShapeError);
         return;
       }
-      if(!aFuseAlgo.isValid()) {
+      if(!aFuseAlgo->isValid()) {
         std::string aFeatureError = "Warning: resulting shape is not valid";
         setError(aFeatureError);
         return;
       }
 
-      std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo.shape();
-      aMakeShapeList.appendAlgo(aFuseAlgo.makeShape());
-      aMapOfShapes.merge(aFuseAlgo.mapOfShapes());
+      std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo->shape();
+      aMakeShapeList.appendAlgo(aFuseAlgo);
+      aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
 
       // Add result to not used solids from compsolid (if we have any).
       if(!aNotUsedSolids.empty()) {
index 2737a82fb64bfd345a8672a80038f0865201e392..0eb79e23a44e1f4f66237973dfb714e33296288a 100644 (file)
@@ -203,7 +203,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
         if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-7) {
           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
           loadNamingDS(aResultBody, aShells, aSolidsAlgos, anObject, aTools, aBoolAlgo.shape(),
-                       *aBoolAlgo.makeShape(), *aBoolAlgo.mapOfShapes());
+                       aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
@@ -230,22 +230,22 @@ void FeaturesPlugin_CompositeBoolean::execute()
           }
         }
 
-        GeomAlgoAPI_Boolean aBoolAlgo(aUsedInOperationSolids, aTools, myBooleanOperationType);
+        std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aUsedInOperationSolids, aTools, myBooleanOperationType));
 
         // Checking that the algorithm worked properly.
-        if(!aBoolAlgo.isDone() || aBoolAlgo.shape()->isNull() || !aBoolAlgo.isValid()) {
+        if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) {
           setError("Boolean algorithm failed");
           return;
         }
 
         GeomAlgoAPI_MakeShapeList aMakeShapeList;
-        aMakeShapeList.appendAlgo(aBoolAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aBoolAlgo);
         GeomAPI_DataMapOfShapeShape aMapOfShapes;
-        aMapOfShapes.merge(aBoolAlgo.mapOfShapes());
+        aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
 
         // Add result to not used solids from compsolid.
         ListOfShape aShapesToAdd = aNotUsedSolids;
-        aShapesToAdd.push_back(aBoolAlgo.shape());
+        aShapesToAdd.push_back(aBoolAlgo->shape());
         GeomAlgoAPI_PaveFiller aFillerAlgo(aShapesToAdd, true);
         if(!aFillerAlgo.isDone()) {
           std::string aFeatureError = "PaveFiller algorithm failed";
@@ -305,12 +305,12 @@ void FeaturesPlugin_CompositeBoolean::execute()
         for(ListOfShape::iterator anIt = anOriginalSolids.begin(); anIt != anOriginalSolids.end(); anIt++) {
           ListOfShape aOneObjectList;
           aOneObjectList.push_back(*anIt);
-          GeomAlgoAPI_Boolean aCutAlgo(aOneObjectList, aNotUsedSolids, GeomAlgoAPI_Boolean::BOOL_CUT);
+          std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(aOneObjectList, aNotUsedSolids, GeomAlgoAPI_Boolean::BOOL_CUT));
 
-          if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo.shape()) > 1.e-7) {
-            aSolidsToFuse.push_back(aCutAlgo.shape());
-            aMakeShapeList.appendAlgo(aCutAlgo.makeShape());
-            aMapOfShapes.merge(aCutAlgo.mapOfShapes());
+          if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-7) {
+            aSolidsToFuse.push_back(aCutAlgo->shape());
+            aMakeShapeList.appendAlgo(aCutAlgo);
+            aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
           }
         }
       }
@@ -321,18 +321,18 @@ void FeaturesPlugin_CompositeBoolean::execute()
       aTools = aSolidsToFuse;
 
       // Fuse all objects and all tools.
-      GeomAlgoAPI_Boolean aFuseAlgo(anObjects, aTools, myBooleanOperationType);
+      std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects, aTools, myBooleanOperationType));
 
       // Checking that the algorithm worked properly.
-      if(!aFuseAlgo.isDone() || aFuseAlgo.shape()->isNull() || !aFuseAlgo.isValid()) {
+      if(!aFuseAlgo->isDone() || aFuseAlgo->shape()->isNull() || !aFuseAlgo->isValid()) {
         static const std::string aFeatureError = "Boolean algorithm failed";
         setError(aFeatureError);
         return;
       }
 
-      std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo.shape();
-      aMakeShapeList.appendAlgo(aFuseAlgo.makeShape());
-      aMapOfShapes.merge(aFuseAlgo.mapOfShapes());
+      std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo->shape();
+      aMakeShapeList.appendAlgo(aFuseAlgo);
+      aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
 
       // Add result to not used solids from compsolid (if we have any).
       if(!aNotUsedSolids.empty()) {
index 709031f3b14626ceb742a05169eb89ae20f22367..5322a17e574f2cda35773de03e882ea21fb734c7 100644 (file)
 #include <BRepAlgoAPI_Common.hxx>
 #include <BRepAlgoAPI_Cut.hxx>
 #include <BRepAlgoAPI_Fuse.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <TopExp_Explorer.hxx>
 #include <TopTools_ListOfShape.hxx>
 
 //=================================================================================================
 GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const ListOfShape& theObjects,
                                          const ListOfShape& theTools,
                                          const OperationType theOperationType)
-: myDone(false)
 {
   build(theObjects, theTools, theOperationType);
 }
@@ -68,14 +65,14 @@ void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects,
       return;
     }
   }
-  myMkShape.reset(new GeomAlgoAPI_MakeShape(anOperation));
+  this->setImpl(anOperation);
+  this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
   anOperation->SetArguments(anObjects);
   anOperation->SetTools(aTools);
 
   // Building and getting result.
   anOperation->Build();
-  myDone = anOperation->IsDone() == Standard_True;
-  if(!myDone) {
+  if(anOperation->IsDone() != Standard_True) {
     return;
   }
   TopoDS_Shape aResult = anOperation->Shape();
@@ -84,45 +81,8 @@ void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects,
     aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
   }
 
-  // fill data map to keep correct orientation of sub-shapes
-  myMap.reset(new GeomAPI_DataMapOfShapeShape());
-  for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
-    std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
-    aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
-    myMap->bind(aCurrentShape, aCurrentShape);
-  }
-  myShape.reset(new GeomAPI_Shape());
-  myShape->setImpl(new TopoDS_Shape(aResult));
-
-}
-
-//=================================================================================================
-const bool GeomAlgoAPI_Boolean::isDone() const
-{
-  return myDone;
-}
-
-//=================================================================================================
-const bool GeomAlgoAPI_Boolean::isValid() const
-{
-  BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
-  return (aChecker.IsValid() == Standard_True);
-}
-
-//=================================================================================================
-const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Boolean::shape() const
-{
-  return myShape;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Boolean::mapOfShapes() const
-{
-  return myMap;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Boolean::makeShape() const
-{
-  return myMkShape;
+  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  aShape->setImpl(new TopoDS_Shape(aResult));
+  this->setShape(aShape);
+  this->setDone(true);
 }
index 5c2059b88f1cf20867e1980b056152be198347dd..df42f8e3b33cf724673eaf9b0538adb38a899a52 100644 (file)
 #include <GeomAlgoAPI_MakeShape.h>
 
 #include <GeomAPI_Shape.h>
-#include <GeomAPI_Interface.h>
-#include <GeomAPI_DataMapOfShapeShape.h>
 
-#include <memory>
-
-/** \class GeomAlgoAPI_Boolean
- *  \ingroup DataAlgo
- *  \brief Allows to perform of boolean operations
- */
-class GeomAlgoAPI_Boolean : public GeomAPI_Interface
+/// \class GeomAlgoAPI_Boolean
+/// \ingroup DataAlgo
+/// \brief Allows to perform of boolean operations
+class GeomAlgoAPI_Boolean : public GeomAlgoAPI_MakeShape
 {
 public:
   /// Type of booelan operation
   enum OperationType{
-    BOOL_CUT, ///< Cut objects
-    BOOL_FUSE, ///< Fuse objects
+    BOOL_CUT,   ///< Cut objects
+    BOOL_FUSE,  ///< Fuse objects
     BOOL_COMMON ///< Take common part of objects
   };
 
@@ -37,33 +32,11 @@ public:
                                          const ListOfShape& theTools,
                                          const OperationType theOperationType);
 
-  /// \return true if algorithm succeed.
-  GEOMALGOAPI_EXPORT const bool isDone() const;
-
-  /// \return true if resulting shape is valid.
-  GEOMALGOAPI_EXPORT const bool isValid() const;
-
-  /// \return result of the boolean algorithm.
-  GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape() const;
-
-  /// \return map of sub-shapes of the result. To be used for History keeping.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfShapes() const;
-
-  /// \return interface for for History processing.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
-
 private:
   /// Builds resulting shape.
   void build(const ListOfShape& theObjects,
              const ListOfShape& theTools,
              const OperationType theOperationType);
-
-private:
-  /// Fields.
-  bool myDone;
-  std::shared_ptr<GeomAPI_Shape> myShape;
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
-  std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
 };
 
 #endif