1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_MakeShape.h
4 // Created: 17 Oct 2014
5 // Author: Sergey ZARITCHNY
7 // Modified by Clarisse Genrault (CEA) : 17 Mar 2016
9 #ifndef GeomAlgoAPI_MakeShape_H_
10 #define GeomAlgoAPI_MakeShape_H_
12 #include <GeomAlgoAPI.h>
13 #include <GeomAPI_DataMapOfShapeShape.h>
20 /// \class GeomAlgoAPI_MakeShape
22 /// \brief Interface to the root class of all topological shapes constructions
23 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
29 OCCT_BRepBuilderAPI_MakeShape,
34 /// \brief Empty constructor.
35 GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
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)
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)
55 myBuilderType = theBuilderType;
59 /// \return status of builder.
60 GEOMALGOAPI_EXPORT bool isDone() const;
62 /// \return a shape built by the shape construction algorithm.
63 GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
65 /// \return true if resulting shape is valid.
66 GEOMALGOAPI_EXPORT bool isValid() const;
68 /// \return true if resulting shape has volume.
69 GEOMALGOAPI_EXPORT bool hasVolume() const;
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;
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);
80 /// \return the list of shapes modified from the shape \a theShape.
81 /// \param[in] theShape base shape.
82 /// \param[out] theHistory modified shapes. Does not cleared!
83 GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
84 ListOfShape& theHistory);
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);
90 /// \return true if the data were correct.
91 GEOMALGOAPI_EXPORT virtual bool check() { return true; };
93 /// \return the list of created faces.
94 GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces()
95 {return myCreatedFaces;}
97 /// \return the error.
98 GEOMALGOAPI_EXPORT std::string getError() { return myError; }
100 /// \brief Prepare the naming of faces.
101 GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
103 /// \brief Check the validity of the produced shape.
104 GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
107 /// \brief Sets builder type.
108 /// \param[in] theBuilderType new builder type.
109 void setBuilderType(const BuilderType theBuilderType);
111 /// \brief Sets status of builder.
112 /// \param[in] theFlag new status.
113 void setDone(const bool theFlag);
115 /// \brief Sets result shape.
116 /// \param[in] theShape new shape.
117 void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
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.
124 /// Map of created faces with their name for naming.
125 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces;
128 /// \brief Initializes internals.
132 GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
133 bool myDone; ///< Builder status.
134 std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
137 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;