Salome HOME
c3562f75abffb6d809219e79c1914b46184a713b
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Revolution.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_Revolution.h
4 // Created:     12 May 2015
5 // Author:      Dmitry Bobylev
6
7 #ifndef GeomAlgoAPI_Revolution_H_
8 #define GeomAlgoAPI_Revolution_H_
9
10 #include <GeomAlgoAPI.h>
11 #include <GeomAlgoAPI_MakeShape.h>
12 #include <GeomAPI_Ax1.h>
13 #include <GeomAPI_DataMapOfShapeShape.h>
14
15 class gp_Pln;
16 class gp_Pnt;
17 class TopoDS_Face;
18 class TopoDS_Shape;
19 class TopoDS_Solid;
20
21 /** \class GeomAlgoAPI_Revolution
22  *  \ingroup DataAlgo
23  *  \brief Allows to create the revolution based on a given face, angles and bounding planes.
24  *  \n Note that only the planar faces are allowed as bounding faces and resulting
25  *  revolution will be bounded by the infinite planes taken from the faces.
26  *  \n If the bounding plane was specified with the angle then this plane will be rotated around
27  *  the axis to the value of the angle.
28  *  \n Note that algorithm return only one solid object. So in case when after cutting with bounding
29  *  planes algorithm got more than one solid it will return the closest to the center of mass of
30  *  the base face.
31  */
32 class GeomAlgoAPI_Revolution : public GeomAPI_Interface
33 {
34 public:
35   /** \brief Creates revolution for the given shape.
36    *  \param[in] theBasis face for revolution.
37    *  \param[in] theToAngle to angle.
38    *  \param[in] theFromAngle from angle.
39    */
40   GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBasis,
41                                             std::shared_ptr<GeomAPI_Ax1>   theAxis,
42                                             double                         theToAngle,
43                                             double                         theFromAngle);
44
45   /** \brief Creates revolution for the given shape.
46    *  \param[in] theBasis face for revolution.
47    *  \param[in] theToShape to bounding shape. Can be empty. In this case offset will be applied to the basis.
48    *  \param[in] theToAngle to angle.
49    *  \param[in] theFromShape from bounding shape. Can be empty. In this case offset will be applied to the basis.
50    *  \param[in] theFromAngle from angle.
51    */
52   GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBasis,
53                                             std::shared_ptr<GeomAPI_Ax1>   theAxis,
54                                             std::shared_ptr<GeomAPI_Shape> theToShape,
55                                             double                         theToAngle,
56                                             std::shared_ptr<GeomAPI_Shape> theFromShape,
57                                             double                         theFromAngle);
58
59   /// \return true if algorithm succeed.
60   GEOMALGOAPI_EXPORT const bool isDone() const;
61
62   /// \return true if resulting shape is valid.
63   GEOMALGOAPI_EXPORT const bool isValid() const;
64
65   /// \return true if resulting shape has volume.
66   GEOMALGOAPI_EXPORT const bool hasVolume() const;
67
68   /// \return result of the Revolution algorithm.
69   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape() const;
70
71   /// \returns the list of from faces.
72   GEOMALGOAPI_EXPORT const ListOfShape& fromFaces() const;
73
74   /// \return the list of to faces.
75   GEOMALGOAPI_EXPORT const ListOfShape& toFaces() const;
76  
77   /// \return map of sub-shapes of the result. To be used for History keeping.
78   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfShapes() const;
79
80   /// \return interface for History processing.
81   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
82
83 private:
84   /** \brief Constructs infinite face from thePlane, and with axis located on the same side
85    *  of the plane as thePoint. Modifies thePlane axis direction.
86    *  \param[in,out] thePlane plane to construct face.
87    *  \param[in] thePoint point to locate plane axis.
88    *  \return constructed face.
89    */
90   TopoDS_Face makeFaceFromPlane(gp_Pln& thePlane, const gp_Pnt& thePoint);
91
92   /// \return solid created from face or shell.
93   TopoDS_Solid makeSolidFromShape(const TopoDS_Shape& theShape);
94
95   /** \brief Selects solid from theShape with closest center of mass to thePoint
96    *  \param[in] theShape compound with solids.
97    *  \param[in] thePoint point.
98    *  \return solid.
99    */
100   TopoDS_Shape findClosest(const TopoDS_Shape& theShape, const gp_Pnt& thePoint);
101
102   /// Builds resulting shape.
103   void build(const std::shared_ptr<GeomAPI_Shape>& theBasis,
104              const std::shared_ptr<GeomAPI_Ax1>&   theAxis,
105              const std::shared_ptr<GeomAPI_Shape>& theToShape,
106              double                                theToAngle,
107              const std::shared_ptr<GeomAPI_Shape>& theFromShape,
108              double                                theFromAngle);
109
110 private:
111   /// Fields.
112   bool myDone;
113   std::shared_ptr<GeomAPI_Shape> myShape;
114   ListOfShape myFromFaces;
115   ListOfShape myToFaces;
116   std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
117   std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
118 };
119
120 #endif