Salome HOME
Feature #524: 4.01. Revolution feature (not complete!)
[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] theFromShape from bounding shape
38    *  \param[in] theFromAngle from angle
39    *  \param[in] theToShape to bounding shape
40    *  \param[in] theToAngle to angle
41    *  \return a solid which is obtained from specified one
42    */
43   GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBasis,
44                                             std::shared_ptr<GeomAPI_Ax1>   theAxis,
45                                             std::shared_ptr<GeomAPI_Shape> theFromShape,
46                                             double                         theFromAngle,
47                                             std::shared_ptr<GeomAPI_Shape> theToShape,
48                                             double                         theToAngle);
49
50   /// \return true if algorithm succeed.
51   GEOMALGOAPI_EXPORT const bool isDone() const;
52
53   /// \return true if resulting shape is valid.
54   GEOMALGOAPI_EXPORT const bool isValid() const;
55
56   /// \return true if resulting shape has volume.
57   GEOMALGOAPI_EXPORT const bool hasVolume() const;
58
59   /// \return result of the Revolution algorithm.
60   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape() const;
61
62   /// \return the first shape.
63   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& firstShape();
64
65   /// \return the last shape.
66   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& lastShape();
67  
68   /// \return map of sub-shapes of the result. To be used for History keeping.
69   GEOMALGOAPI_EXPORT void mapOfShapes(GeomAPI_DataMapOfShapeShape& theMap) const;
70
71   /// \return interface for History processing.
72   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape() const;
73
74   /// Destructor.
75   GEOMALGOAPI_EXPORT ~GeomAlgoAPI_Revolution();
76
77 private:
78   /** \brief Constructs infinite face from thePlane, and with axis located on the same side
79    *  of the plane as thePoint. Modifies thePlane axis direction.
80    *  \param[in,out] thePlane plane to construct face.
81    *  \param[in] thePoint point to locate plane axis.
82    *  \return constructed face.
83    */
84   TopoDS_Face makeFaceFromPlane(gp_Pln& thePlane, const gp_Pnt& thePoint);
85
86   /// \return solid created from face.
87   TopoDS_Solid makeSolidFromFace(const TopoDS_Face& theFace);
88
89   /** \brief Selects solid from theShape with closest center of mass to thePoint
90    *  \param[in] theShape compound with solids.
91    *  \param[in] thePoint point.
92    *  \return solid.
93    */
94   TopoDS_Shape findClosest(const TopoDS_Shape& theShape, const gp_Pnt& thePoint);
95
96   /// Builds resulting shape.
97   void build(const std::shared_ptr<GeomAPI_Shape>& theBasis);
98
99 private:
100   /// Fields.
101   std::shared_ptr<GeomAPI_Ax1>   myAxis;
102   std::shared_ptr<GeomAPI_Shape> myFromShape;
103   double myFromAngle;
104   std::shared_ptr<GeomAPI_Shape> myToShape;
105   double myToAngle;
106   bool myDone;
107   std::shared_ptr<GeomAPI_Shape> myShape;
108   std::shared_ptr<GeomAPI_Shape> myFirst;
109   std::shared_ptr<GeomAPI_Shape> myLast;
110   GeomAPI_DataMapOfShapeShape myMap;
111   GeomAlgoAPI_MakeShape* myMkShape;
112 };
113
114 #endif