SHAPER 9.16.0
GeomAlgoAPI_MakeShape.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef GeomAlgoAPI_MakeShape_H_
21#define GeomAlgoAPI_MakeShape_H_
22
23#include <GeomAlgoAPI.h>
24#include <GeomAPI_DataMapOfShapeShape.h>
25
26#include <list>
27#include <memory>
28#include <map>
29#include <string>
30
35{
36public:
39 Unknown,
40 OCCT_BRepBuilderAPI_MakeShape,
41 OCCT_BOPAlgo_Builder,
42 OCCT_BRepOffset_MakeOffset
43 };
44
45public:
47 GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
48
50 GEOMALGOAPI_EXPORT ~GeomAlgoAPI_MakeShape();
51
55 template<class T> explicit GeomAlgoAPI_MakeShape(
56 T* theBuilder,
57 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
58 : GeomAPI_Interface(theBuilder),
59 myBuilderType(theBuilderType)
60 {
61 initialize();
62 }
63
67 template<class T> void initialize(
68 T* theBuilder,
69 const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
70 {
71 setImpl(theBuilder);
72 myBuilderType = theBuilderType;
73 initialize();
74 }
75
77 GEOMALGOAPI_EXPORT virtual void build() {}
78
80 GEOMALGOAPI_EXPORT bool isDone() const;
81
83 GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const;
84
86 GEOMALGOAPI_EXPORT bool isValid() const;
87
89 GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
90
94 GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape,
95 ListOfShape& theNewShapes);
96
101 GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
102 ListOfShape& theNewShapes);
103
109 GEOMALGOAPI_EXPORT void modifiedCached(const GeomShapePtr theOldShape,
110 ListOfShape& theNewShapes);
111
114 GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theOldShape);
115
117 GEOMALGOAPI_EXPORT virtual bool check() { return true; };
118
120 GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
121
123 GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces() {
124 return myCreatedFaces;
125 }
126
128 GEOMALGOAPI_EXPORT std::string getError() { return myError; }
129
131 GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
132
137 GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld,
138 const int theShapeType);
139
144 GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld,
145 const int theShapeType);
146
150 GEOMALGOAPI_EXPORT void cleanNewShapes(GeomShapePtr theWholeOld,
151 const int theShapeType);
152
158 GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld,
159 GeomShapePtr theNewShape,
160 const int theShapeType);
161
163 GEOMALGOAPI_EXPORT void fixOrientation(GeomShapePtr& theShape);
164
165protected:
168 GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType);
169
172 GEOMALGOAPI_EXPORT void setDone(const bool theFlag);
173
176 GEOMALGOAPI_EXPORT void setShape(const GeomShapePtr theShape);
177
179 bool isValidForHistory(const GeomShapePtr theShape);
180
181protected:
183 std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
185 std::string myError;
187 std::map< std::string, GeomShapePtr > myCreatedFaces;
188
189private:
191 void initialize();
192
193private:
195 bool myDone;
196 GeomShapePtr myShape;
197
200 void* myHist;
201
204 void* myModifHist;
205};
206
207typedef std::shared_ptr<GeomAlgoAPI_MakeShape> GeomMakeShapePtr;
208typedef std::list<GeomMakeShapePtr> ListOfMakeShape;
209
210#endif
General base class for all interfaces in this package.
Definition: GeomAPI_Interface.h:38
void setImpl(T *theImpl)
Updates the impl (deletes the old one)
Definition: GeomAPI_Interface.h:71
Interface to the root class of all topological shapes constructions.
Definition: GeomAlgoAPI_MakeShape.h:35
virtual GEOMALGOAPI_EXPORT void generated(const GeomShapePtr theOldShape, ListOfShape &theNewShapes)
Definition: GeomAlgoAPI_MakeShape.cpp:96
GEOMALGOAPI_EXPORT void cleanNewShapes(GeomShapePtr theWholeOld, const int theShapeType)
Clean cached data, created by collectNewShapes() method, called with the same arguments.
Definition: GeomAlgoAPI_MakeShape.cpp:390
virtual GEOMALGOAPI_EXPORT const GeomShapePtr shape() const
Definition: GeomAlgoAPI_MakeShape.cpp:77
GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType)
Sets builder type.
Definition: GeomAlgoAPI_MakeShape.cpp:185
BuilderType
Builder type enum.
Definition: GeomAlgoAPI_MakeShape.h:38
GEOMALGOAPI_EXPORT std::shared_ptr< GeomAPI_DataMapOfShapeShape > mapOfSubShapes() const
Definition: GeomAlgoAPI_MakeShape.cpp:90
GEOMALGOAPI_EXPORT ~GeomAlgoAPI_MakeShape()
Destructor for remove myHist.
Definition: GeomAlgoAPI_MakeShape.cpp:60
bool isValidForHistory(const GeomShapePtr theShape)
Definition: GeomAlgoAPI_MakeShape.cpp:237
GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld, GeomShapePtr theNewShape, const int theShapeType)
Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
Definition: GeomAlgoAPI_MakeShape.cpp:428
std::string myError
Error occurred during the execution of an algorithm.
Definition: GeomAlgoAPI_MakeShape.h:185
GEOMALGOAPI_EXPORT void setShape(const GeomShapePtr theShape)
Sets result shape.
Definition: GeomAlgoAPI_MakeShape.cpp:197
GEOMALGOAPI_EXPORT void setDone(const bool theFlag)
Sets status of builder.
Definition: GeomAlgoAPI_MakeShape.cpp:191
std::map< std::string, GeomShapePtr > myCreatedFaces
Map of created faces with their name for naming.
Definition: GeomAlgoAPI_MakeShape.h:187
void initialize(T *theBuilder, const BuilderType theBuilderType=OCCT_BRepBuilderAPI_MakeShape)
Initializes internals.
Definition: GeomAlgoAPI_MakeShape.h:67
virtual GEOMALGOAPI_EXPORT bool check()
Definition: GeomAlgoAPI_MakeShape.h:117
virtual GEOMALGOAPI_EXPORT void build()
Execute the algorithm.
Definition: GeomAlgoAPI_MakeShape.h:77
GEOMALGOAPI_EXPORT bool isValid() const
Definition: GeomAlgoAPI_MakeShape.cpp:83
virtual GEOMALGOAPI_EXPORT void modified(const GeomShapePtr theOldShape, ListOfShape &theNewShapes)
Get a list of new shapes, modified from the given old shape.
Definition: GeomAlgoAPI_MakeShape.cpp:120
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape()
Empty constructor.
Definition: GeomAlgoAPI_MakeShape.cpp:51
GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld, const int theShapeType)
Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
Definition: GeomAlgoAPI_MakeShape.cpp:337
GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces()
Definition: GeomAlgoAPI_MakeShape.h:123
GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld, const int theShapeType)
Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
Definition: GeomAlgoAPI_MakeShape.cpp:348
GEOMALGOAPI_EXPORT std::string getError()
Definition: GeomAlgoAPI_MakeShape.h:128
virtual GEOMALGOAPI_EXPORT bool isDeleted(const GeomShapePtr theOldShape)
Definition: GeomAlgoAPI_MakeShape.cpp:167
std::shared_ptr< GeomAPI_DataMapOfShapeShape > myMap
Data map to keep correct orientation of sub-shapes.
Definition: GeomAlgoAPI_MakeShape.h:183
GEOMALGOAPI_EXPORT void modifiedCached(const GeomShapePtr theOldShape, ListOfShape &theNewShapes)
Get a list of new shapes, modified from the given old shape.
Definition: GeomAlgoAPI_MakeShape.cpp:150
GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage)
Check the validity of the produced shape.
Definition: GeomAlgoAPI_MakeShape.cpp:312
virtual GEOMALGOAPI_EXPORT void prepareNamingFaces()
Prepare the naming of faces.
Definition: GeomAlgoAPI_MakeShape.cpp:301
GeomAlgoAPI_MakeShape(T *theBuilder, const BuilderType theBuilderType=OCCT_BRepBuilderAPI_MakeShape)
Constructor by builder and builder type.
Definition: GeomAlgoAPI_MakeShape.h:55
GEOMALGOAPI_EXPORT bool isDone() const
Definition: GeomAlgoAPI_MakeShape.cpp:71
GEOMALGOAPI_EXPORT void fixOrientation(GeomShapePtr &theShape)
Replaces theShape with shape from myMap.
Definition: GeomAlgoAPI_MakeShape.cpp:253