Salome HOME
Issue #358: Prevent crashes on operations when viewer is absent
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Extrusion.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_Extrusion.h
4 // Created:     22 October 2014
5 // Author:      Sergey Zaritchny
6
7 #ifndef GeomAlgoAPI_Extrusion_H_
8 #define GeomAlgoAPI_Extrusion_H_
9
10 #include <GeomAlgoAPI.h>
11 #include <GeomAPI_Shape.h>
12 #include <GeomAPI_Dir.h>
13 #include <GeomAlgoAPI_MakeShape.h>
14 #include <GeomAPI_DataMapOfShapeShape.h>
15 #include <memory>
16 /**\class GeomAlgoAPI_Extrusion
17  * \ingroup DataAlgo
18  * \brief Allows to create the prism based on a given face and a direction
19  */
20
21 class GeomAlgoAPI_Extrusion : public GeomAPI_Interface
22 {
23  public:
24
25   /* \brief Creates extrusion for the given shape along the normal for this shape
26    * \param[in] theBasis face or wire to be extruded
27    * \param[in] theSize  the length of extrusion (if the value is less than 0, the extrusion in opposite normal)
28    * \return a solid or a face/shell which is obtained from specified one  
29    */
30   /// Constructor
31   GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion (std::shared_ptr<GeomAPI_Shape> theBasis, double theSize);
32
33   /// Returns True if algorithm succeed
34   GEOMALGOAPI_EXPORT const bool isDone() const;
35
36   ///  Returns True if resulting shape is valid
37   GEOMALGOAPI_EXPORT const bool isValid() const;
38
39   /// Returns True if resulting shape has volume
40   GEOMALGOAPI_EXPORT const bool hasVolume() const;
41
42   /// Returns result of the Extrusion algorithm which may be a Solid or a Face
43   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape () const;
44
45   /// Returns the first shape 
46   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& firstShape();
47
48   /// returns last shape
49   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& lastShape(); 
50  
51   /// Returns map of sub-shapes of the result. To be used for History keeping
52   GEOMALGOAPI_EXPORT void  mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const;
53
54   /// Return interface for for History processing
55   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape () const;
56
57   /// Destructor
58   GEOMALGOAPI_EXPORT  ~GeomAlgoAPI_Extrusion();
59 private:
60   /// builds resulting shape
61   void build(const std::shared_ptr<GeomAPI_Shape>& theBasis);
62   /// fields
63   double mySize;
64   bool myDone;
65   std::shared_ptr<GeomAPI_Shape> myShape;
66   std::shared_ptr<GeomAPI_Shape> myFirst;
67   std::shared_ptr<GeomAPI_Shape> myLast;
68   GeomAPI_DataMapOfShapeShape myMap;
69   GeomAlgoAPI_MakeShape * myMkShape;
70 };
71
72 #endif