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 /// Destructor for remove myHist
50 GEOMALGOAPI_EXPORT ~GeomAlgoAPI_MakeShape();
52 /// \brief Constructor by builder and builder type.
53 /// \param[in] theBuilder pointer to the builder.
54 /// \param[in] theBuilderType builder type.
55 template<class T> explicit GeomAlgoAPI_MakeShape(
57 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
58 : GeomAPI_Interface(theBuilder),
59 myBuilderType(theBuilderType)
64 /// \brief Initializes internals.
65 /// \param[in] theBuilder pointer to the builder.
66 /// \param[in] theBuilderType builder type.
67 template<class T> void initialize(
69 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
72 myBuilderType = theBuilderType;
76 /// \return status of builder.
77 GEOMALGOAPI_EXPORT bool isDone() const;
79 /// \return a shape built by the shape construction algorithm.
80 GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const;
82 /// \return true if resulting shape is valid.
83 GEOMALGOAPI_EXPORT bool isValid() const;
85 /// \return true if resulting shape has volume.
86 GEOMALGOAPI_EXPORT bool hasVolume() const;
88 /// \return map of sub-shapes of the result. To be used for History keeping.
89 GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
91 /// \return the list of shapes generated from the shape \a theShape.
92 /// \param[in] theOldShape base shape.
93 /// \param[out] theNewShapes shapes generated from \a theShape. Does not cleared!
94 GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape,
95 ListOfShape& theNewShapes);
97 /// \return the list of shapes modified from the shape \a theShape.
98 /// \param[in] theOldShape base shape.
99 /// \param[out] theNewShapes shapes modified from \a theShape. Does not cleared!
100 GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
101 ListOfShape& theNewShapes);
103 /// \return true if theShape was deleted.
104 /// \param[in] theOldShape base shape.
105 GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theOldShape);
107 /// \return true if the data were correct.
108 GEOMALGOAPI_EXPORT virtual bool check() { return true; };
110 /// \brief Prepare the naming of faces.
111 GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
113 /// \return the list of created faces.
114 GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces() {
115 return myCreatedFaces;
118 /// \return the error.
119 GEOMALGOAPI_EXPORT std::string getError() { return myError; }
121 /// \brief Check the validity of the produced shape.
122 GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
124 /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
125 /// \param theWholeOld the whole old shape
126 /// \param theShapeType type of the sub-shapes that is used for optimization
127 /// \returns true if optimization containers are already filled
128 GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld,
129 const int theShapeType);
131 /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
132 /// \param theWholeOld the whole old shape
133 /// \param theShapeType type of the sub-shapes that is used for optimization
134 /// \returns true if optimization containers are already filled
135 GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld,
136 const int theShapeType);
138 /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
139 /// \param theWholeOld the whole old shape
140 /// \param theNewShape the whole new shape
141 /// \param theShapeType type of the old sub-shapes
142 /// \returns compound of all old shapes that were used for creation of the given new
143 GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld,
144 GeomShapePtr theNewShape,
145 const int theShapeType);
147 /// Replaces \a theShape with shape from \a myMap.
148 GEOMALGOAPI_EXPORT void fixOrientation(GeomShapePtr& theShape);
151 /// \brief Sets builder type.
152 /// \param[in] theBuilderType new builder type.
153 void setBuilderType(const BuilderType theBuilderType);
155 /// \brief Sets status of builder.
156 /// \param[in] theFlag new status.
157 void setDone(const bool theFlag);
159 /// \brief Sets result shape.
160 /// \param[in] theShape new shape.
161 void setShape(const GeomShapePtr theShape);
163 /// \return true if passed shape is valid for history.
164 bool isValidForHistory(const GeomShapePtr theShape);
167 /// Data map to keep correct orientation of sub-shapes.
168 std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
169 /// Error occurred during the execution of an algorithm.
171 /// Map of created faces with their name for naming.
172 std::map< std::string, GeomShapePtr > myCreatedFaces;
175 /// \brief Initializes internals.
179 GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
180 bool myDone; ///< Builder status.
181 GeomShapePtr myShape; ///< Resulting shape.
183 /// map that is used to keep the optimization structure for access to the history
184 /// kind of sub-shapes -> whole old shape -> new shape -> list of old shapes that create this new
188 typedef std::shared_ptr<GeomAlgoAPI_MakeShape> GeomMakeShapePtr;
189 typedef std::list<GeomMakeShapePtr> ListOfMakeShape;