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