1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef GeomAPI_Shape_H_
21 #define GeomAPI_Shape_H_
23 #include "GeomAPI_Dir.h"
25 #include <GeomAPI_Interface.h>
37 /**\class GeomAPI_Shape
39 * \brief Interface to the topological shape object
41 class GeomAPI_Shape : public GeomAPI_Interface
46 COMPOUND, COMPSOLID, SOLID, SHELL,
47 FACE, WIRE, EDGE, VERTEX,
60 /// Creation of empty (null) shape
64 /// \return a new Shape with the same Orientation and Location and a new TShape with the same
65 /// geometry and no sub-shapes.
66 GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Shape> emptyCopied() const;
68 /// Returns true if the underlied shape is null
72 /// Returns whether the shapes are equal
74 virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const;
76 /// Returns whether the shapes are same
78 virtual bool isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const;
80 /// Returns \c true if shapes have same underlying geometry
82 virtual bool isSameGeometry(const std::shared_ptr<GeomAPI_Shape> theShape) const;
84 /// Returns whether the shape is a vertex
86 virtual bool isVertex() const;
88 /// Returns whether the shape is an edge
90 virtual bool isEdge() const;
92 /// Returns whether the shape is a wire
94 virtual bool isWire() const;
96 /// Returns whether the shape is a face
98 virtual bool isFace() const;
100 /// Returns whether the shape is a shell
102 virtual bool isShell() const;
104 /// Returns whether the shape is a compound
106 virtual bool isCompound() const;
108 /// Returns whether the shape is a compound of solids
110 virtual bool isCompoundOfSolids() const;
112 /// Returns whether the shape is a compound where all elements are topologically connected
114 virtual bool isConnectedTopology() const;
116 /// Returns whether the shape is a solid
118 virtual bool isSolid() const;
120 /// Returns whether the shape is a compsolid
122 virtual bool isCompSolid() const;
124 /// Returns whether the shape is planar
126 virtual bool isPlanar() const;
128 /// Returns vertex or empty shape
130 std::shared_ptr<GeomAPI_Vertex> vertex() const;
132 /// Returns edge or empty shape
134 std::shared_ptr<GeomAPI_Edge> edge() const;
136 /// Returns wire or empty shape
138 std::shared_ptr<GeomAPI_Wire> wire() const;
140 /// Returns face or empty shape
142 std::shared_ptr<GeomAPI_Face> face() const;
144 /// Returns shell or empty shape
146 std::shared_ptr<GeomAPI_Shell> shell() const;
148 /// Returns solid or empty shape
150 std::shared_ptr<GeomAPI_Solid> solid() const;
152 /// Returns list of sub-shapes of the given type
154 std::list<std::shared_ptr<GeomAPI_Shape> > subShapes(ShapeType theSubShapeType) const;
156 /// Returns the shape type
158 virtual ShapeType shapeType() const;
160 /// Returns the type enumeration by the string-type
161 GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType);
163 /// \return the shape type as string.
165 virtual std::string shapeTypeStr() const;
167 /// \return the shape orientation.
168 GEOMAPI_EXPORT virtual Orientation orientation() const;
170 /// Sets the shape orientation.
171 GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation);
174 GEOMAPI_EXPORT virtual void reverse();
176 /// \return true if passed shape is a sub-shape of this shape.
177 /// \param theShape shape to search.
178 /// \param theCheckOrientation if false, returns true even if orientation of shape differs
179 GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape,
180 const bool theCheckOrientation = true) const;
182 /// Computes boundary dimensions of the shape
183 /// Returns False if it is not possible
185 bool computeSize(double& theXmin, double& theYmin, double& theZmin,
186 double& theXmax, double& theYmax, double& theZmax) const;
188 /// Return middle point on the shape
190 virtual std::shared_ptr<GeomAPI_Pnt> middlePoint() const;
192 /// Returns the shape as BRep stream
194 std::string getShapeStream() const;
196 /// Returns intersection of shapes
198 std::shared_ptr<GeomAPI_Shape> intersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
200 /// Returns true if min distance between shapes < tolerance.
202 bool isIntersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
204 /// Translates the shape along the direction for the given offset
206 void translate(const std::shared_ptr<GeomAPI_Dir> theDir, const double theOffset);
208 /// Returns type of shapes in the compound.
209 // If shapes are of different type then it will return SHAPE type
210 GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const;
212 /// Returns true if shape have self-intersections.
213 /// \param[in] theLevelOfCheck defines which interferences will be checked:<br>
214 /// 0 - only V/V;<br>
215 /// 1 - V/V and V/E;<br>
216 /// 2 - V/V, V/E and E/E;<br>
217 /// 3 - V/V, V/E, E/E and V/F;<br>
218 /// 4 - V/V, V/E, E/E, V/F and E/F;<br>
219 /// 5 - V/V, V/E, E/E, V/F, E/F and F/F;<br>
220 /// 6 - V/V, V/E, E/E, V/F, E/F, F/F and V/S;<br>
221 /// 7 - V/V, V/E, E/E, V/F, E/F, F/F, V/S and E/S;<br>
222 /// 8 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S and F/S;<br>
223 /// 9 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S, F/S and S/S - all interferences (Default value)
224 GEOMAPI_EXPORT bool isSelfIntersected(const int theLevelOfCheck = 9) const;
227 /// \brief Compare addresses of shapes
231 /// Return \c true if the address of the first shape is less than the address of the second
233 bool operator ()(const std::shared_ptr<GeomAPI_Shape>& theShape1,
234 const std::shared_ptr<GeomAPI_Shape>& theShape2) const;
237 /// \brief Compare addresses of shapes with respect to orientation of shapes.
238 /// Same TShapes with opposite orientations will be treated as different.
239 class ComparatorWithOri
242 /// Return \c true if the address of the first shape is less than the address of the second
244 bool operator ()(const std::shared_ptr<GeomAPI_Shape>& theShape1,
245 const std::shared_ptr<GeomAPI_Shape>& theShape2) const;
249 //! Pointer on list of shapes
250 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
252 //! Pointer on attribute object
253 typedef std::shared_ptr<GeomAPI_Shape> GeomShapePtr;