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