1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_ShapeTools.h
4 // Created: 3 August 2015
5 // Author: Dmitry Bobylev
7 #ifndef GeomAlgoAPI_ShapeTools_H_
8 #define GeomAlgoAPI_ShapeTools_H_
10 #include <GeomAlgoAPI.h>
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Shape.h>
16 /** \class GeomAlgoAPI_ShapeTools
18 * \brief Useful tools for working with shapes.
20 class GEOMALGOAPI_EXPORT GeomAlgoAPI_ShapeTools
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);
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);
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.
36 static void combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
37 const GeomAPI_Shape::ShapeType theType,
38 ListOfShape& theCombinedShapes,
39 ListOfShape& theFreeShapes);
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.
46 static std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0);
49 * Returns infinite plane received from theFace plane.
51 static std::shared_ptr<GeomAPI_Shape> faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace);
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).
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);