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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef GeomAlgoAPI_MakeShape_H_
22 #define GeomAlgoAPI_MakeShape_H_
24 #include <GeomAlgoAPI.h>
25 #include <GeomAPI_DataMapOfShapeShape.h>
32 /// \class GeomAlgoAPI_MakeShape
34 /// \brief Interface to the root class of all topological shapes constructions
35 class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
41 OCCT_BRepBuilderAPI_MakeShape,
46 /// \brief Empty constructor.
47 GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
49 /// \brief Constructor by builder and builder type.
50 /// \param[in] theBuilder pointer to the builder.
51 /// \param[in] theBuilderType builder type.
52 template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder,
53 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
54 : GeomAPI_Interface(theBuilder),
55 myBuilderType(theBuilderType)
60 /// \brief Initializes internals.
61 /// \param[in] theBuilder pointer to the builder.
62 /// \param[in] theBuilderType builder type.
63 template<class T> void initialize(T* theBuilder,
64 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
67 myBuilderType = theBuilderType;
71 /// \return status of builder.
72 GEOMALGOAPI_EXPORT bool isDone() const;
74 /// \return a shape built by the shape construction algorithm.
75 GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
77 /// \return true if resulting shape is valid.
78 GEOMALGOAPI_EXPORT bool isValid() const;
80 /// \return true if resulting shape has volume.
81 GEOMALGOAPI_EXPORT bool hasVolume() const;
83 /// \return map of sub-shapes of the result. To be used for History keeping.
84 GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
86 /// \return the list of shapes generated from the shape \a theShape.
87 /// \param[in] theShape base shape.
88 /// \param[out] theHistory generated shapes.
89 GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
90 ListOfShape& theHistory);
92 /// \return the list of shapes modified from the shape \a theShape.
93 /// \param[in] theShape base shape.
94 /// \param[out] theHistory modified shapes. Does not cleared!
95 GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
96 ListOfShape& theHistory);
98 /// \return true if theShape was deleted.
99 /// \param[in] theShape base shape.
100 GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
102 /// \return true if the data were correct.
103 GEOMALGOAPI_EXPORT virtual bool check() { return true; };
105 /// \return the list of created faces.
106 GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces()
107 {return myCreatedFaces;}
109 /// \return the error.
110 GEOMALGOAPI_EXPORT std::string getError() { return myError; }
112 /// \brief Prepare the naming of faces.
113 GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
115 /// \brief Check the validity of the produced shape.
116 GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
119 /// \brief Sets builder type.
120 /// \param[in] theBuilderType new builder type.
121 void setBuilderType(const BuilderType theBuilderType);
123 /// \brief Sets status of builder.
124 /// \param[in] theFlag new status.
125 void setDone(const bool theFlag);
127 /// \brief Sets result shape.
128 /// \param[in] theShape new shape.
129 void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
132 /// Data map to keep correct orientation of sub-shapes.
133 std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
134 /// Error occurred during the execution of an algorithm.
136 /// Map of created faces with their name for naming.
137 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces;
140 /// \brief Initializes internals.
144 GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
145 bool myDone; ///< Builder status.
146 std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
149 typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;