Salome HOME
Fix coding style.
[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 //
7 // Modified by Clarisse Genrault (CEA) : 17 Mar 2016
8
9 #ifndef GeomAlgoAPI_MakeShape_H_
10 #define GeomAlgoAPI_MakeShape_H_
11
12 #include <GeomAlgoAPI.h>
13 #include <GeomAPI_DataMapOfShapeShape.h>
14
15 #include <list>
16 #include <memory>
17 #include <map>
18 #include <string>
19
20 /// \class GeomAlgoAPI_MakeShape
21 /// \ingroup DataAlgo
22 /// \brief Interface to the root class of all topological shapes constructions
23 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
24 {
25 public:
26   /// Builder type enum
27   enum BuilderType {
28     Unknown,
29     OCCT_BRepBuilderAPI_MakeShape,
30     OCCT_BOPAlgo_Builder
31   };
32
33 public:
34   /// \brief Empty constructor.
35   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
36
37   /// \brief Constructor by builder and builder type.
38   /// \param[in] theBuilder pointer to the builder.
39   /// \param[in] theBuilderType builder type.
40   template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder,
41     const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
42   : GeomAPI_Interface(theBuilder),
43     myBuilderType(theBuilderType)
44   {
45     initialize();
46   }
47
48   /// \brief Initializes internals.
49   /// \param[in] theBuilder pointer to the builder.
50   /// \param[in] theBuilderType builder type.
51   template<class T> void initialize(T* theBuilder,
52     const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
53   {
54     setImpl(theBuilder);
55     myBuilderType = theBuilderType;
56     initialize();
57   }
58
59   /// \return status of builder.
60   GEOMALGOAPI_EXPORT bool isDone() const;
61
62   /// \return a shape built by the shape construction algorithm.
63   GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
64
65   /// \return true if resulting shape is valid.
66   GEOMALGOAPI_EXPORT bool isValid() const;
67
68   /// \return true if resulting shape has volume.
69   GEOMALGOAPI_EXPORT bool hasVolume() const;
70
71   /// \return map of sub-shapes of the result. To be used for History keeping.
72   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
73
74   /// \return the list of shapes generated from the shape \a theShape.
75   /// \param[in] theShape base shape.
76   /// \param[out] theHistory generated shapes.
77   GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
78                                             ListOfShape& theHistory);
79
80   /// \return the list of shapes modified from the shape \a theShape.
81   /// \param[in] theShape base shape.
82   /// \param[out] theHistory modified shapes.
83   GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
84                                            ListOfShape& theHistory);
85
86   /// \return true if theShape was deleted.
87   /// \param[in] theShape base shape.
88   GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
89
90   /// \return true if the data were correct.
91   GEOMALGOAPI_EXPORT virtual bool check() { return true; };
92
93   ///  \return the list of created faces.
94   GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces()
95   {return myCreatedFaces;}
96
97   /// \return the error.
98   GEOMALGOAPI_EXPORT std::string getError() { return myError; }
99
100   /// \brief Prepare the naming of faces.
101   GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
102
103   /// \brief Check the validity of the produced shape.
104   GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
105
106 protected:
107   /// \brief Sets builder type.
108   /// \param[in] theBuilderType new builder type.
109   void setBuilderType(const BuilderType theBuilderType);
110
111   /// \brief Sets status of builder.
112   /// \param[in] theFlag new status.
113   void setDone(const bool theFlag);
114
115   /// \brief Sets result shape.
116   /// \param[in] theShape new shape.
117   void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
118
119 protected:
120    /// Data map to keep correct orientation of sub-shapes.
121   std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
122   /// Error occurred during the execution of an algorithm.
123   std::string myError;
124   /// Map of created faces with their name for naming.
125   std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces;
126
127 private:
128   /// \brief Initializes internals.
129   void initialize();
130
131 private:
132   GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
133   bool myDone; ///< Builder status.
134   std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
135 };
136
137 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;
138
139 #endif