1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef GeomAPI_Shape_H_
22 #define GeomAPI_Shape_H_
24 #include "GeomAPI_Dir.h"
26 #include <GeomAPI_Interface.h>
38 /**\class GeomAPI_Shape
40 * \brief Interface to the topological shape object
42 class GeomAPI_Shape : public GeomAPI_Interface
47 COMPOUND, COMPSOLID, SOLID, SHELL,
48 FACE, WIRE, EDGE, VERTEX,
61 /// Creation of empty (null) shape
65 /// \return a new Shape with the same Orientation and Location and a new TShape with the same
66 /// geometry and no sub-shapes.
67 GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Shape> emptyCopied() const;
69 /// Returns true if the underlied shape is null
73 /// Returns whether the shapes are equal
75 virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const;
77 /// Returns whether the shapes are same
79 virtual bool isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const;
81 /// Returns whether the shape is a vertex
83 virtual bool isVertex() const;
85 /// Returns whether the shape is an edge
87 virtual bool isEdge() const;
89 /// Returns whether the shape is a wire
91 virtual bool isWire() const;
93 /// Returns whether the shape is a face
95 virtual bool isFace() const;
97 /// Returns whether the shape is a shell
99 virtual bool isShell() const;
101 /// Returns whether the shape is a compound
103 virtual bool isCompound() const;
105 /// Returns whether the shape is a compound of solids
107 virtual bool isCompoundOfSolids() const;
109 /// Returns whether the shape is a compound where all elements are topologically connected
111 virtual bool isConnectedTopology() const;
113 /// Returns whether the shape is a solid
115 virtual bool isSolid() const;
117 /// Returns whether the shape is a compsolid
119 virtual bool isCompSolid() const;
121 /// Returns whether the shape is planar
123 virtual bool isPlanar() const;
125 /// Returns vertex or empty shape
127 std::shared_ptr<GeomAPI_Vertex> vertex() const;
129 /// Returns edge or empty shape
131 std::shared_ptr<GeomAPI_Edge> edge() const;
133 /// Returns wire or empty shape
135 std::shared_ptr<GeomAPI_Wire> wire() const;
137 /// Returns face or empty shape
139 std::shared_ptr<GeomAPI_Face> face() const;
141 /// Returns shell or empty shape
143 std::shared_ptr<GeomAPI_Shell> shell() const;
145 /// Returns solid or empty shape
147 std::shared_ptr<GeomAPI_Solid> solid() const;
149 /// Returns list of sub-shapes of the given type
151 std::list<std::shared_ptr<GeomAPI_Shape> > subShapes(ShapeType theSubShapeType) const;
153 /// Returns the shape type
155 virtual ShapeType shapeType() const;
157 /// Returns the type enumeration by the string-type
158 GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType);
160 /// \return the shape type as string.
162 virtual std::string shapeTypeStr() const;
164 /// \return the shape orientation.
165 GEOMAPI_EXPORT virtual Orientation orientation() const;
167 /// Sets the shape orientation.
168 GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation);
171 GEOMAPI_EXPORT virtual void reverse();
173 /// \return true if passed shape is a sub-shape of this shape.
174 /// \param theShape shape to search.
175 /// \param theCheckOrientation if false, returns true even if orientation of shape differs
176 GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape,
177 const bool theCheckOrientation = true) const;
179 /// Computes boundary dimensions of the shape
180 /// Returns False if it is not possible
182 bool computeSize(double& theXmin, double& theYmin, double& theZmin,
183 double& theXmax, double& theYmax, double& theZmax) const;
185 /// Return middle point on the shape
187 virtual std::shared_ptr<GeomAPI_Pnt> middlePoint() const;
189 /// Returns the shape as BRep stream
191 std::string getShapeStream() const;
193 /// Returns intersection of shapes
195 std::shared_ptr<GeomAPI_Shape> intersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
197 /// Returns true if min distance between shapes < tolerance.
199 bool isIntersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
201 /// Translates the shape along the direction for the given offset
203 void translate(const std::shared_ptr<GeomAPI_Dir> theDir, const double theOffset);
205 /// Returns type of shapes in the compound.
206 // If shapes are of different type then it will return SHAPE type
207 GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const;
209 /// Returns true if shape have self-intersections.
210 /// \param[in] theLevelOfCheck defines which interferences will be checked:<br>
211 /// 0 - only V/V;<br>
212 /// 1 - V/V and V/E;<br>
213 /// 2 - V/V, V/E and E/E;<br>
214 /// 3 - V/V, V/E, E/E and V/F;<br>
215 /// 4 - V/V, V/E, E/E, V/F and E/F;<br>
216 /// 5 - V/V, V/E, E/E, V/F, E/F and F/F;<br>
217 /// 6 - V/V, V/E, E/E, V/F, E/F, F/F and V/S;<br>
218 /// 7 - V/V, V/E, E/E, V/F, E/F, F/F, V/S and E/S;<br>
219 /// 8 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S and F/S;<br>
220 /// 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)
221 GEOMAPI_EXPORT bool isSelfIntersected(const int theLevelOfCheck = 9) const;
224 //! Pointer on list of shapes
225 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
227 //! Pointer on attribute object
228 typedef std::shared_ptr<GeomAPI_Shape> GeomShapePtr;