Salome HOME
Merge branch 'Dev_GroupsRevision'
[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_Dir.h"
25
26 #include <GeomAPI_Interface.h>
27 #include <memory>
28 #include <list>
29
30 /**\class GeomAPI_Shape
31  * \ingroup DataModel
32  * \brief Interface to the topological shape object
33  */
34 class GeomAPI_Shape : public GeomAPI_Interface
35 {
36 public:
37   /// Shape type enum
38   enum ShapeType {
39     COMPOUND, COMPSOLID, SOLID, SHELL,
40     FACE, WIRE, EDGE, VERTEX,
41     SHAPE
42   };
43
44   /// Shape orientation
45   enum Orientation {
46     FORWARD,
47     REVERSED,
48     INTERNAL,
49     EXTERNAL
50   };
51
52  public:
53   /// Creation of empty (null) shape
54   GEOMAPI_EXPORT
55   GeomAPI_Shape();
56
57   /// \return a new Shape with the same Orientation and Location and a new TShape with the same
58   ///         geometry and no sub-shapes.
59   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Shape> emptyCopied() const;
60
61   /// Returns true if the underlied shape is null
62   GEOMAPI_EXPORT
63   bool isNull() const;
64
65   /// Returns whether the shapes are equal
66   GEOMAPI_EXPORT
67   virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const;
68
69   /// Returns whether the shapes are same
70   GEOMAPI_EXPORT
71   virtual bool isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const;
72
73   /// Returns whether the shape is a vertex
74   GEOMAPI_EXPORT
75   virtual bool isVertex() const;
76
77   /// Returns whether the shape is an edge
78   GEOMAPI_EXPORT
79   virtual bool isEdge() const;
80
81   /// Returns whether the shape is a wire
82   GEOMAPI_EXPORT
83   virtual bool isWire() const;
84
85   /// Returns whether the shape is a face
86   GEOMAPI_EXPORT
87   virtual bool isFace() const;
88
89   /// Returns whether the shape is a compound
90   GEOMAPI_EXPORT
91   virtual bool isCompound() const;
92
93   /// Returns whether the shape is a compound of solids
94   GEOMAPI_EXPORT
95   virtual bool isCompoundOfSolids() const;
96
97   /// Returns whether the shape is a compound where all elements are topologically connected
98   GEOMAPI_EXPORT
99   virtual bool isConnectedTopology() const;
100
101   /// Returns whether the shape is a solid
102   GEOMAPI_EXPORT
103   virtual bool isSolid() const;
104
105   /// Returns whether the shape is a compsolid
106   GEOMAPI_EXPORT
107   virtual bool isCompSolid() const;
108
109   /// Returns whether the shape is planar
110   GEOMAPI_EXPORT
111   virtual bool isPlanar() const;
112
113   /// Returns the shape type
114   GEOMAPI_EXPORT
115   virtual ShapeType shapeType() const;
116
117   /// Returns the type enumeration by the string-type
118   GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType);
119
120   /// \return the shape type as string.
121   GEOMAPI_EXPORT
122   virtual std::string shapeTypeStr() const;
123
124   /// \return the shape orientation.
125   GEOMAPI_EXPORT virtual Orientation orientation() const;
126
127   /// Sets the shape orientation.
128   GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation);
129
130   /// Reverse shape
131   GEOMAPI_EXPORT virtual void reverse();
132
133   /// \return true if passed shape is a sub-shape of this shape.
134   /// \param theShape shape to search.
135   /// \param theCheckOrientation if false, returns true even if orientation of shape differs
136   GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape,
137     const bool theCheckOrientation = true) const;
138
139   /// Computes boundary dimensions of the shape
140   /// Returns False if it is not possible
141   GEOMAPI_EXPORT
142   bool computeSize(double& theXmin, double& theYmin, double& theZmin,
143                    double& theXmax, double& theYmax, double& theZmax) const;
144
145   /// Returns the shape as BRep stream
146   GEOMAPI_EXPORT
147   std::string getShapeStream() const;
148
149   /// Returns intersection of shapes
150   GEOMAPI_EXPORT
151   std::shared_ptr<GeomAPI_Shape> intersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
152
153   /// Returns true if min distance between shapes < tolerance.
154   GEOMAPI_EXPORT
155   bool isIntersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
156
157   /// Translates the shape along the direction for the given offset
158   GEOMAPI_EXPORT
159   void translate(const std::shared_ptr<GeomAPI_Dir> theDir, const double theOffset);
160
161   /// Returns type of shapes in the compound.
162   // If shapes are of different type then it will return SHAPE type
163   GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const;
164 };
165
166 //! Pointer on list of shapes
167 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
168
169 //! Pointer on attribute object
170 typedef std::shared_ptr<GeomAPI_Shape> GeomShapePtr;
171
172 #endif