Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / ModelAPI / ModelAPI_ResultBody.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_ResultBody.hxx
4 // Created:     07 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef ModelAPI_ResultBody_H_
8 #define ModelAPI_ResultBody_H_
9
10 #include "ModelAPI_Result.h"
11 #include <GeomAPI_Shape.h>
12 #include <GeomAPI_DataMapOfShapeShape.h>
13 #include <string>
14
15 class ModelAPI_BodyBuilder;
16 class GeomAlgoAPI_MakeShape;
17
18 /**\class ModelAPI_ResultBody
19 * \ingroup DataModel
20 * \brief The body (shape) result of a feature.
21 *
22 * Provides a shape that may be displayed in the viewer.
23 * May provide really huge results, so, working with this kind
24 * of result must be optimized.
25 */
26 class ModelAPI_ResultBody : public ModelAPI_Result
27 {
28 public:
29   MODELAPI_EXPORT virtual ~ModelAPI_ResultBody();
30   /// Returns the group identifier of this result
31   MODELAPI_EXPORT virtual std::string groupName();
32
33   /// Returns the group identifier of this result
34   inline static std::string group()
35   {
36     static std::string MY_GROUP = "Bodies";
37     return MY_GROUP;
38   }
39
40   /// default color for a result body
41   inline static const std::string& DEFAULT_COLOR()
42   {
43     static const std::string RESULT_BODY_COLOR("200,200,230");
44     return RESULT_BODY_COLOR;
45   }
46
47   /// default deflection for a result body
48   inline static const std::string DEFAULT_DEFLECTION()
49   {
50     return "0.001";
51   }
52
53   /// Iternal enumeration for storage the information of connected topology flag
54   enum ConnectedTopologyFlag {
55     ConnectionNotComputed, ///< not yet computed
56     IsConnected,           ///< the topology is connected
57     IsNotConnected         ///< the topology is connected
58   };
59   /// Keeps (not persistently) the connected topology flag
60   ConnectedTopologyFlag myConnect;
61
62   /// \brief Stores the shape (called by the execution method).
63   /// param[in] theShape shape to store.
64   /// param[in] theIsStoreSameShapes if false stores reference to the same shape
65   ///                                if it is already in document.
66   MODELAPI_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
67                                      const bool theIsStoreSameShapes = true);
68
69   /// Stores the generated shape (called by the execution method).
70   MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
71     const std::shared_ptr<GeomAPI_Shape>& theToShape);
72
73   /// Stores the modified shape (called by the execution method).
74   MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
75     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
76
77   /// Stores the shape without naming support
78   MODELAPI_EXPORT virtual void storeWithoutNaming(
79     const std::shared_ptr<GeomAPI_Shape>& theShape);
80
81   /// Returns the shape-result produced by this feature
82   MODELAPI_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
83
84   /// Records the subshape newShape which was generated during a topological construction.
85   /// As an example, consider the case of a face generated in construction of a box.
86   MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
87     const std::string& theName, const int theTag = 1);
88
89   /// Records the shape newShape which was generated from the shape oldShape during a topological
90   /// construction. As an example, consider the case of a face generated from an edge in
91   /// construction of a prism.
92   MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
93     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
94     const int theTag = 1);
95
96   /// Records the shape newShape which is a modification of the shape oldShape.
97   /// As an example, consider the case of a face split or merged in a Boolean operation.
98   MODELAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
99     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
100     const int theTag = 1);
101
102   /// Records the shape oldShape which was deleted from the current label.
103   /// As an example, consider the case of a face removed by a Boolean operation.
104   MODELAPI_EXPORT virtual void deleted(
105     const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1);
106
107   /// load deleted shapes
108   MODELAPI_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
109                                   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
110                                   const int  theKindOfShape,
111                                   const int  theTag);
112   /// load and orient modified shapes
113   MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
114     std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
115     const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
116     const bool theIsStoreSeparate = false);
117   /// load and orient generated shapes
118   MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS,
119     std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape,
120     const int  theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes);
121
122   /// load shapes of the first level (to be used during shape import)
123   MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
124     const std::string& theName, int&  theTag);
125
126   /// load disconnected edges
127   MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
128     const std::string& theName, int&  theTag);
129
130   /// load disconnected vetexes
131   MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
132     const std::string& theName,int&  theTag);
133
134   /// Returns true if the latest modification of this body in the naming history
135   // is equal to the given shape
136   MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
137
138   /// Returns true is the topology is connected. Cashes this information for the current shape,
139   /// so it is more effective to use this method than directly GeomAPI_Shape.
140   MODELAPI_EXPORT virtual bool isConnectedTopology();
141
142 protected:
143   /// Default constructor accessible only from Model_Objects
144   MODELAPI_EXPORT ModelAPI_ResultBody();
145
146   ModelAPI_BodyBuilder* myBuilder; ///< provides the body processing in naming shape
147 };
148
149 //! Pointer on feature object
150 typedef std::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;
151
152 #endif