Salome HOME
Documentation fixes.
[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] theAxis axis for revolution.
38    *  \param[in] theToAngle to angle.
39    *  \param[in] theFromAngle from angle.
40    */
41   GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBasis,
42                                             std::shared_ptr<GeomAPI_Ax1>   theAxis,
43                                             double                         theToAngle,
44                                             double                         theFromAngle);
45
46   /** \brief Creates revolution for the given shape.
47    *  \param[in] theBasis face for revolution.
48    *  \param[in] theAxis axis for revolution.
49    *  \param[in] theToShape to bounding shape. Can be empty. In this case offset will be applied to the basis.
50    *  \param[in] theToAngle to angle.
51    *  \param[in] theFromShape from bounding shape. Can be empty. In this case offset will be applied to the basis.
52    *  \param[in] theFromAngle from angle.
53    */
54   GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBasis,
55                                             std::shared_ptr<GeomAPI_Ax1>   theAxis,
56                                             std::shared_ptr<GeomAPI_Shape> theToShape,
57                                             double                         theToAngle,
58                                             std::shared_ptr<GeomAPI_Shape> theFromShape,
59                                             double                         theFromAngle);
60
61   /// \return true if algorithm succeed.
62   GEOMALGOAPI_EXPORT const bool isDone() const;
63
64   /// \return true if resulting shape is valid.
65   GEOMALGOAPI_EXPORT const bool isValid() const;
66
67   /// \return true if resulting shape has volume.
68   GEOMALGOAPI_EXPORT const bool hasVolume() const;
69
70   /// \return result of the Revolution algorithm.
71   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape() const;
72
73   /// \returns the list of from faces.
74   GEOMALGOAPI_EXPORT const ListOfShape& fromFaces() const;
75
76   /// \return the list of to faces.
77   GEOMALGOAPI_EXPORT const ListOfShape& toFaces() const;
78  
79   /// \return map of sub-shapes of the result. To be used for History keeping.
80   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfShapes() const;
81
82   /// \return interface for History processing.
83   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
84
85 private:
86   /** \brief Constructs infinite face from thePlane, and with axis located on the same side
87    *  of the plane as thePoint. Modifies thePlane axis direction.
88    *  \param[in,out] thePlane plane to construct face.
89    *  \param[in] thePoint point to locate plane axis.
90    *  \return constructed face.
91    */
92   TopoDS_Face makeFaceFromPlane(gp_Pln& thePlane, const gp_Pnt& thePoint);
93
94   /// \return solid created from face or shell.
95   TopoDS_Solid makeSolidFromShape(const TopoDS_Shape& theShape);
96
97   /** \brief Selects solid from theShape with closest center of mass to thePoint
98    *  \param[in] theShape compound with solids.
99    *  \param[in] thePoint point.
100    *  \return solid.
101    */
102   TopoDS_Shape findClosest(const TopoDS_Shape& theShape, const gp_Pnt& thePoint);
103
104   /// Builds resulting shape.
105   void build(const std::shared_ptr<GeomAPI_Shape>& theBasis,
106              const std::shared_ptr<GeomAPI_Ax1>&   theAxis,
107              const std::shared_ptr<GeomAPI_Shape>& theToShape,
108              double                                theToAngle,
109              const std::shared_ptr<GeomAPI_Shape>& theFromShape,
110              double                                theFromAngle);
111
112 private:
113   /// Fields.
114   bool myDone;
115   std::shared_ptr<GeomAPI_Shape> myShape;
116   ListOfShape myFromFaces;
117   ListOfShape myToFaces;
118   std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
119   std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
120 };
121
122 #endif