Salome HOME
Issue #1366: Remove Sub-Shapes feature added.
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeTools.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_ShapeTools.h
4 // Created:     3 August 2015
5 // Author:      Dmitry Bobylev
6
7 #ifndef GeomAlgoAPI_ShapeTools_H_
8 #define GeomAlgoAPI_ShapeTools_H_
9
10 #include "GeomAlgoAPI.h"
11
12 #include <GeomAPI_Shape.h>
13 #include <GeomAPI_Vertex.h>
14
15 class GeomAPI_Dir;
16 class GeomAPI_PlanarEdges;
17 class GeomAPI_Pln;
18 class GeomAPI_Pnt;
19
20 /// \class GeomAlgoAPI_ShapeTools
21 /// \ingroup DataAlgo
22 /// \brief Useful tools for working with shapes.
23 class GeomAlgoAPI_ShapeTools
24 {
25 public:
26   /// \return the total volume of the solids of the current shape or 0.0 if it can be computed.
27   GEOMALGOAPI_EXPORT static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
28
29   /// \return the centre of mass of the current face. The coordinates returned for the center of mass
30   /// are expressed in the absolute Cartesian coordinate system. (This function works only for surfaces).
31   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pnt> centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape);
32
33   /// \brief Combines faces with common edges to shells, or solids to compsolids.
34   /// \param[in] theCompound compound of shapes.
35   /// \param[in] theType type of combine.
36   /// \param[out] theCombinedShapes resulting shapes.
37   /// \param[out] theFreeShapes shapes that does not have common subshapes.
38   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
39                                                                          const GeomAPI_Shape::ShapeType theType,
40                                                                          ListOfShape& theCombinedShapes,
41                                                                          ListOfShape& theFreeShapes);
42
43   /// \brief Groups shapes with shared topology to compounds.
44   /// \param[in] theCompound compound of shapes.
45   /// \return compound of compounds with shared topology.
46   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> groupSharedTopology(const std::shared_ptr<GeomAPI_Shape> theCompound);
47
48   /// \brief Calculates bounding box for theShapes
49   /// \return list of eight points.
50   /// \param[in] theShapes list of shapes.
51   /// \param[in] theEnlarge enlarges bounding box size.
52   GEOMALGOAPI_EXPORT static std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0);
53
54   /// \return infinite plane received from theFace plane.
55   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace);
56
57   /// \brief Enlarges or reduces plane to fit bounding box.
58   /// \return plane that fits to bounding box.
59   /// \param[in] thePlane base plane.
60   /// \param[in] thePoints bounding box points (shoud be eight).
61   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
62                                                                          const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
63
64   /// \brief Finds the start and end vertices of theShape. theShape can be of the following type:\n
65   /// Vertex: theV1 and theV2 are the same and equal to theShape;\n
66   /// Edge : theV1 is start and theV2 is end vertex;\n
67   /// Wire : theV1 is start vertex of the first edge, theV2 is end vertex of the last edge. If wire
68   /// contains no edges theV1 and theV2 are nullified.\n
69   /// If none of the above theV1 and theV2 are nullified.
70   GEOMALGOAPI_EXPORT static void findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
71                                             std::shared_ptr<GeomAPI_Vertex>& theV1,
72                                             std::shared_ptr<GeomAPI_Vertex>& theV2);
73
74   /// \brief Creates faces with holes from wires.
75   /// \param[in] theWires base wires.
76   /// \param[out] theFaces resulting faces.
77   GEOMALGOAPI_EXPORT static void makeFacesWithHoles(const std::shared_ptr<GeomAPI_Pnt> theOrigin,
78                                                     const std::shared_ptr<GeomAPI_Dir> theDirection,
79                                                     const ListOfShape& theWires,
80                                                     ListOfShape& theFaces);
81
82   /// \brief Return a plane for list of shapes if they are all planar.
83   /// \param[in] theShapes shapes to find plane.
84   /// \return plane where all shapes lie or empty ptr if they not planar.
85   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pln> findPlane(const ListOfShape& theShapes);
86
87   /// \brief Checks that vertex/edge is inside face or vertext inside wire.
88   /// \param[in] theSubShape shape that should be inside.
89   /// \param[in] theBaseShape base shape.
90   /// \return true if edge inside the face.
91   GEOMALGOAPI_EXPORT static bool isSubShapeInsideShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
92                                                        const std::shared_ptr<GeomAPI_Shape> theBaseShape);
93
94   /// \return true if theShape is valid.
95   GEOMALGOAPI_EXPORT static bool isShapeValid(const std::shared_ptr<GeomAPI_Shape> theShape);
96
97 };
98
99 #endif