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>
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 whether the shape is a vertex
82 virtual bool isVertex() const;
84 /// Returns whether the shape is an edge
86 virtual bool isEdge() const;
88 /// Returns whether the shape is a wire
90 virtual bool isWire() const;
92 /// Returns whether the shape is a face
94 virtual bool isFace() const;
96 /// Returns whether the shape is a shell
98 virtual bool isShell() const;
100 /// Returns whether the shape is a compound
102 virtual bool isCompound() const;
104 /// Returns whether the shape is a compound of solids
106 virtual bool isCompoundOfSolids() const;
108 /// Returns whether the shape is a compound where all elements are topologically connected
110 virtual bool isConnectedTopology() const;
112 /// Returns whether the shape is a solid
114 virtual bool isSolid() const;
116 /// Returns whether the shape is a compsolid
118 virtual bool isCompSolid() const;
120 /// Returns whether the shape is planar
122 virtual bool isPlanar() const;
124 /// Returns vertex or empty shape
126 std::shared_ptr<GeomAPI_Vertex> vertex() const;
128 /// Returns edge or empty shape
130 std::shared_ptr<GeomAPI_Edge> edge() const;
132 /// Returns wire or empty shape
134 std::shared_ptr<GeomAPI_Wire> wire() const;
136 /// Returns face or empty shape
138 std::shared_ptr<GeomAPI_Face> face() const;
140 /// Returns shell or empty shape
142 std::shared_ptr<GeomAPI_Shell> shell() const;
144 /// Returns solid or empty shape
146 std::shared_ptr<GeomAPI_Solid> solid() const;
148 /// Returns list of sub-shapes of the given type
150 std::list<std::shared_ptr<GeomAPI_Shape> > subShapes(ShapeType theSubShapeType) const;
152 /// Returns the shape type
154 virtual ShapeType shapeType() const;
156 /// Returns the type enumeration by the string-type
157 GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType);
159 /// \return the shape type as string.
161 virtual std::string shapeTypeStr() const;
163 /// \return the shape orientation.
164 GEOMAPI_EXPORT virtual Orientation orientation() const;
166 /// Sets the shape orientation.
167 GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation);
170 GEOMAPI_EXPORT virtual void reverse();
172 /// \return true if passed shape is a sub-shape of this shape.
173 /// \param theShape shape to search.
174 /// \param theCheckOrientation if false, returns true even if orientation of shape differs
175 GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape,
176 const bool theCheckOrientation = true) const;
178 /// Computes boundary dimensions of the shape
179 /// Returns False if it is not possible
181 bool computeSize(double& theXmin, double& theYmin, double& theZmin,
182 double& theXmax, double& theYmax, double& theZmax) const;
184 /// Returns the shape as BRep stream
186 std::string getShapeStream() const;
188 /// Returns intersection of shapes
190 std::shared_ptr<GeomAPI_Shape> intersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
192 /// Returns true if min distance between shapes < tolerance.
194 bool isIntersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
196 /// Translates the shape along the direction for the given offset
198 void translate(const std::shared_ptr<GeomAPI_Dir> theDir, const double theOffset);
200 /// Returns type of shapes in the compound.
201 // If shapes are of different type then it will return SHAPE type
202 GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const;
205 //! Pointer on list of shapes
206 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
208 //! Pointer on attribute object
209 typedef std::shared_ptr<GeomAPI_Shape> GeomShapePtr;