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