Salome HOME
GeomAlgoAPI_Prism now derived from GeomAlgoAPI_MakeSweep
authordbv <dbv@opencascade.com>
Tue, 22 Dec 2015 13:14:50 +0000 (16:14 +0300)
committerdbv <dbv@opencascade.com>
Thu, 24 Dec 2015 07:57:25 +0000 (10:57 +0300)
13 files changed:
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_ExtrusionSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeSweep.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeSweep.h
src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Prism.h

index 9ab80ccfe545f2bc959017efead61a5a284e6093..6a9e9392910deaa12c63215ad17528248acb242a 100644 (file)
@@ -10,7 +10,6 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Session.h>
@@ -199,7 +198,7 @@ void FeaturesPlugin_Boolean::execute()
         }
 
         GeomAlgoAPI_MakeShapeList aMakeShapeList;
-        aMakeShapeList.append(aBoolAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aBoolAlgo.makeShape());
         GeomAPI_DataMapOfShapeShape aMapOfShapes;
         aMapOfShapes.merge(aBoolAlgo.mapOfShapes());
 
@@ -213,7 +212,7 @@ void FeaturesPlugin_Boolean::execute()
           return;
         }
 
-        aMakeShapeList.append(aFillerAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
         aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
 
         if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo.shape()) > 1.e-7) {
@@ -275,7 +274,7 @@ void FeaturesPlugin_Boolean::execute()
 
           if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo.shape()) > 1.e-7) {
             aSolidsToFuse.push_back(aCutAlgo.shape());
-            aMakeShapeList.append(aCutAlgo.makeShape());
+            aMakeShapeList.appendAlgo(aCutAlgo.makeShape());
             aMapOfShapes.merge(aCutAlgo.mapOfShapes());
           }
         }
@@ -307,7 +306,7 @@ void FeaturesPlugin_Boolean::execute()
       }
 
       std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo.shape();
-      aMakeShapeList.append(aFuseAlgo.makeShape());
+      aMakeShapeList.appendAlgo(aFuseAlgo.makeShape());
       aMapOfShapes.merge(aFuseAlgo.mapOfShapes());
 
       // Add result to not used solids from compsolid (if we have any).
@@ -331,7 +330,7 @@ void FeaturesPlugin_Boolean::execute()
         }
 
         aShape = aFillerAlgo.shape();
-        aMakeShapeList.append(aFillerAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
         aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
       }
 
index c51ac16b5ddcee205c620920ca1ea4b3db3fdf03..02e977af90e13c09822ae5d6ebbec6910c44fe6d 100644 (file)
@@ -4,11 +4,10 @@
 // Created:     11 June 2015
 // Author:      Dmitry Bobylev
 
-#include <FeaturesPlugin_CompositeBoolean.h>
+#include "FeaturesPlugin_CompositeBoolean.h"
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeReference.h>
-#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Session.h>
@@ -239,7 +238,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
         }
 
         GeomAlgoAPI_MakeShapeList aMakeShapeList;
-        aMakeShapeList.append(aBoolAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aBoolAlgo.makeShape());
         GeomAPI_DataMapOfShapeShape aMapOfShapes;
         aMapOfShapes.merge(aBoolAlgo.mapOfShapes());
 
@@ -253,7 +252,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
           return;
         }
 
-        aMakeShapeList.append(aFillerAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
         aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
 
         if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo.shape()) > 1.e-7) {
@@ -309,7 +308,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
 
           if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo.shape()) > 1.e-7) {
             aSolidsToFuse.push_back(aCutAlgo.shape());
-            aMakeShapeList.append(aCutAlgo.makeShape());
+            aMakeShapeList.appendAlgo(aCutAlgo.makeShape());
             aMapOfShapes.merge(aCutAlgo.mapOfShapes());
           }
         }
@@ -331,7 +330,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
       }
 
       std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo.shape();
-      aMakeShapeList.append(aFuseAlgo.makeShape());
+      aMakeShapeList.appendAlgo(aFuseAlgo.makeShape());
       aMapOfShapes.merge(aFuseAlgo.mapOfShapes());
 
       // Add result to not used solids from compsolid (if we have any).
@@ -355,7 +354,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
         }
 
         aShape = aFillerAlgo.shape();
-        aMakeShapeList.append(aFillerAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
         aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
       }
 
@@ -413,8 +412,8 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
       //Insert lateral face : Face from Edge
       if(std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter)) {
         std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter);
-        aSubShapes = aPrismAlgo->mapOfShapes();
-        theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aShellsIter, GeomAPI_Shape::EDGE, aGenTag,
+        aSubShapes = aPrismAlgo->mapOfSubShapes();
+        theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo.get(), *aShellsIter, GeomAPI_Shape::EDGE, aGenTag,
                                                     aLatName, *aSubShapes.get());
 
         aFromFaces = aPrismAlgo->fromFaces();
index 3f7ed7efdc9ed42fd3ad344ac2c9090ec4db461e..c0bcd77f3bcb125d4f58cb8c534c9212ccd66084 100644 (file)
@@ -4,22 +4,16 @@
 // Created:     30 May 2014
 // Author:      Vitaly SMETANNIKOV
 
-#include <FeaturesPlugin_Extrusion.h>
+#include "FeaturesPlugin_Extrusion.h"
 
-#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeString.h>
-#include <ModelAPI_AttributeReference.h>
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_Prism.h>
@@ -171,12 +165,12 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo,
   //load result
   theResultBody->storeGenerated(theBasis, thePrismAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = thePrismAlgo.mapOfShapes();
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = thePrismAlgo.mapOfSubShapes();
 
   //Insert lateral face : Face from Edge
   const std::string aLatName = "LateralFace";
   const int aLatTag = 1;
-  theResultBody->loadAndOrientGeneratedShapes(thePrismAlgo.makeShape().get(), theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
+  theResultBody->loadAndOrientGeneratedShapes(&thePrismAlgo, theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
 
   //Insert to faces
   const std::string aToName = "ToFace";
index 682ea60ac214877e7cbfeb8beca0fbdafcd49329..94fb46a4c4aa19852895a7ef6f6e7f43c1c38c8a 100644 (file)
@@ -79,17 +79,17 @@ void FeaturesPlugin_ExtrusionSketch::makeSolid(const std::shared_ptr<GeomAPI_Sha
   }
 
   // Extrude face
-  GeomAlgoAPI_Prism aPrismAlgo(theFace, aToShape, aToSize, aFromShape, aFromSize);
+  std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo(new GeomAlgoAPI_Prism(theFace, aToShape, aToSize, aFromShape, aFromSize));
 
   // Checking that the algorithm worked properly.
-  if(!aPrismAlgo.isDone() || !aPrismAlgo.shape().get() || aPrismAlgo.shape()->isNull() ||
-     !aPrismAlgo.isValid()) {
+  if(!aPrismAlgo->isDone() || !aPrismAlgo->shape().get() || aPrismAlgo->shape()->isNull() ||
+     !aPrismAlgo->isValid()) {
     return;
   }
 
-  theResult = aPrismAlgo.shape();
-  theFromFaces = aPrismAlgo.fromFaces();
-  theToFaces = aPrismAlgo.toFaces();
-  theMakeShape = aPrismAlgo.makeShape();
-  theDataMap = aPrismAlgo.mapOfShapes();
+  theResult = aPrismAlgo->shape();
+  theFromFaces = aPrismAlgo->fromFaces();
+  theToFaces = aPrismAlgo->toFaces();
+  theMakeShape = aPrismAlgo;
+  theDataMap = aPrismAlgo->mapOfSubShapes();
 }
index 52ee4eaf6eea70b37dc346435991711d50236f3e..94b7f4bcebaedc02a626d62dc782a610b804e61e 100755 (executable)
@@ -93,7 +93,7 @@ void FeaturesPlugin_Partition::execute()
         aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aContext->shape(), aBoundingPoints);
         std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(new GeomAlgoAPI_MakeShapeCustom);
         aMkShCustom->addModified(aContext->shape(), aTool);
-        aMakeShapeList.append(aMkShCustom);
+        aMakeShapeList.appendAlgo(aMkShCustom);
         aTools.push_back(aTool);
         aToolsForNaming.push_back(aContext->shape());
       }
@@ -143,7 +143,7 @@ void FeaturesPlugin_Partition::execute()
 
     if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) {
       std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-      aMakeShapeList.append(aPartitionAlgo.makeShape());
+      aMakeShapeList.appendAlgo(aPartitionAlgo.makeShape());
       GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get();
       loadNamingDS(aResultBody, anObjects.front(), aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes);
       setResult(aResultBody, aResultIndex);
@@ -175,7 +175,7 @@ void FeaturesPlugin_Partition::execute()
 
       if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) {
         std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-        aMakeShapeList.append(aPartitionAlgo.makeShape());
+        aMakeShapeList.appendAlgo(aPartitionAlgo.makeShape());
         GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get();
         loadNamingDS(aResultBody, anObject, aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes);
         setResult(aResultBody, aResultIndex);
index 3b0d3ca8b2462b5b33812439740a31d5be284cf9..5419c4f151465f565c3eaec968608ef3600ac674 100644 (file)
@@ -4,18 +4,21 @@
 // Created:     20 Oct 2014
 // Author:      Sergey ZARITCHNY
 
-#include <GeomAlgoAPI_MakeShape.h>
+#include "GeomAlgoAPI_MakeShape.h"
 
 #include <BOPAlgo_Builder.hxx>
 #include <BRepBuilderAPI_MakeShape.hxx>
-#include <BRepOffsetAPI_MakePipe.hxx>
+#include <BRepCheck_Analyzer.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <Precision.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 
 //=================================================================================================
 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
-: myBuilderType(OCCT_BRepBuilderAPI_MakeShape),
+: myBuilderType(UNKNOWN),
   myDone(false)
 {
 }
@@ -32,6 +35,33 @@ const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
   return myShape;
 }
 
+//=================================================================================================
+bool GeomAlgoAPI_MakeShape::isValid() const
+{
+  BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
+  return (aChecker.IsValid() == Standard_True);
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_MakeShape::hasVolume() const
+{
+  bool hasVolume = false;
+  if(isValid()) {
+    const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
+    GProp_GProps aGProp;
+    BRepGProp::VolumeProperties(aRShape, aGProp);
+    if(aGProp.Mass() > Precision::Confusion())
+      hasVolume = true;
+  }
+  return hasVolume;
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_MakeShape::mapOfSubShapes() const
+{
+  return myMap;
+}
+
 //=================================================================================================
 void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
                                       ListOfShape& theHistory)
@@ -106,7 +136,31 @@ void GeomAlgoAPI_MakeShape::setDone(const bool theFlag)
 //=================================================================================================
 void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theShape)
 {
+  if(myShape.get() && myShape->isEqual(theShape)) {
+    return;
+  }
+
   myShape = theShape;
+
+  // Filling data map to keep correct orientation of sub-shapes.
+  if(myShape.get()) {
+    if(myMap.get()) {
+      myMap->clear();
+    } else {
+      myMap.reset(new GeomAPI_DataMapOfShapeShape);
+    }
+
+    const TopoDS_Shape& aTopoDSSHape = myShape->impl<TopoDS_Shape>();
+    for(TopExp_Explorer anExp(aTopoDSSHape,TopAbs_FACE); anExp.More(); anExp.Next()) {
+      std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+      aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+      myMap->bind(aCurrentShape, aCurrentShape);
+    }
+  } else {
+    if(myMap.get()) {
+      myMap->clear();
+    }
+  }
 }
 
 //=================================================================================================
index 272f9f9750f468786ba35f961d0bec8060713a32..acbc9c84fbf5247c7820ee6dad889bf833986089 100644 (file)
 #include <list>
 #include <memory>
 
-/** \class GeomAlgoAPI_MakeShape
- *  \ingroup DataAlgo
- *  \brief Interface to the root class of all topological shapes constructions
- */
+/// \class GeomAlgoAPI_MakeShape
+/// \ingroup DataAlgo
+/// \brief Interface to the root class of all topological shapes constructions
 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
 {
 public:
   /// Builder type enum
   enum BuilderType {
     OCCT_BRepBuilderAPI_MakeShape,
-    OCCT_BOPAlgo_Builder
+    OCCT_BOPAlgo_Builder,
+    UNKNOWN
   };
 
 public:
   /// \brief Empty constructor.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
 
-  /** \brief Constructor by builder and builder type.
-   *  \param[in] theBuilder pointer to the builder.
-   *  \param[in] theBuilderType builder type.
-   */
+  /// \brief Constructor by builder and builder type.
+  /// \param[in] theBuilder pointer to the builder.
+  /// \param[in] theBuilderType builder type.
   template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
   : GeomAPI_Interface(theBuilder),
     myBuilderType(theBuilderType)
@@ -40,10 +39,9 @@ public:
     initialize();
   }
 
-  /** \brief Initializes internals.
-   *  \param[in] theBuilder pointer to the builder.
-   *  \param[in] theBuilderType builder type.
-   */
+  /// \brief Initializes internals.
+  /// \param[in] theBuilder pointer to the builder.
+  /// \param[in] theBuilderType builder type.
   template<class T> void initialize(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
   {
     setImpl(theBuilder);
@@ -57,40 +55,43 @@ public:
   /// \return a shape built by the shape construction algorithm.
   GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
 
-  /** \return the list of shapes generated from the shape \a theShape.
-   *  \param[in] theShape base shape.
-   *  \param[out] theHistory generated shapes.
-   */
+  /// \return true if resulting shape is valid.
+  GEOMALGOAPI_EXPORT bool isValid() const;
+
+  /// \return true if resulting shape has volume.
+  GEOMALGOAPI_EXPORT bool hasVolume() const;
+
+  /// \return map of sub-shapes of the result. To be used for History keeping.
+  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
+
+  /// \return the list of shapes generated from the shape \a theShape.
+  /// \param[in] theShape base shape.
+  /// \param[out] theHistory generated shapes.
   GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
                                             ListOfShape& theHistory);
 
-  /** \return the list of shapes modified from the shape \a theShape.
-   *  \param[in] theShape base shape.
-   *  \param[out] theHistory modified shapes.
-   */
+  /// \return the list of shapes modified from the shape \a theShape.
+  /// \param[in] theShape base shape.
+  /// \param[out] theHistory modified shapes.
   GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
                                            ListOfShape& theHistory);
 
-  /** \return true if theShape was deleted.
-   *  \param[in] theShape base shape.
-   */
+  /// \return true if theShape was deleted.
+  /// \param[in] theShape base shape.
   GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
 
 protected:
-  /** \brief Sets builder type.
-   *  \param[in] theBuilderType new builder type.
-   */
-  GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType);
-
-  /** \brief Sets status of builder.
-   *  \param[in] theFlag new status.
-   */
-  GEOMALGOAPI_EXPORT void setDone(const bool theFlag);
-
-  /** \brief Sets result shape.
-   *  \param[in] theShape new shape.
-   */
-  GEOMALGOAPI_EXPORT void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
+  /// \brief Sets builder type.
+  /// \param[in] theBuilderType new builder type.
+  void setBuilderType(const BuilderType theBuilderType);
+
+  /// \brief Sets status of builder.
+  /// \param[in] theFlag new status.
+  void setDone(const bool theFlag);
+
+  /// \brief Sets result shape.
+  /// \param[in] theShape new shape.
+  void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
 
 private:
   /// \brief Initializes internals.
index cdcc4596dadc8b541ea65f98bedd3f9d896e1a81..1442c5b324204398f776174c4e77fb6a022258a2 100644 (file)
@@ -4,12 +4,10 @@
 // Created:     27 May 2015
 // Author:      Dmitry Bobylev
 
-#include <GeomAlgoAPI_MakeShapeList.h>
+#include "GeomAlgoAPI_MakeShapeList.h"
 
-#include <BRepBuilderAPI_MakeShape.hxx>
 #include <NCollection_Map.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Shape.hxx>
 
 //=================================================================================================
 GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList()
@@ -30,28 +28,21 @@ void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList)
 }
 
 //=================================================================================================
-void GeomAlgoAPI_MakeShapeList::append(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+void GeomAlgoAPI_MakeShapeList::appendAlgo(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
 {
   myListOfMakeShape.push_back(theMakeShape);
 }
 
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeList::append(const GeomAlgoAPI_MakeShapeList& theMakeShapeList)
-{
-  for(ListOfMakeShape::const_iterator anIt = theMakeShapeList.myListOfMakeShape.cbegin();
-    anIt != theMakeShapeList.myListOfMakeShape.cend(); anIt++) {
-    myListOfMakeShape.push_back(*anIt);
-  }
-}
-
 //=================================================================================================
 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShapeList::shape() const
 {
-  if(myListOfMakeShape.empty()) {
-    return std::shared_ptr<GeomAPI_Shape>();
-  } else {
+  std::shared_ptr<GeomAPI_Shape> aShape = GeomAlgoAPI_MakeShape::shape();
+  if(aShape.get() && !aShape->impl<TopoDS_Shape>().IsNull()) {
+    return aShape;
+  } else if(!myListOfMakeShape.empty()) {
     return myListOfMakeShape.back()->shape();
   }
+  return std::shared_ptr<GeomAPI_Shape>();
 }
 
 //=================================================================================================
index 64dfa760b8dcf0e64d80ffb4dbb34d56f4d7f68f..179e0d1832f52d54ba3465cb3f544c07d5f26350 100644 (file)
 
 #include <memory>
 
-/** \class GeomAlgoAPI_MakeShapeList
- *  \ingroup DataAlgo
- *  \brief List of topological shapes constructions
- */
+/// \class GeomAlgoAPI_MakeShapeList
+/// \ingroup DataAlgo
+/// \brief List of topological shapes constructions
 class GeomAlgoAPI_MakeShapeList : public GeomAlgoAPI_MakeShape
 {
   enum OperationType {
@@ -27,25 +26,17 @@ public:
   /// Default constructor
   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeList();
 
-  /** \brief Constructor
-   *  \param[in] theMakeShapeList list of algorithms.
-   */
+  /// \brief Constructor
+  /// \param[in] theMakeShapeList list of algorithms.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeList(const ListOfMakeShape& theMakeShapeList);
 
-  /** \brief Initializes a class with new list of algorithms.
-   *  \param[in] theMakeShapeList list of algorithms.
-   */
+  /// \brief Initializes a class with new list of algorithms.
+  /// \param[in] theMakeShapeList list of algorithms.
   GEOMALGOAPI_EXPORT void init(const ListOfMakeShape& theMakeShapeList);
 
-  /** \brief Adds algo to the end of list.
-   *  \param[in] theMakeShape algo to be added.
-   */
-  GEOMALGOAPI_EXPORT void append(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
-
-  /** \brief Adds another one list of algos to the end of list.
-   *  \param[in] theMakeShapeList algo list to be added.
-   */
-  GEOMALGOAPI_EXPORT void append(const GeomAlgoAPI_MakeShapeList& theMakeShapeList);
+  /// \brief Adds algo to the end of list.
+  /// \param[in] theMakeShape algo to be added.
+  GEOMALGOAPI_EXPORT void appendAlgo(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
 
   /// \return a shape built by the shape construction algorithms
   GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
index 0cb97621f73e2353d505695c8023af045d5deca6..701a99d145504caa3dd302bfdcf298a925479b38 100644 (file)
@@ -4,7 +4,7 @@
 // Created:     23 November 2015
 // Author:      Dmitry Bobylev
 
-#include <GeomAlgoAPI_MakeSweep.h>
+#include "GeomAlgoAPI_MakeSweep.h"
 
 //=================================================================================================
 const ListOfShape& GeomAlgoAPI_MakeSweep::fromFaces() const
@@ -17,3 +17,27 @@ const ListOfShape& GeomAlgoAPI_MakeSweep::toFaces() const
 {
   return myToFaces;
 }
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::addFromFace(const std::shared_ptr<GeomAPI_Shape> theFace)
+{
+  myFromFaces.push_back(theFace);
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::setFromFaces(const ListOfShape& theListOfFaces)
+{
+  myFromFaces = theListOfFaces;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::addToFace(const std::shared_ptr<GeomAPI_Shape> theFace)
+{
+  myToFaces.push_back(theFace);
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::setToFaces(const ListOfShape& theListOfFaces)
+{
+  myToFaces = theListOfFaces;
+}
index fee768599be12c4c3ca64f3006f580432b4ddef2..d9c5f4ec2a24820c29d752742c8e2577e0473734 100644 (file)
@@ -27,13 +27,30 @@ class GeomAlgoAPI_MakeSweep : public GeomAlgoAPI_MakeShapeList
 {
 public:
   /// \returns the list of from faces.
-  GEOMALGOAPI_EXPORT const ListOfShape& fromFaces() const;
+  GEOMALGOAPI_EXPORT virtual const ListOfShape& fromFaces() const;
 
   /// \return the list of to faces.
-  GEOMALGOAPI_EXPORT const ListOfShape& toFaces() const;
+  GEOMALGOAPI_EXPORT virtual const ListOfShape& toFaces() const;
 
 protected:
-  GeomAlgoAPI_MakeSweep(){};
+  /// Empty constructor.
+  GeomAlgoAPI_MakeSweep() : GeomAlgoAPI_MakeShapeList() {};
+
+  /// \brief Adds a face to list of from faces.
+  /// \param[in] theFace a face to add.
+  void addFromFace(const std::shared_ptr<GeomAPI_Shape> theFace);
+
+  /// \brief Sets from faces
+  /// \param[in] theListOfFaces list of from faces.
+  void setFromFaces(const ListOfShape& theListOfFaces);
+
+  /// \brief Adds a face to list of to faces.
+  /// \param[in] theFace a face to add.
+  void addToFace(const std::shared_ptr<GeomAPI_Shape> theFace);
+
+  /// \brief Sets to faces
+  /// \param[in] theListOfFaces list of to faces.
+  void setToFaces(const ListOfShape& theListOfFaces);
 
 private:
   ListOfShape myFromFaces;
index 04f6ef2a8cbbf6591e507763eebcd59e80c5a32e..2e8b00ca7f51be556d1bffbf0541ef8134ebc391 100644 (file)
@@ -4,7 +4,7 @@
 // Created:     5 May 2015
 // Author:      Dmitry Bobylev
 
-#include <GeomAlgoAPI_Prism.h>
+#include "GeomAlgoAPI_Prism.h"
 
 #include <GeomAPI_Face.h>
 #include <GeomAPI_Pln.h>
@@ -13,7 +13,6 @@
 #include <GeomAPI_XYZ.h>
 #include <GeomAlgoAPI_DFLoader.h>
 #include <GeomAlgoAPI_FaceBuilder.h>
-#include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
 #include <Bnd_Box.hxx>
 #include <BRepAlgoAPI_Cut.hxx>
 #include <BRepBndLib.hxx>
 #include <BRepBuilderAPI_Transform.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <BRepExtrema_ExtCF.hxx>
-#include <BRepGProp.hxx>
 #include <BRepPrimAPI_MakePrism.hxx>
 #include <gp_Pln.hxx>
-#include <GProp_GProps.hxx>
 #include <IntAna_IntConicQuad.hxx>
 #include <IntAna_Quadric.hxx>
 #include <TopExp_Explorer.hxx>
@@ -38,7 +33,6 @@
 GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
                                      double                         theToSize,
                                      double                         theFromSize)
-: myDone(false)
 {
   build(theBaseShape, std::shared_ptr<GeomAPI_Shape>(), theToSize, std::shared_ptr<GeomAPI_Shape>(), theFromSize);
 }
@@ -49,7 +43,6 @@ GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape
                                      double                         theToSize,
                                      std::shared_ptr<GeomAPI_Shape> theFromShape,
                                      double                         theFromSize)
-: myDone(false)
 {
   build(theBaseShape, theToShape, theToSize, theFromShape, theFromSize);
 }
@@ -92,7 +85,6 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
   const gp_Pnt& aBasePnt = aBaseLoc->impl<gp_Pnt>();
 
   TopoDS_Shape aResult;
-  ListOfMakeShape aListOfMakeShape;
   bool isBoundingShapesSet = theFromShape || theToShape;
   if(!isBoundingShapesSet) {
     // Moving base shape.
@@ -102,7 +94,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     if(!aTransformBuilder) {
       return;
     }
-    aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
+    this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
     if(!aTransformBuilder->IsDone()) {
       return;
     }
@@ -113,7 +105,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     if(!aPrismBuilder) {
       return;
     }
-    aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
+    this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
     if(!aPrismBuilder->IsDone()) {
       return;
     }
@@ -125,8 +117,8 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
       std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
       aFromShape->setImpl(new TopoDS_Shape(aPrismBuilder->FirstShape(aFace)));
       aToShape->setImpl(new TopoDS_Shape(aPrismBuilder->LastShape(aFace)));
-      myFromFaces.push_back(aFromShape);
-      myToFaces.push_back(aToShape);
+      this->addFromFace(aFromShape);
+      this->addToFace(aToShape);
     }
   } else {
     std::shared_ptr<GeomAPI_Shape> aBoundingFromShape = theFromShape ? theFromShape : aBasePlane;
@@ -201,7 +193,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     if(!aTransformBuilder) {
       return;
     }
-    aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
+    this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
     if(!aTransformBuilder->IsDone()) {
       return;
     }
@@ -212,7 +204,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     if(!aPrismBuilder) {
       return;
     }
-    aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
+    this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
     if(!aPrismBuilder->IsDone()) {
       return;
     }
@@ -271,12 +263,12 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     if(!aToCutBuilder->IsDone()) {
       return;
     }
-    aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
+    this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
     const TopTools_ListOfShape& aToShapes = aToCutBuilder->Modified(aToShape);
     for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) {
       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
       aShape->setImpl(new TopoDS_Shape(anIt.Value()));
-      myToFaces.push_back(aShape);
+      this->addToFace(aShape);
     }
     aResult = aToCutBuilder->Shape();
 
@@ -286,12 +278,12 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     if(!aFromCutBuilder->IsDone()) {
       return;
     }
-    aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
+    this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
     const TopTools_ListOfShape& aFromShapes = aFromCutBuilder->Modified(aFromShape);
     for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) {
       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
       aShape->setImpl(new TopoDS_Shape(anIt.Value()));
-      myFromFaces.push_back(aShape);
+      this->addFromFace(aShape);
     }
     aResult = aFromCutBuilder->Shape();
 
@@ -328,76 +320,8 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
   if(aResult.IsNull()) {
     return;
   }
-  myShape.reset(new GeomAPI_Shape);
-  myShape->setImpl(new TopoDS_Shape(aResult));
-
-  // Filling 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);
-  }
-
-  // Setting list of make shape.
-  myMkShape.reset(new GeomAlgoAPI_MakeShapeList(aListOfMakeShape));
-
-  myDone = true;
-}
-
-//=================================================================================================
-bool GeomAlgoAPI_Prism::isDone() const
-{
-  return myDone;
-}
-
-//=================================================================================================
-bool GeomAlgoAPI_Prism::isValid() const
-{
-  BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
-  return (aChecker.IsValid() == Standard_True);
-}
-
-//=================================================================================================
-bool GeomAlgoAPI_Prism::hasVolume() const
-{
-  bool hasVolume(false);
-  if(isValid()) {
-    const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
-    GProp_GProps aGProp;
-    BRepGProp::VolumeProperties(aRShape, aGProp);
-    if(aGProp.Mass() > Precision::Confusion())
-      hasVolume = true;
-  }
-  return hasVolume;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Prism::shape() const
-{
-  return myShape;
-}
-
-//=================================================================================================
-const ListOfShape& GeomAlgoAPI_Prism::fromFaces() const
-{
-  return myFromFaces;
-}
-
-//=================================================================================================
-const ListOfShape& GeomAlgoAPI_Prism::toFaces() const
-{
-  return myToFaces;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Prism::mapOfShapes() const
-{
-  return myMap;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Prism::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 e7c18fcb9af367051b048777238a8cb2b5ca03d4..f286e6970ebcedbfc9f66d9af11289748a1db3ea 100644 (file)
@@ -9,65 +9,38 @@
 
 #include <GeomAlgoAPI.h>
 #include <GeomAPI_Shape.h>
-#include <GeomAlgoAPI_MakeShape.h>
-#include <GeomAPI_DataMapOfShapeShape.h>
+#include <GeomAlgoAPI_MakeSweep.h>
+
 #include <memory>
 
-/** \class GeomAlgoAPI_Prism
- *  \ingroup DataAlgo
- *  \brief Allows to create the prism based on a given face and bounding planes.
- *  \n Note that only planar faces are allowed as bounding faces and resulting
- *  extrusion will be bounded by the infinite planes taken from the faces.
- */
-class GeomAlgoAPI_Prism : public GeomAPI_Interface
+/// \class GeomAlgoAPI_Prism
+/// \ingroup DataAlgo
+/// \brief Allows to create the prism based on a given face and bounding planes.
+/// \n Note that only planar faces are allowed as bounding faces and resulting
+/// extrusion will be bounded by the infinite planes taken from the faces.
+class GeomAlgoAPI_Prism : public GeomAlgoAPI_MakeSweep
 {
 public:
-  /** \brief Creates extrusion for the given shape along the normal for this shape.
-   *  \param[in] theBaseShape face or wire to be extruded.
-   *  \param[in] theToSize offset for "to" plane.
-   *  \param[in] theFromSize offset for "from" plane.
-   */
+  /// \brief Creates extrusion for the given shape along the normal for this shape.
+  /// \param[in] theBaseShape face or wire to be extruded.
+  /// \param[in] theToSize offset for "to" plane.
+  /// \param[in] theFromSize offset for "from" plane.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
                                        double                         theToSize,
                                        double                         theFromSize);
 
-  /** \brief Creates extrusion for the given shape along the normal for this shape.
-   *  \param[in] theBaseShape face or wire to be extruded.
-   *  \param[in] theToShape top bounding shape.  Can be empty. In this case offset will be applied to the basis.
-   *  \param[in] theToSize offset for "to" plane.
-   *  \param[in] theFromShape bottom bounding shape. Can be empty. In this case offset will be applied to the basis.
-   *  \param[in] theFromSize offset for "from" plane.
-   */
+  /// \brief Creates extrusion for the given shape along the normal for this shape.
+  /// \param[in] theBaseShape face or wire to be extruded.
+  /// \param[in] theToShape top bounding shape.  Can be empty. In this case offset will be applied to the basis.
+  /// \param[in] theToSize offset for "to" plane.
+  /// \param[in] theFromShape bottom bounding shape. Can be empty. In this case offset will be applied to the basis.
+  /// \param[in] theFromSize offset for "from" plane.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
                                        std::shared_ptr<GeomAPI_Shape> theToShape,
                                        double                         theToSize,
                                        std::shared_ptr<GeomAPI_Shape> theFromShape,
                                        double                         theFromSize);
 
-  /// \return true if algorithm succeed.
-  GEOMALGOAPI_EXPORT bool isDone() const;
-
-  /// \return true if resulting shape is valid.
-  GEOMALGOAPI_EXPORT bool isValid() const;
-
-  /// \return true if resulting shape has volume.
-  GEOMALGOAPI_EXPORT bool hasVolume() const;
-
-  /// \return result of the Prism algorithm.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape() const;
-
-  /// \returns the list of from faces.
-  GEOMALGOAPI_EXPORT const ListOfShape& fromFaces() const;
-
-  /// \return the list of to faces.
-  GEOMALGOAPI_EXPORT const ListOfShape& toFaces() 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 History processing.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
-
 private:
   /// Builds resulting shape.
   void build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
@@ -75,15 +48,6 @@ private:
              double                                theToSize,
              const std::shared_ptr<GeomAPI_Shape>& theFromShape,
              double                                theFromSize);
-
-private:
-  /// Fields.
-  bool myDone;
-  std::shared_ptr<GeomAPI_Shape> myShape;
-  ListOfShape myFromFaces;
-  ListOfShape myToFaces;
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
-  std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
 };
 
 #endif