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"
12 #include <GeomAPI_Pnt.h>
13 #include <GeomAPI_Shape.h>
14 #include <GeomAPI_Vertex.h>
16 /// \class GeomAlgoAPI_ShapeTools
18 /// \brief Useful tools for working with shapes.
19 class GEOMALGOAPI_EXPORT GeomAlgoAPI_ShapeTools
22 /// \return the total volume of the solids of the current shape or 0.0 if it can be computed.
23 static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
25 /// \return the centre of mass of the current face. The coordinates returned for the center of mass
26 /// are expressed in the absolute Cartesian coordinate system. (This function works only for surfaces).
27 static std::shared_ptr<GeomAPI_Pnt> centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape);
29 /// \brief Combines faces with common edges to shells, or solids to compsolids.
30 /// \param[in] theCompound compound of shapes.
31 /// \param[in] theType type of combine.
32 /// \param[out] theCombinedShapes resulting shapes.
33 /// \param[out] theFreeShapes shapes that does not have common subshapes.
34 static void combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
35 const GeomAPI_Shape::ShapeType theType,
36 ListOfShape& theCombinedShapes,
37 ListOfShape& theFreeShapes);
39 /// \brief Calculates bounding box for theShapes
40 /// \return list of eight points.
41 /// \param[in] theShapes list of shapes.
42 /// \param[in] theEnlarge enlarges bounding box size.
43 static std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0);
45 /// \return infinite plane received from theFace plane.
46 static std::shared_ptr<GeomAPI_Shape> faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace);
48 /// \brief Enlarges or reduces plane to fit bounding box.
49 /// \return plane that fits to bounding box.
50 /// \param[in] thePlane base plane.
51 /// \param[in] thePoints bounding box points (shoud be eight).
52 static std::shared_ptr<GeomAPI_Shape> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
53 const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
55 /// \brief Finds the start and end vertices of theShape. theShape can be of the following type:\n
56 /// Vertex: theV1 and theV2 are the same and equal to theShape;\n
57 /// Edge : theV1 is start and theV2 is end vertex;\n
58 /// Wire : theV1 is start vertex of the first edge, theV2 is end vertex of the last edge. If wire
59 /// contains no edges theV1 and theV2 are nullified.\n
60 /// If none of the above theV1 and theV2 are nullified.
61 static void findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
62 std::shared_ptr<GeomAPI_Vertex>& theV1,
63 std::shared_ptr<GeomAPI_Vertex>& theV2);