Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / GeomAPI / GeomAPI_Shape.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef GeomAPI_Shape_H_
22 #define GeomAPI_Shape_H_
23
24 #include <GeomAPI_Interface.h>
25 #include <memory>
26 #include <list>
27
28 /**\class GeomAPI_Shape
29  * \ingroup DataModel
30  * \brief Interface to the topological shape object
31  */
32 class GeomAPI_Shape : public GeomAPI_Interface
33 {
34 public:
35   /// Shape type enum
36   enum ShapeType {
37     COMPOUND, COMPSOLID, SOLID, SHELL,
38     FACE, WIRE, EDGE, VERTEX,
39     SHAPE
40   };
41
42   /// Shape orientation
43   enum Orientation {
44     FORWARD,
45     REVERSED,
46     INTERNAL,
47     EXTERNAL
48   };
49
50  public:
51   /// Creation of empty (null) shape
52   GEOMAPI_EXPORT
53   GeomAPI_Shape();
54
55   /// \return a new Shape with the same Orientation and Location and a new TShape with the same
56   ///         geometry and no sub-shapes.
57   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Shape> emptyCopied() const;
58
59   /// Returns true if the underlied shape is null
60   GEOMAPI_EXPORT
61   bool isNull() const;
62
63   /// Returns whether the shapes are equal
64   GEOMAPI_EXPORT
65   virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const;
66
67   /// Returns whether the shapes are same
68   GEOMAPI_EXPORT
69   virtual bool isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const;
70
71   /// Returns whether the shape is a vertex
72   GEOMAPI_EXPORT
73   virtual bool isVertex() const;
74
75   /// Returns whether the shape is an edge
76   GEOMAPI_EXPORT
77   virtual bool isEdge() const;
78
79   /// Returns whether the shape is a face
80   GEOMAPI_EXPORT
81   virtual bool isFace() const;
82
83   /// Returns whether the shape is a compound
84   GEOMAPI_EXPORT
85   virtual bool isCompound() const;
86
87   /// Returns whether the shape is a compound of solids
88   GEOMAPI_EXPORT
89   virtual bool isCompoundOfSolids() const;
90
91   /// Returns whether the shape is a compound where all elements are topologically connected
92   GEOMAPI_EXPORT
93   virtual bool isConnectedTopology() const;
94
95   /// Returns whether the shape is a solid
96   GEOMAPI_EXPORT
97   virtual bool isSolid() const;
98
99   /// Returns whether the shape is a compsolid
100   GEOMAPI_EXPORT
101   virtual bool isCompSolid() const;
102
103   /// Returns whether the shape is planar
104   GEOMAPI_EXPORT
105   virtual bool isPlanar() const;
106
107   /// Returns the shape type
108   GEOMAPI_EXPORT
109   virtual ShapeType shapeType() const;
110
111   /// Returns the type enumeration by the string-type
112   GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType);
113
114   /// \return the shape type as string.
115   GEOMAPI_EXPORT
116   virtual std::string shapeTypeStr() const;
117
118   /// \return the shape orientation.
119   GEOMAPI_EXPORT virtual Orientation orientation() const;
120
121   /// Sets the shape orientation.
122   GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation);
123
124   /// \return true if passed shape is a sub-shape of this shape.
125   /// \param theShape shape to search.
126   GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape) const;
127
128   /// Computes boundary dimensions of the shape
129   /// Returns False if it is not possible
130   GEOMAPI_EXPORT
131   bool computeSize(double& theXmin, double& theYmin, double& theZmin,
132                    double& theXmax, double& theYmax, double& theZmax) const;
133
134   /// Returns the shape as BRep stream
135   GEOMAPI_EXPORT
136   std::string getShapeStream() const;
137
138   /// Returns intersection of shapes
139   GEOMAPI_EXPORT
140   std::shared_ptr<GeomAPI_Shape> intersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
141
142   /// Returns true if min distance between shapes < tolerance.
143   GEOMAPI_EXPORT
144   bool isIntersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
145 };
146
147 //! Pointer on list of shapes
148 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
149
150 //! Pointer on attribute object
151 typedef std::shared_ptr<GeomAPI_Shape> GeomShapePtr;
152
153 #endif