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>
19 /// \class GeomAlgoAPI_MakeShape
21 /// \brief Interface to the root class of all topological shapes constructions
22 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
28 OCCT_BRepBuilderAPI_MakeShape,
33 /// \brief Empty constructor.
34 GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
36 /// \brief Constructor by builder and builder type.
37 /// \param[in] theBuilder pointer to the builder.
38 /// \param[in] theBuilderType builder type.
39 template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
40 : GeomAPI_Interface(theBuilder),
41 myBuilderType(theBuilderType)
46 /// \brief Initializes internals.
47 /// \param[in] theBuilder pointer to the builder.
48 /// \param[in] theBuilderType builder type.
49 template<class T> void initialize(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
52 myBuilderType = theBuilderType;
56 /// \return status of builder.
57 GEOMALGOAPI_EXPORT bool isDone() const;
59 /// \return a shape built by the shape construction algorithm.
60 GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
62 /// \return true if resulting shape is valid.
63 GEOMALGOAPI_EXPORT bool isValid() const;
65 /// \return true if resulting shape has volume.
66 GEOMALGOAPI_EXPORT bool hasVolume() const;
68 /// \return map of sub-shapes of the result. To be used for History keeping.
69 GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
71 /// \return the list of shapes generated from the shape \a theShape.
72 /// \param[in] theShape base shape.
73 /// \param[out] theHistory generated shapes.
74 GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
75 ListOfShape& theHistory);
77 /// \return the list of shapes modified from the shape \a theShape.
78 /// \param[in] theShape base shape.
79 /// \param[out] theHistory modified shapes.
80 GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
81 ListOfShape& theHistory);
83 /// \return true if theShape was deleted.
84 /// \param[in] theShape base shape.
85 GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
87 /// \return true if the data were correct.
88 GEOMALGOAPI_EXPORT virtual bool check() { return true; };
90 /// \return the list of created faces.
91 GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces() {return myCreatedFaces;}
93 /// \return the error.
94 GEOMALGOAPI_EXPORT std::string getError() { return myError; }
96 /// \brief Prepare the naming of faces.
97 GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
99 /// \brief Check the validity of the produced shape.
100 GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
103 /// \brief Sets builder type.
104 /// \param[in] theBuilderType new builder type.
105 void setBuilderType(const BuilderType theBuilderType);
107 /// \brief Sets status of builder.
108 /// \param[in] theFlag new status.
109 void setDone(const bool theFlag);
111 /// \brief Sets result shape.
112 /// \param[in] theShape new shape.
113 void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
116 std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap; ///< Data map to keep correct orientation of sub-shapes.
117 std::string myError; /// Error occurred during the execution of an algorithm.
118 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces; /// Map of created faces with their name for naming.
121 /// \brief Initializes internals.
125 GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
126 bool myDone; ///< Builder status.
127 std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
130 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;