SHAPER  9.12.0
GeomAlgoAPI_MakeShape.h
1 // Copyright (C) 2014-2023 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 {
36 public:
38  enum BuilderType {
39  Unknown,
40  OCCT_BRepBuilderAPI_MakeShape,
41  OCCT_BOPAlgo_Builder
42  };
43 
44 public:
46  GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
47 
49  GEOMALGOAPI_EXPORT ~GeomAlgoAPI_MakeShape();
50 
54  template<class T> explicit GeomAlgoAPI_MakeShape(
55  T* theBuilder,
56  const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
57  : GeomAPI_Interface(theBuilder),
58  myBuilderType(theBuilderType)
59  {
60  initialize();
61  }
62 
66  template<class T> void initialize(
67  T* theBuilder,
68  const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
69  {
70  setImpl(theBuilder);
71  myBuilderType = theBuilderType;
72  initialize();
73  }
74 
76  GEOMALGOAPI_EXPORT virtual void build() {}
77 
79  GEOMALGOAPI_EXPORT bool isDone() const;
80 
82  GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const;
83 
85  GEOMALGOAPI_EXPORT bool isValid() const;
86 
88  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
89 
93  GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape,
94  ListOfShape& theNewShapes);
95 
99  GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
100  ListOfShape& theNewShapes);
101 
104  GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theOldShape);
105 
107  GEOMALGOAPI_EXPORT virtual bool check() { return true; };
108 
110  GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
111 
113  GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces() {
114  return myCreatedFaces;
115  }
116 
118  GEOMALGOAPI_EXPORT std::string getError() { return myError; }
119 
121  GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
122 
127  GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld,
128  const int theShapeType);
129 
134  GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld,
135  const int theShapeType);
136 
142  GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld,
143  GeomShapePtr theNewShape,
144  const int theShapeType);
145 
147  GEOMALGOAPI_EXPORT void fixOrientation(GeomShapePtr& theShape);
148 
149 protected:
152  GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType);
153 
156  GEOMALGOAPI_EXPORT void setDone(const bool theFlag);
157 
160  GEOMALGOAPI_EXPORT void setShape(const GeomShapePtr theShape);
161 
163  bool isValidForHistory(const GeomShapePtr theShape);
164 
165 protected:
167  std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
169  std::string myError;
171  std::map< std::string, GeomShapePtr > myCreatedFaces;
172 
173 private:
175  void initialize();
176 
177 private:
178  GeomAlgoAPI_MakeShape::BuilderType myBuilderType;
179  bool myDone;
180  GeomShapePtr myShape;
181 
184  void* myHist;
185 };
186 
187 typedef std::shared_ptr<GeomAlgoAPI_MakeShape> GeomMakeShapePtr;
188 typedef std::list<GeomMakeShapePtr> ListOfMakeShape;
189 
190 #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:88
virtual GEOMALGOAPI_EXPORT const GeomShapePtr shape() const
Definition: GeomAlgoAPI_MakeShape.cpp:69
GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType)
Sets builder type.
Definition: GeomAlgoAPI_MakeShape.cpp:148
BuilderType
Builder type enum.
Definition: GeomAlgoAPI_MakeShape.h:38
GEOMALGOAPI_EXPORT std::shared_ptr< GeomAPI_DataMapOfShapeShape > mapOfSubShapes() const
Definition: GeomAlgoAPI_MakeShape.cpp:82
GEOMALGOAPI_EXPORT ~GeomAlgoAPI_MakeShape()
Destructor for remove myHist.
Definition: GeomAlgoAPI_MakeShape.cpp:55
bool isValidForHistory(const GeomShapePtr theShape)
Definition: GeomAlgoAPI_MakeShape.cpp:200
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:355
std::string myError
Error occurred during the execution of an algorithm.
Definition: GeomAlgoAPI_MakeShape.h:169
GEOMALGOAPI_EXPORT void setShape(const GeomShapePtr theShape)
Sets result shape.
Definition: GeomAlgoAPI_MakeShape.cpp:160
GEOMALGOAPI_EXPORT void setDone(const bool theFlag)
Sets status of builder.
Definition: GeomAlgoAPI_MakeShape.cpp:154
std::map< std::string, GeomShapePtr > myCreatedFaces
Map of created faces with their name for naming.
Definition: GeomAlgoAPI_MakeShape.h:171
void initialize(T *theBuilder, const BuilderType theBuilderType=OCCT_BRepBuilderAPI_MakeShape)
Initializes internals.
Definition: GeomAlgoAPI_MakeShape.h:66
virtual GEOMALGOAPI_EXPORT bool check()
Definition: GeomAlgoAPI_MakeShape.h:107
virtual GEOMALGOAPI_EXPORT void build()
Execute the algorithm.
Definition: GeomAlgoAPI_MakeShape.h:76
GEOMALGOAPI_EXPORT bool isValid() const
Definition: GeomAlgoAPI_MakeShape.cpp:75
virtual GEOMALGOAPI_EXPORT void modified(const GeomShapePtr theOldShape, ListOfShape &theNewShapes)
Definition: GeomAlgoAPI_MakeShape.cpp:109
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape()
Empty constructor.
Definition: GeomAlgoAPI_MakeShape.cpp:47
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:293
GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces()
Definition: GeomAlgoAPI_MakeShape.h:113
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:304
GEOMALGOAPI_EXPORT std::string getError()
Definition: GeomAlgoAPI_MakeShape.h:118
virtual GEOMALGOAPI_EXPORT bool isDeleted(const GeomShapePtr theOldShape)
Definition: GeomAlgoAPI_MakeShape.cpp:133
std::shared_ptr< GeomAPI_DataMapOfShapeShape > myMap
Data map to keep correct orientation of sub-shapes.
Definition: GeomAlgoAPI_MakeShape.h:167
GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage)
Check the validity of the produced shape.
Definition: GeomAlgoAPI_MakeShape.cpp:268
virtual GEOMALGOAPI_EXPORT void prepareNamingFaces()
Prepare the naming of faces.
Definition: GeomAlgoAPI_MakeShape.cpp:257
GeomAlgoAPI_MakeShape(T *theBuilder, const BuilderType theBuilderType=OCCT_BRepBuilderAPI_MakeShape)
Constructor by builder and builder type.
Definition: GeomAlgoAPI_MakeShape.h:54
GEOMALGOAPI_EXPORT bool isDone() const
Definition: GeomAlgoAPI_MakeShape.cpp:63
GEOMALGOAPI_EXPORT void fixOrientation(GeomShapePtr &theShape)
Replaces theShape with shape from myMap.
Definition: GeomAlgoAPI_MakeShape.cpp:216