SHAPER  9.12.0
GeomAPI_Shape.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 GeomAPI_Shape_H_
21 #define GeomAPI_Shape_H_
22 
23 #include "GeomAPI_Dir.h"
24 
25 #include <GeomAPI_Interface.h>
26 #include <memory>
27 #include <list>
28 
29 class GeomAPI_Pnt;
30 class GeomAPI_Vertex;
31 class GeomAPI_Edge;
32 class GeomAPI_Wire;
33 class GeomAPI_Face;
34 class GeomAPI_Shell;
35 class GeomAPI_Solid;
36 class GeomAPI_Trsf;
37 
43 {
44 public:
46  enum ShapeType {
47  COMPOUND, COMPSOLID, SOLID, SHELL,
48  FACE, WIRE, EDGE, VERTEX,
49  SHAPE
50  };
51 
53  enum Orientation {
54  FORWARD,
55  REVERSED,
56  INTERNAL,
57  EXTERNAL
58  };
59 
60  public:
62  GEOMAPI_EXPORT
63  GeomAPI_Shape();
64 
67  GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Shape> emptyCopied() const;
68 
70  GEOMAPI_EXPORT
71  bool isNull() const;
72 
74  GEOMAPI_EXPORT
75  virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const;
76 
78  GEOMAPI_EXPORT
79  virtual bool isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const;
80 
82  GEOMAPI_EXPORT
83  virtual bool isSameGeometry(const std::shared_ptr<GeomAPI_Shape> theShape) const;
84 
86  GEOMAPI_EXPORT
87  virtual bool isVertex() const;
88 
90  GEOMAPI_EXPORT
91  virtual bool isEdge() const;
92 
94  GEOMAPI_EXPORT
95  virtual bool isWire() const;
96 
98  GEOMAPI_EXPORT
99  virtual bool isFace() const;
100 
102  GEOMAPI_EXPORT
103  virtual bool isShell() const;
104 
106  GEOMAPI_EXPORT
107  virtual bool isCompound() const;
108 
110  GEOMAPI_EXPORT
111  virtual bool isCompoundOfSolids() const;
112 
115  GEOMAPI_EXPORT
116  virtual bool isCollectionOfSolids() const;
117 
119  GEOMAPI_EXPORT
120  virtual bool isConnectedTopology() const;
121 
123  GEOMAPI_EXPORT
124  virtual bool isSolid() const;
125 
127  GEOMAPI_EXPORT
128  virtual bool isCompSolid() const;
129 
131  GEOMAPI_EXPORT
132  virtual bool isPlanar() const;
133 
135  GEOMAPI_EXPORT
136  std::shared_ptr<GeomAPI_Vertex> vertex() const;
137 
139  GEOMAPI_EXPORT
140  std::shared_ptr<GeomAPI_Edge> edge() const;
141 
143  GEOMAPI_EXPORT
144  std::shared_ptr<GeomAPI_Wire> wire() const;
145 
147  GEOMAPI_EXPORT
148  std::shared_ptr<GeomAPI_Face> face() const;
149 
151  GEOMAPI_EXPORT
152  std::shared_ptr<GeomAPI_Shell> shell() const;
153 
155  GEOMAPI_EXPORT
156  std::shared_ptr<GeomAPI_Solid> solid() const;
157 
162  GEOMAPI_EXPORT
163  std::list< std::shared_ptr<GeomAPI_Shape> > subShapes(const ShapeType theSubShapeType,
164  const bool theOnlyUnique = false) const;
165 
167  GEOMAPI_EXPORT
168  virtual ShapeType shapeType() const;
169 
171  GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType);
172 
174  GEOMAPI_EXPORT
175  virtual std::string shapeTypeStr() const;
176 
178  GEOMAPI_EXPORT virtual Orientation orientation() const;
179 
181  GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation);
182 
184  GEOMAPI_EXPORT virtual void reverse();
185 
189  GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape,
190  const bool theCheckOrientation = true) const;
191 
194  GEOMAPI_EXPORT
195  bool computeSize(double& theXmin, double& theYmin, double& theZmin,
196  double& theXmax, double& theYmax, double& theZmax) const;
197 
199  GEOMAPI_EXPORT
200  virtual std::shared_ptr<GeomAPI_Pnt> middlePoint() const;
201 
203  GEOMAPI_EXPORT
204  std::string getShapeStream(const bool theWithTriangulation = true) const;
205 
207  GEOMAPI_EXPORT
208  std::shared_ptr<GeomAPI_Shape> intersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
209 
211  GEOMAPI_EXPORT
212  bool isIntersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
213 
215  GEOMAPI_EXPORT
216  void translate(const std::shared_ptr<GeomAPI_Dir> theDir, const double theOffset);
217 
219  GEOMAPI_EXPORT
220  void move(const std::shared_ptr<GeomAPI_Trsf> theTransformation);
221 
223  // If shapes are of different type then it will return SHAPE type
224  GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const;
225 
238  GEOMAPI_EXPORT bool isSelfIntersected(const int theLevelOfCheck = 9) const;
239 
240 public:
243  {
244  public:
246  GEOMAPI_EXPORT
247  bool operator ()(const std::shared_ptr<GeomAPI_Shape>& theShape1,
248  const std::shared_ptr<GeomAPI_Shape>& theShape2) const;
249  };
250 
254  {
255  public:
257  GEOMAPI_EXPORT
258  bool operator ()(const std::shared_ptr<GeomAPI_Shape>& theShape1,
259  const std::shared_ptr<GeomAPI_Shape>& theShape2) const;
260  };
261 
263  class Hash
264  {
265  public:
267  GEOMAPI_EXPORT
268  int operator ()(const std::shared_ptr<GeomAPI_Shape>& theShape) const;
269  };
270 
272  class Equal
273  {
274  public:
276  GEOMAPI_EXPORT
277  bool operator ()(const std::shared_ptr<GeomAPI_Shape>& theShape1,
278  const std::shared_ptr<GeomAPI_Shape>& theShape2) const;
279  };
280 };
281 
283 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
284 
286 typedef std::shared_ptr<GeomAPI_Shape> GeomShapePtr;
287 
288 #endif
Interface to the edge object.
Definition: GeomAPI_Edge.h:38
Interface to the face object.
Definition: GeomAPI_Face.h:36
General base class for all interfaces in this package.
Definition: GeomAPI_Interface.h:38
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
Compare addresses of shapes with respect to orientation of shapes.
Definition: GeomAPI_Shape.h:254
GEOMAPI_EXPORT bool operator()(const std::shared_ptr< GeomAPI_Shape > &theShape1, const std::shared_ptr< GeomAPI_Shape > &theShape2) const
Return true if the address of the first shape is less than the address of the second.
Definition: GeomAPI_Shape.cpp:820
Compare addresses of shapes.
Definition: GeomAPI_Shape.h:243
GEOMAPI_EXPORT bool operator()(const std::shared_ptr< GeomAPI_Shape > &theShape1, const std::shared_ptr< GeomAPI_Shape > &theShape2) const
Return true if the address of the first shape is less than the address of the second.
Definition: GeomAPI_Shape.cpp:806
Compare addresses of shapes.
Definition: GeomAPI_Shape.h:273
GEOMAPI_EXPORT bool operator()(const std::shared_ptr< GeomAPI_Shape > &theShape1, const std::shared_ptr< GeomAPI_Shape > &theShape2) const
Return true if the address of the shapes are equal.
Definition: GeomAPI_Shape.cpp:842
Hash code for the shape.
Definition: GeomAPI_Shape.h:264
GEOMAPI_EXPORT int operator()(const std::shared_ptr< GeomAPI_Shape > &theShape) const
Return Hash value according to the address of the shape.
Definition: GeomAPI_Shape.cpp:836
Interface to the topological shape object.
Definition: GeomAPI_Shape.h:43
virtual GEOMAPI_EXPORT bool isSubShape(const std::shared_ptr< GeomAPI_Shape > theShape, const bool theCheckOrientation=true) const
Definition: GeomAPI_Shape.cpp:627
virtual GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Pnt > middlePoint() const
Return middle point on the shape.
Definition: GeomAPI_Shape.cpp:675
static GEOMAPI_EXPORT ShapeType shapeTypeByStr(std::string theType)
Returns the type enumeration by the string-type.
Definition: GeomAPI_Shape.cpp:529
GEOMAPI_EXPORT bool isSelfIntersected(const int theLevelOfCheck=9) const
Returns true if shape have self-intersections.
Definition: GeomAPI_Shape.cpp:790
virtual GEOMAPI_EXPORT bool isSame(const std::shared_ptr< GeomAPI_Shape > theShape) const
Returns whether the shapes are same.
Definition: GeomAPI_Shape.cpp:96
ShapeType
Shape type enum.
Definition: GeomAPI_Shape.h:46
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Shape > emptyCopied() const
Definition: GeomAPI_Shape.cpp:72
GEOMAPI_EXPORT std::string getShapeStream(const bool theWithTriangulation=true) const
Returns the shape as BRep stream.
Definition: GeomAPI_Shape.cpp:711
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Face > face() const
Returns face or empty shape.
Definition: GeomAPI_Shape.cpp:415
virtual GEOMAPI_EXPORT bool isPlanar() const
Returns whether the shape is planar.
Definition: GeomAPI_Shape.cpp:293
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Solid > solid() const
Returns solid or empty shape.
Definition: GeomAPI_Shape.cpp:437
virtual GEOMAPI_EXPORT bool isEdge() const
Returns whether the shape is an edge.
Definition: GeomAPI_Shape.cpp:122
virtual GEOMAPI_EXPORT bool isConnectedTopology() const
Returns whether the shape is a compound where all elements are topologically connected.
Definition: GeomAPI_Shape.cpp:225
virtual GEOMAPI_EXPORT std::string shapeTypeStr() const
Definition: GeomAPI_Shape.cpp:552
virtual GEOMAPI_EXPORT ShapeType shapeType() const
Returns the shape type.
Definition: GeomAPI_Shape.cpp:488
GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const
Returns type of shapes in the compound.
Definition: GeomAPI_Shape.cpp:193
virtual GEOMAPI_EXPORT bool isCompoundOfSolids() const
Returns whether the shape is a compound of solids.
Definition: GeomAPI_Shape.cpp:178
virtual GEOMAPI_EXPORT bool isCompound() const
Returns whether the shape is a compound.
Definition: GeomAPI_Shape.cpp:146
GEOMAPI_EXPORT GeomAPI_Shape()
Creation of empty (null) shape.
Definition: GeomAPI_Shape.cpp:67
virtual GEOMAPI_EXPORT bool isWire() const
Returns whether the shape is a wire.
Definition: GeomAPI_Shape.cpp:128
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Shape > intersect(const std::shared_ptr< GeomAPI_Shape > theShape) const
Returns intersection of shapes.
Definition: GeomAPI_Shape.cpp:731
virtual GEOMAPI_EXPORT void setOrientation(const Orientation theOrientation)
Sets the shape orientation.
Definition: GeomAPI_Shape.cpp:612
virtual GEOMAPI_EXPORT bool isVertex() const
Returns whether the shape is a vertex.
Definition: GeomAPI_Shape.cpp:116
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Wire > wire() const
Returns wire or empty shape.
Definition: GeomAPI_Shape.cpp:404
GEOMAPI_EXPORT bool computeSize(double &theXmin, double &theYmin, double &theZmin, double &theXmax, double &theYmax, double &theZmax) const
Computes boundary dimensions of the shape Returns False if it is not possible.
Definition: GeomAPI_Shape.cpp:649
virtual GEOMAPI_EXPORT bool isSolid() const
Returns whether the shape is a solid.
Definition: GeomAPI_Shape.cpp:281
GEOMAPI_EXPORT void translate(const std::shared_ptr< GeomAPI_Dir > theDir, const double theOffset)
Translates the shape along the direction for the given offset.
Definition: GeomAPI_Shape.cpp:774
virtual GEOMAPI_EXPORT bool isShell() const
Returns whether the shape is a shell.
Definition: GeomAPI_Shape.cpp:140
GEOMAPI_EXPORT std::list< std::shared_ptr< GeomAPI_Shape > > subShapes(const ShapeType theSubShapeType, const bool theOnlyUnique=false) const
Returns list of sub-shapes of the given type.
Definition: GeomAPI_Shape.cpp:449
virtual GEOMAPI_EXPORT bool isFace() const
Returns whether the shape is a face.
Definition: GeomAPI_Shape.cpp:134
GEOMAPI_EXPORT bool isNull() const
Returns true if the underlied shape is null.
Definition: GeomAPI_Shape.cpp:79
virtual GEOMAPI_EXPORT bool isEqual(const std::shared_ptr< GeomAPI_Shape > theShape) const
Returns whether the shapes are equal.
Definition: GeomAPI_Shape.cpp:84
virtual GEOMAPI_EXPORT void reverse()
Reverse shape.
Definition: GeomAPI_Shape.cpp:622
virtual GEOMAPI_EXPORT bool isCompSolid() const
Returns whether the shape is a compsolid.
Definition: GeomAPI_Shape.cpp:287
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Edge > edge() const
Returns edge or empty shape.
Definition: GeomAPI_Shape.cpp:393
virtual GEOMAPI_EXPORT bool isCollectionOfSolids() const
Returns true, if the shape contains only solids, compsolids and compounds of solids and compsolids of...
Definition: GeomAPI_Shape.cpp:152
Orientation
Shape orientation.
Definition: GeomAPI_Shape.h:53
virtual GEOMAPI_EXPORT bool isSameGeometry(const std::shared_ptr< GeomAPI_Shape > theShape) const
Returns true if shapes have same underlying geometry.
Definition: GeomAPI_Shape.cpp:107
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Vertex > vertex() const
Returns vertex or empty shape.
Definition: GeomAPI_Shape.cpp:382
GEOMAPI_EXPORT std::shared_ptr< GeomAPI_Shell > shell() const
Returns shell or empty shape.
Definition: GeomAPI_Shape.cpp:426
GEOMAPI_EXPORT bool isIntersect(const std::shared_ptr< GeomAPI_Shape > theShape) const
Returns true if min distance between shapes < tolerance.
Definition: GeomAPI_Shape.cpp:756
GEOMAPI_EXPORT void move(const std::shared_ptr< GeomAPI_Trsf > theTransformation)
Moves the shape with the given transformation matrix.
Definition: GeomAPI_Shape.cpp:784
virtual GEOMAPI_EXPORT Orientation orientation() const
Definition: GeomAPI_Shape.cpp:599
Interface to the shell object.
Definition: GeomAPI_Shell.h:35
Interface to the solid object.
Definition: GeomAPI_Solid.h:35
Keep the transformation matrix coefficients.
Definition: GeomAPI_Trsf.h:36
Interface to the vertex object.
Definition: GeomAPI_Vertex.h:31
Interface to the wire object.
Definition: GeomAPI_Wire.h:31