1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #ifndef GeomAlgoAPI_MakeShape_H_
21 #define GeomAlgoAPI_MakeShape_H_
23 #include <GeomAlgoAPI.h>
24 #include <GeomAPI_DataMapOfShapeShape.h>
31 /// \class GeomAlgoAPI_MakeShape
33 /// \brief Interface to the root class of all topological shapes constructions
34 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
40 OCCT_BRepBuilderAPI_MakeShape,
45 /// \brief Empty constructor.
46 GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
48 /// \brief Constructor by builder and builder type.
49 /// \param[in] theBuilder pointer to the builder.
50 /// \param[in] theBuilderType builder type.
51 template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder,
52 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
53 : GeomAPI_Interface(theBuilder),
54 myBuilderType(theBuilderType)
59 /// \brief Initializes internals.
60 /// \param[in] theBuilder pointer to the builder.
61 /// \param[in] theBuilderType builder type.
62 template<class T> void initialize(T* theBuilder,
63 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
66 myBuilderType = theBuilderType;
70 /// \return status of builder.
71 GEOMALGOAPI_EXPORT bool isDone() const;
73 /// \return a shape built by the shape construction algorithm.
74 GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
76 /// \return true if resulting shape is valid.
77 GEOMALGOAPI_EXPORT bool isValid() const;
79 /// \return true if resulting shape has volume.
80 GEOMALGOAPI_EXPORT bool hasVolume() const;
82 /// \return map of sub-shapes of the result. To be used for History keeping.
83 GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
85 /// \return the list of shapes generated from the shape \a theShape.
86 /// \param[in] theShape base shape.
87 /// \param[out] theHistory generated shapes.
88 GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
89 ListOfShape& theHistory);
91 /// \return the list of shapes modified from the shape \a theShape.
92 /// \param[in] theShape base shape.
93 /// \param[out] theHistory modified shapes. Does not cleared!
94 GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
95 ListOfShape& theHistory);
97 /// \return true if theShape was deleted.
98 /// \param[in] theShape base shape.
99 GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
101 /// \return true if the data were correct.
102 GEOMALGOAPI_EXPORT virtual bool check() { return true; };
104 /// \return the list of created faces.
105 GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces()
106 {return myCreatedFaces;}
108 /// \return the error.
109 GEOMALGOAPI_EXPORT std::string getError() { return myError; }
111 /// \brief Prepare the naming of faces.
112 GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
114 /// \brief Check the validity of the produced shape.
115 GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
118 /// \brief Sets builder type.
119 /// \param[in] theBuilderType new builder type.
120 void setBuilderType(const BuilderType theBuilderType);
122 /// \brief Sets status of builder.
123 /// \param[in] theFlag new status.
124 void setDone(const bool theFlag);
126 /// \brief Sets result shape.
127 /// \param[in] theShape new shape.
128 void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
131 /// Data map to keep correct orientation of sub-shapes.
132 std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
133 /// Error occurred during the execution of an algorithm.
135 /// Map of created faces with their name for naming.
136 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces;
139 /// \brief Initializes internals.
143 GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
144 bool myDone; ///< Builder status.
145 std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
148 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;