Salome HOME
e851eaa3685355efc22da818014e510e6ce28303
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.h
1
2
3 #ifndef HYDROData_CalculationCase_HeaderFile
4 #define HYDROData_CalculationCase_HeaderFile
5
6 #include <HYDROData_ShapesGroup.h>
7 #include <HYDROData_SplitToZonesTool.h>
8 #include <HYDROData_PriorityQueue.h>
9 #include <HYDROData_Zone.h>
10
11 // IDL includes
12 #include <SALOMEconfig.h>
13 #include CORBA_SERVER_HEADER(GEOM_Gen)
14
15 class gp_XY;
16
17 class TopoDS_Shape;
18 class TopoDS_Shell;
19 class TopTools_ListOfShape;
20
21 class Handle(HYDROData_Object);
22 class Handle(HYDROData_Region);
23 class Handle(HYDROData_Zone);
24 class Handle(HYDROData_PolylineXY);
25 class Handle(HYDROData_ShapesGroup);
26 class Handle(HYDROData_SplittedShapesGroup);
27 class Handle(HYDROData_Document);
28
29 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
30
31
32 /**\class HYDROData_CalculationCase
33  * \brief Calculation case is defined by selection of Geometry objects with or without \93Zone of water\94.
34  *
35  */
36 class HYDROData_CalculationCase : public HYDROData_Entity
37 {
38 public:
39
40   enum PointClassification
41   {
42     POINT_OUT,  ///< point is out of zone face
43     POINT_IN,   ///< point is inside of zone face
44     POINT_ON    ///< point is on the edge of zone face
45   };
46
47   enum AssignmentMode
48   {
49     MANUAL = 0,
50     AUTOMATIC,
51   };
52
53 public:
54
55   /**
56    * Enumeration of tags corresponding to the persistent object parameters.
57    */
58   enum DataTag
59   {
60     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
61     DataTag_GeometryObject,   ///< reference geometry objects
62     DataTag_ChildRegion,      ///< child regions
63     DataTag_Region,           ///< reference regions
64     DataTag_Polyline,         ///< reference boundary polyline
65     DataTag_GeometryGroup,    ///< reference geometry groups
66     DataTag_SplittedGroups,   ///< reference splitted groups
67     DataTag_CustomRules,      ///< custom rules
68     DataTag_AssignmentMode,   ///< assignment mode
69   };
70
71 public:
72
73   DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
74
75   /**
76    * Returns the kind of this object. Must be redefined in all objects of known type.
77    */
78   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
79
80   /**
81    * Updates the name of this object.
82    * Reimplemented to update the names of regions, zones and splitted groups.
83    */
84   HYDRODATA_EXPORT virtual void SetName( const QString& theName );
85
86   /**
87    * Dump Calculation object to Python script representation.
88    */
89   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
90
91   /**
92    * Update the calcualtion case object.
93    * Call this method whenever you made changes for object data.
94    */
95   HYDRODATA_EXPORT virtual void Update();
96
97   /**
98    * Returns the list of all reference objects of this object.
99    */
100   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
101
102 public:      
103   // Public methods to work with Calculation
104
105   /**
106    * Add new one reference geometry object for calculation case.
107    */
108   HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
109
110   /**
111    * Returns all reference geometry objects of calculation case.
112    */
113   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
114
115   /**
116    * Removes reference geometry object from calculation case.
117    */
118   HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
119
120   /**
121    * Removes all reference geometry objects from calculation case.
122    */
123   HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
124
125
126   /**
127    * Add new one reference geometry group for calculation case.
128    */
129   HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
130
131   /**
132    * Returns all reference geometry groups of calculation case.
133    */
134   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
135
136   /**
137    * Removes reference geometry group from calculation case.
138    */
139   HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
140
141   /**
142    * Removes all reference geometry groups from calculation case.
143    */
144   HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
145
146
147   /**
148    * Sets reference boundary polyline object for calculation case.
149    */
150   HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
151
152   /**
153    * Returns reference boundary polyline object of calculation case.
154    */
155   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
156
157   /**
158    * Remove reference boundary polyline object from calculation case.
159    */
160   HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
161
162
163   /**
164    * Add new one child region for calculation case.
165    * The new region is added into the list of reference regions.
166    * The label of theZone is changed during this operation
167    * because of new region becomes the new parent for this zone.
168    */
169   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
170
171
172   /**
173    * Add new one reference region for calculation case.
174    * The label of theRegion is changed in case if old parent is not this calculation.
175    */
176   HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
177
178   /**
179    * Returns all reference regions of calculation case.
180    */
181   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
182
183   /**
184    * Updates names of regions to correct order.
185    */
186   HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
187
188   /**
189    * Removes reference region from calculation case.
190    */
191   HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
192
193   /**
194    * Removes all reference regions from calculation case.
195    */
196   HYDRODATA_EXPORT virtual void RemoveRegions();
197
198   
199   /**
200    * Returns all reference geometry groups of calculation case.
201    */
202   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
203
204   /**
205    * Removes all reference geometry groups from calculation case.
206    */
207   HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
208
209
210   /**
211    * Exports the calculation case data (shell and groups) to GEOM module.
212    * \param theGeomEngine GEOM module engine
213    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
214    * \return true in case of success
215    */
216   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
217                                         SALOMEDS::Study_ptr theStudy ) const;
218
219 public:      
220   // Public methods to work with Calculation services
221
222   /**
223    * Returns altitude for given point.
224    * \param thePoint the point to examine
225    * \return result altitude value
226    */
227   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
228
229   /**
230    * Returns altitude for given point on given region.
231    * \param thePoint the point to examine
232    * \param theRegion reference region to check
233    * \return result altitude value
234    */
235   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                    thePoint,
236                                                        const Handle(HYDROData_Region)& theRegion ) const;
237
238   /**
239    * Returns altitude for given point on given zone.
240    * \param thePoint the point to examine
241    * \param theZone reference zone to check
242    * \return result altitude value
243    */
244   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
245                                                        const Handle(HYDROData_Zone)& theZone ) const;
246
247   /**
248    * Returns altitudes for given points on given region.
249    * \param thePoints the points to examine
250    * \param theRegion reference region to check
251    * \return result altitude value
252    */
253   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
254     const NCollection_Sequence<gp_XY>& thePoints,
255     const Handle(HYDROData_Region)&    theRegion ) const;
256
257   /**
258    * Returns altitudes for given points on given zone.
259    * \param thePoints the points to examine
260    * \param theZone reference zone to check
261    * \return result altitude value
262    */
263   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
264     const NCollection_Sequence<gp_XY>& thePoints,
265     const Handle(HYDROData_Zone)&      theZone ) const;
266
267   /**
268    * Returns region to which the point is belongs.
269    * \param thePoint the point to examine
270    * \return result region
271    */
272   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
273
274   /**
275    * Returns zone to which the point is belongs.
276    * \param thePoint the point to examine
277    * \return result zone
278    */
279   HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
280
281   /**
282    * Returns classification of point for given zone.
283    * \param thePoint the point to examine
284    * \param theZone the zone to examine
285    * \return result classification
286    */
287   HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
288     const gp_XY&                  thePoint,
289     const Handle(HYDROData_Zone)& theZone ) const;
290
291   HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
292   HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
293
294   HYDRODATA_EXPORT void ClearRules();
295   HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Object)&    theObject1,
296                                  HYDROData_PriorityType             thePriority,
297                                  const Handle(HYDROData_Object)&    theObject2,
298                                  HYDROData_Zone::MergeAltitudesType theMergeType );
299
300   HYDRODATA_EXPORT QString DumpRules();
301
302 private:
303
304   /**
305    * Add new one region for calculation case.
306    * The new region is added into the list of reference regions.
307    */
308   Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
309                                          const QString& thePrefixOrName,
310                                          bool isPrefix = true );
311
312   /**
313    * Add new one splitted edges group for calculation case.
314    */
315   Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
316
317   /**
318    * Exports the given faces as shell and the given groups to GEOM module.
319    * \param theGeomEngine GEOM module engine
320    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
321    * \param theFaces the list of faces to make shell 
322    * \param theSplittedGroups the list of groups
323    * \return true in case of success
324    */
325   bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
326                SALOMEDS::Study_ptr                           theStudy,
327                const TopTools_ListOfShape&                   theFaces,
328                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const;
329
330   /**
331    * Publish the given shape in GEOM as a GEOM object.
332    * \param theGeomEngine GEOM module engine
333    * \param theStudy SALOMEDS study, used for publishing of the shape
334    * \param theShape the shape to publish as a GEOM object
335    * \param theName the name of the published object
336    * \return the published GEOM object
337    */
338   GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
339                                             SALOMEDS::Study_ptr theStudy,
340                                             const TopoDS_Shape& theShape, 
341                                             const QString&      theName ) const;
342
343   void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
344                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
345   void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
346                           const HYDROData_SplitToZonesTool::SplitDataList& theZones );
347
348   void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
349                             const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
350
351   void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
352
353 protected:
354   friend class HYDROData_Iterator;
355
356   /**
357    * Creates new object in the internal data structure. Use higher level objects 
358    * to create objects with real content.
359    */
360   HYDRODATA_EXPORT HYDROData_CalculationCase();
361
362   /**
363    * Destructs properties of the object and object itself, removes it from the document.
364    */
365   HYDRODATA_EXPORT ~HYDROData_CalculationCase();
366 };
367
368 #endif