Salome HOME
Copyright update 2021
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Prism.h
index 642ff9b305f064acd07f01a3cf67724506a1ca2a..b46a34402c66a218f235e592e3c9bb1a02114040 100644 (file)
@@ -1,89 +1,86 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        GeomAlgoAPI_Prism.h
-// Created:     5 May 2015
-// Author:      Dmitry Bobylev
+// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #ifndef GeomAlgoAPI_Prism_H_
 #define GeomAlgoAPI_Prism_H_
 
-#include <GeomAlgoAPI.h>
+#include "GeomAlgoAPI_MakeSweep.h"
+
 #include <GeomAPI_Shape.h>
-#include <GeomAlgoAPI_MakeShape.h>
-#include <GeomAPI_DataMapOfShapeShape.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 GeomAPI_Dir;
+class GeomAPI_Pln;
+
+/// \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] theBasis face or wire to be extruded.
-   *  \param[in] theFromSize offset for "from" plane.
-   *  \param[in] theToSize offset for "to" plane.
-   */
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBasis,
-                                       double                         theFromSize,
-                                       double                         theToSize);
-
-  /** \brief Creates extrusion for the given shape along the normal for this shape.
-   *  \param[in] theBasis face or wire to be extruded.
-   *  \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.
-   *  \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.
-   */
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBasis,
-                                       std::shared_ptr<GeomAPI_Shape> theFromShape,
-                                       double                         theFromSize,
-                                       std::shared_ptr<GeomAPI_Shape> theToShape,
-                                       double                         theToSize);
-
-  /// \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 first shape.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> firstShape() const;
-
-  /// \return the last shape.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> lastShape() 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>& theBasis,
-             const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-             double                                theFromSize,
-             const std::shared_ptr<GeomAPI_Shape>& theToShape,
-             double                                theToSize);
+  /// \brief Creates extrusion for the given shape along the normal for this shape.
+  /// \param[in] theBaseShape planar face or wire to be extruded.
+  /// \param[in] theDirection direction of extrusion.
+  ///                         Can be empty if theBaseShape is planar wire or face.
+  /// \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(const GeomShapePtr                 theBaseShape,
+                                       const std::shared_ptr<GeomAPI_Dir> theDirection,
+                                       const GeomShapePtr                 theToShape,
+                                       const double                       theToSize,
+                                       const GeomShapePtr                 theFromShape,
+                                       const double                       theFromSize);
 
 private:
-  /// Fields.
-  bool myDone;
-  std::shared_ptr<GeomAPI_Shape> myShape;
-  std::shared_ptr<GeomAPI_Shape> myFirst;
-  std::shared_ptr<GeomAPI_Shape> myLast;
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
-  std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
+  /// Build extrusion by distances from the base shape.
+  void buildBySizes(const GeomShapePtr                 theBaseShape,
+                    const std::shared_ptr<GeomAPI_Dir> theDirection,
+                    const double                       theToSize,
+                    const double                       theFromSize,
+                    const GeomAPI_Shape::ShapeType     theTypeToExp);
+
+  /// Build extrusion from plane to plane.
+  void buildByPlanes(const GeomShapePtr                 theBaseShape,
+                     const std::shared_ptr<GeomAPI_Dir> theDirection,
+                     const std::shared_ptr<GeomAPI_Pln> theToPlane,
+                     const double                       theToSize,
+                     const std::shared_ptr<GeomAPI_Pln> theFromPlane,
+                     const double                       theFromSize,
+                     const GeomAPI_Shape::ShapeType     theTypeToExp);
+
+  /// Build extrusion from face to face.
+  void buildByFaces(const GeomShapePtr                 theBaseShape,
+                    const std::shared_ptr<GeomAPI_Dir> theDirection,
+                    const GeomShapePtr                 theToShape,
+                    const double                       theToSize,
+                    const bool                         theToIsPlanar,
+                    const GeomShapePtr                 theFromShape,
+                    const double                       theFromSize,
+                    const bool                         theFromIsPlanar,
+                    const GeomAPI_Shape::ShapeType     theTypeToExp);
 };
 
 #endif