X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Shape.h;h=91aa17d19238d807499cdfae0ae775308fd86507;hb=refs%2Fheads%2FV9_11_BR;hp=96db714562f42983e3730546629d62bb049c306e;hpb=29083ee3765ce3f564eb4fa6c93620084acfb067;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.h b/src/GeomAPI/GeomAPI_Shape.h index 96db71456..91aa17d19 100644 --- a/src/GeomAPI/GeomAPI_Shape.h +++ b/src/GeomAPI/GeomAPI_Shape.h @@ -1,37 +1,288 @@ -// File: GeomAPI_Shape.hxx -// Created: 23 Apr 2014 -// Author: Mikhail PONIKAROV +// Copyright (C) 2014-2023 CEA, EDF +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #ifndef GeomAPI_Shape_H_ #define GeomAPI_Shape_H_ +#include "GeomAPI_Dir.h" + #include -#include +#include +#include + +class GeomAPI_Pnt; +class GeomAPI_Vertex; +class GeomAPI_Edge; +class GeomAPI_Wire; +class GeomAPI_Face; +class GeomAPI_Shell; +class GeomAPI_Solid; +class GeomAPI_Trsf; /**\class GeomAPI_Shape * \ingroup DataModel * \brief Interface to the topological shape object */ -class GEOMAPI_EXPORT GeomAPI_Shape : public GeomAPI_Interface +class GeomAPI_Shape : public GeomAPI_Interface { +public: + /// Shape type enum + enum ShapeType { + COMPOUND, COMPSOLID, SOLID, SHELL, + FACE, WIRE, EDGE, VERTEX, + SHAPE + }; + + /// Shape orientation + enum Orientation { + FORWARD, + REVERSED, + INTERNAL, + EXTERNAL + }; + public: /// Creation of empty (null) shape + GEOMAPI_EXPORT GeomAPI_Shape(); + /// \return a new Shape with the same Orientation and Location and a new TShape with the same + /// geometry and no sub-shapes. + GEOMAPI_EXPORT std::shared_ptr emptyCopied() const; + + /// Returns true if the underlied shape is null + GEOMAPI_EXPORT bool isNull() const; /// Returns whether the shapes are equal - virtual bool isEqual(const boost::shared_ptr theShape) const; + GEOMAPI_EXPORT + virtual bool isEqual(const std::shared_ptr theShape) const; + + /// Returns whether the shapes are same + GEOMAPI_EXPORT + virtual bool isSame(const std::shared_ptr theShape) const; + + /// Returns \c true if shapes have same underlying geometry + GEOMAPI_EXPORT + virtual bool isSameGeometry(const std::shared_ptr theShape) const; /// Returns whether the shape is a vertex + GEOMAPI_EXPORT virtual bool isVertex() const; /// Returns whether the shape is an edge + GEOMAPI_EXPORT virtual bool isEdge() const; + /// Returns whether the shape is a wire + GEOMAPI_EXPORT + virtual bool isWire() const; + + /// Returns whether the shape is a face + GEOMAPI_EXPORT + virtual bool isFace() const; + + /// Returns whether the shape is a shell + GEOMAPI_EXPORT + virtual bool isShell() const; + + /// Returns whether the shape is a compound + GEOMAPI_EXPORT + virtual bool isCompound() const; + + /// Returns whether the shape is a compound of solids + GEOMAPI_EXPORT + virtual bool isCompoundOfSolids() const; + + /// Returns true, if the shape contains only solids, compsolids + /// and compounds of solids and compsolids of any nesting depth + GEOMAPI_EXPORT + virtual bool isCollectionOfSolids() const; + + /// Returns whether the shape is a compound where all elements are topologically connected + GEOMAPI_EXPORT + virtual bool isConnectedTopology() const; + + /// Returns whether the shape is a solid + GEOMAPI_EXPORT + virtual bool isSolid() const; + + /// Returns whether the shape is a compsolid + GEOMAPI_EXPORT + virtual bool isCompSolid() const; + + /// Returns whether the shape is planar + GEOMAPI_EXPORT + virtual bool isPlanar() const; + + /// Returns vertex or empty shape + GEOMAPI_EXPORT + std::shared_ptr vertex() const; + + /// Returns edge or empty shape + GEOMAPI_EXPORT + std::shared_ptr edge() const; + + /// Returns wire or empty shape + GEOMAPI_EXPORT + std::shared_ptr wire() const; + + /// Returns face or empty shape + GEOMAPI_EXPORT + std::shared_ptr face() const; + + /// Returns shell or empty shape + GEOMAPI_EXPORT + std::shared_ptr shell() const; + + /// Returns solid or empty shape + GEOMAPI_EXPORT + std::shared_ptr solid() const; + + /// Returns list of sub-shapes of the given type + /// \param theSubShapeType type of sub-shapes to search. + /// \param theOnlyUnique set it to \c true to omit subsequent + /// inclusions of the same sub-shape. By default it is \c false. + GEOMAPI_EXPORT + std::list< std::shared_ptr > subShapes(const ShapeType theSubShapeType, + const bool theOnlyUnique = false) const; + + /// Returns the shape type + GEOMAPI_EXPORT + virtual ShapeType shapeType() const; + + /// Returns the type enumeration by the string-type + GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType); + + /// \return the shape type as string. + GEOMAPI_EXPORT + virtual std::string shapeTypeStr() const; + + /// \return the shape orientation. + GEOMAPI_EXPORT virtual Orientation orientation() const; + + /// Sets the shape orientation. + GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation); + + /// Reverse shape + GEOMAPI_EXPORT virtual void reverse(); + + /// \return true if passed shape is a sub-shape of this shape. + /// \param theShape shape to search. + /// \param theCheckOrientation if false, returns true even if orientation of shape differs + GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr theShape, + const bool theCheckOrientation = true) const; + + /// Computes boundary dimensions of the shape + /// Returns False if it is not possible + GEOMAPI_EXPORT + bool computeSize(double& theXmin, double& theYmin, double& theZmin, + double& theXmax, double& theYmax, double& theZmax) const; + + /// Return middle point on the shape + GEOMAPI_EXPORT + virtual std::shared_ptr middlePoint() const; + + /// Returns the shape as BRep stream + GEOMAPI_EXPORT + std::string getShapeStream(const bool theWithTriangulation = true) const; + + /// Returns intersection of shapes + GEOMAPI_EXPORT + std::shared_ptr intersect(const std::shared_ptr theShape) const; + + /// Returns true if min distance between shapes < tolerance. + GEOMAPI_EXPORT + bool isIntersect(const std::shared_ptr theShape) const; + + /// Translates the shape along the direction for the given offset + GEOMAPI_EXPORT + void translate(const std::shared_ptr theDir, const double theOffset); + + /// Moves the shape with the given transformation matrix. + GEOMAPI_EXPORT + void move(const std::shared_ptr theTransformation); + + /// Returns type of shapes in the compound. + // If shapes are of different type then it will return SHAPE type + GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const; + + /// Returns true if shape have self-intersections. + /// \param[in] theLevelOfCheck defines which interferences will be checked:
+ /// 0 - only V/V;
+ /// 1 - V/V and V/E;
+ /// 2 - V/V, V/E and E/E;
+ /// 3 - V/V, V/E, E/E and V/F;
+ /// 4 - V/V, V/E, E/E, V/F and E/F;
+ /// 5 - V/V, V/E, E/E, V/F, E/F and F/F;
+ /// 6 - V/V, V/E, E/E, V/F, E/F, F/F and V/S;
+ /// 7 - V/V, V/E, E/E, V/F, E/F, F/F, V/S and E/S;
+ /// 8 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S and F/S;
+ /// 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) + GEOMAPI_EXPORT bool isSelfIntersected(const int theLevelOfCheck = 9) const; + +public: + /// \brief Compare addresses of shapes + class Comparator + { + public: + /// Return \c true if the address of the first shape is less than the address of the second + GEOMAPI_EXPORT + bool operator ()(const std::shared_ptr& theShape1, + const std::shared_ptr& theShape2) const; + }; + + /// \brief Compare addresses of shapes with respect to orientation of shapes. + /// Same TShapes with opposite orientations will be treated as different. + class ComparatorWithOri + { + public: + /// Return \c true if the address of the first shape is less than the address of the second + GEOMAPI_EXPORT + bool operator ()(const std::shared_ptr& theShape1, + const std::shared_ptr& theShape2) const; + }; + + /// \brief Hash code for the shape + class Hash + { + public: + /// Return Hash value according to the address of the shape + GEOMAPI_EXPORT + int operator ()(const std::shared_ptr& theShape) const; + }; + + /// \brief Compare addresses of shapes + class Equal + { + public: + /// Return \c true if the address of the shapes are equal + GEOMAPI_EXPORT + bool operator ()(const std::shared_ptr& theShape1, + const std::shared_ptr& theShape2) const; + }; }; +//! Pointer on list of shapes +typedef std::list > ListOfShape; + //! Pointer on attribute object -typedef boost::shared_ptr GeomShapePtr; +typedef std::shared_ptr GeomShapePtr; #endif