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, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
41 : GeomAPI_Interface(theBuilder),
42 myBuilderType(theBuilderType)
47 /// \brief Initializes internals.
48 /// \param[in] theBuilder pointer to the builder.
49 /// \param[in] theBuilderType builder type.
50 template<class T> void initialize(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
53 myBuilderType = theBuilderType;
57 /// \return status of builder.
58 GEOMALGOAPI_EXPORT bool isDone() const;
60 /// \return a shape built by the shape construction algorithm.
61 GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
63 /// \return true if resulting shape is valid.
64 GEOMALGOAPI_EXPORT bool isValid() const;
66 /// \return true if resulting shape has volume.
67 GEOMALGOAPI_EXPORT bool hasVolume() const;
69 /// \return map of sub-shapes of the result. To be used for History keeping.
70 GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
72 /// \return the list of shapes generated from the shape \a theShape.
73 /// \param[in] theShape base shape.
74 /// \param[out] theHistory generated shapes.
75 GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
76 ListOfShape& theHistory);
78 /// \return the list of shapes modified from the shape \a theShape.
79 /// \param[in] theShape base shape.
80 /// \param[out] theHistory modified shapes.
81 GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
82 ListOfShape& theHistory);
84 /// \return true if theShape was deleted.
85 /// \param[in] theShape base shape.
86 GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
88 /// \return true if the data were correct.
89 GEOMALGOAPI_EXPORT virtual bool check() { return true; };
91 /// \return the list of created faces.
92 GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces() {return myCreatedFaces;}
94 /// \return the error.
95 GEOMALGOAPI_EXPORT std::string getError() { return myError; }
97 /// \brief Prepare the naming of faces.
98 GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
100 /// \brief Check the validity of the produced shape.
101 GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
104 /// \brief Sets builder type.
105 /// \param[in] theBuilderType new builder type.
106 void setBuilderType(const BuilderType theBuilderType);
108 /// \brief Sets status of builder.
109 /// \param[in] theFlag new status.
110 void setDone(const bool theFlag);
112 /// \brief Sets result shape.
113 /// \param[in] theShape new shape.
114 void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
117 std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap; ///< Data map to keep correct orientation of sub-shapes.
118 std::string myError; /// Error occurred during the execution of an algorithm.
119 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces; /// Map of created faces with their name for naming.
122 /// \brief Initializes internals.
126 GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
127 bool myDone; ///< Builder status.
128 std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
131 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;