Salome HOME
GeomAlgoAPI_Prism now derived from GeomAlgoAPI_MakeSweep
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_MakeShape.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_MakeShape.h
4 // Created:     17 Oct 2014
5 // Author:      Sergey ZARITCHNY
6 #ifndef GeomAlgoAPI_MakeShape_H_
7 #define GeomAlgoAPI_MakeShape_H_
8
9 #include <GeomAlgoAPI.h>
10 #include <GeomAPI_DataMapOfShapeShape.h>
11
12 #include <list>
13 #include <memory>
14
15 /// \class GeomAlgoAPI_MakeShape
16 /// \ingroup DataAlgo
17 /// \brief Interface to the root class of all topological shapes constructions
18 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
19 {
20 public:
21   /// Builder type enum
22   enum BuilderType {
23     OCCT_BRepBuilderAPI_MakeShape,
24     OCCT_BOPAlgo_Builder,
25     UNKNOWN
26   };
27
28 public:
29   /// \brief Empty constructor.
30   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
31
32   /// \brief Constructor by builder and builder type.
33   /// \param[in] theBuilder pointer to the builder.
34   /// \param[in] theBuilderType builder type.
35   template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
36   : GeomAPI_Interface(theBuilder),
37     myBuilderType(theBuilderType)
38   {
39     initialize();
40   }
41
42   /// \brief Initializes internals.
43   /// \param[in] theBuilder pointer to the builder.
44   /// \param[in] theBuilderType builder type.
45   template<class T> void initialize(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
46   {
47     setImpl(theBuilder);
48     myBuilderType = theBuilder;
49     initialize();
50   }
51
52   /// \return status of builder.
53   GEOMALGOAPI_EXPORT bool isDone() const;
54
55   /// \return a shape built by the shape construction algorithm.
56   GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
57
58   /// \return true if resulting shape is valid.
59   GEOMALGOAPI_EXPORT bool isValid() const;
60
61   /// \return true if resulting shape has volume.
62   GEOMALGOAPI_EXPORT bool hasVolume() const;
63
64   /// \return map of sub-shapes of the result. To be used for History keeping.
65   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
66
67   /// \return the list of shapes generated from the shape \a theShape.
68   /// \param[in] theShape base shape.
69   /// \param[out] theHistory generated shapes.
70   GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
71                                             ListOfShape& theHistory);
72
73   /// \return the list of shapes modified from the shape \a theShape.
74   /// \param[in] theShape base shape.
75   /// \param[out] theHistory modified shapes.
76   GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
77                                            ListOfShape& theHistory);
78
79   /// \return true if theShape was deleted.
80   /// \param[in] theShape base shape.
81   GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
82
83 protected:
84   /// \brief Sets builder type.
85   /// \param[in] theBuilderType new builder type.
86   void setBuilderType(const BuilderType theBuilderType);
87
88   /// \brief Sets status of builder.
89   /// \param[in] theFlag new status.
90   void setDone(const bool theFlag);
91
92   /// \brief Sets result shape.
93   /// \param[in] theShape new shape.
94   void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
95
96 private:
97   /// \brief Initializes internals.
98   void initialize();
99
100 private:
101   GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
102   bool myDone; ///< Builder status.
103   std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
104   std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap; ///< Data map to keep correct orientation of sub-shapes.
105 };
106
107 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;
108
109 #endif