Salome HOME
Fix for issue #1049
[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 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Shape.h>
13
14 #include <map>
15
16 /** \class GeomAlgoAPI_ShapeTools
17  *  \ingroup DataAlgo
18  *  \brief Useful tools for working with shapes.
19  */
20 class GEOMALGOAPI_EXPORT GeomAlgoAPI_ShapeTools
21 {
22 public:
23   /// \return the total volume of the solids of the current shape or 0.0 if it can be computed.
24   static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
25
26   /// \return the centre of mass of the current face. The coordinates returned for the center of mass
27   /// are expressed in the absolute Cartesian coordinate system. (This function works only for surfaces).
28   static std::shared_ptr<GeomAPI_Pnt> centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape);
29
30   /** \brief Combines faces with common edges to shells, or solids to compsolids.
31    *  \param[in] theCompound compound of shapes.
32    *  \param[in] theType type of combine.
33    *  \param[out] theCombinedShapes resulting shapes.
34    *  \param[out] theFreeShapes shapes that does not have common subshapes.
35    */
36   static void combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
37                             const GeomAPI_Shape::ShapeType theType,
38                             ListOfShape& theCombinedShapes,
39                             ListOfShape& theFreeShapes);
40
41   /** \brief Calculates bounding box for theShapes
42    *  \return list of eight points.
43    *  \param[in] theShapes list of shapes.
44    *  \param[in] theEnlarge enlarges bounding box size.
45    */
46   static std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0);
47
48   /**
49    * Returns infinite plane received from theFace plane.
50    */
51   static std::shared_ptr<GeomAPI_Shape> faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace);
52
53   /** \brief Enlarges or reduces plane to fit bounding box.
54    *  \return plane that fits to bounding box.
55    *  \param[in] thePlane base plane.
56    *  \param[in] thePoints bounding box points (shoud be eight).
57    */
58   static std::shared_ptr<GeomAPI_Shape> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
59                                                       const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
60
61 };
62
63 #endif