Salome HOME
272f9f9750f468786ba35f961d0bec8060713a32
[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  */
19 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
20 {
21 public:
22   /// Builder type enum
23   enum BuilderType {
24     OCCT_BRepBuilderAPI_MakeShape,
25     OCCT_BOPAlgo_Builder
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    */
36   template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
37   : GeomAPI_Interface(theBuilder),
38     myBuilderType(theBuilderType)
39   {
40     initialize();
41   }
42
43   /** \brief Initializes internals.
44    *  \param[in] theBuilder pointer to the builder.
45    *  \param[in] theBuilderType builder type.
46    */
47   template<class T> void initialize(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
48   {
49     setImpl(theBuilder);
50     myBuilderType = theBuilder;
51     initialize();
52   }
53
54   /// \return status of builder.
55   GEOMALGOAPI_EXPORT bool isDone() const;
56
57   /// \return a shape built by the shape construction algorithm.
58   GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
59
60   /** \return the list of shapes generated from the shape \a theShape.
61    *  \param[in] theShape base shape.
62    *  \param[out] theHistory generated shapes.
63    */
64   GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
65                                             ListOfShape& theHistory);
66
67   /** \return the list of shapes modified from the shape \a theShape.
68    *  \param[in] theShape base shape.
69    *  \param[out] theHistory modified shapes.
70    */
71   GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
72                                            ListOfShape& theHistory);
73
74   /** \return true if theShape was deleted.
75    *  \param[in] theShape base shape.
76    */
77   GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
78
79 protected:
80   /** \brief Sets builder type.
81    *  \param[in] theBuilderType new builder type.
82    */
83   GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType);
84
85   /** \brief Sets status of builder.
86    *  \param[in] theFlag new status.
87    */
88   GEOMALGOAPI_EXPORT void setDone(const bool theFlag);
89
90   /** \brief Sets result shape.
91    *  \param[in] theShape new shape.
92    */
93   GEOMALGOAPI_EXPORT void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
94
95 private:
96   /// \brief Initializes internals.
97   void initialize();
98
99 private:
100   GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
101   bool myDone; ///< Builder status.
102   std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
103   std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap; ///< Data map to keep correct orientation of sub-shapes.
104 };
105
106 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;
107
108 #endif