Salome HOME
Merge remote-tracking branch 'origin/BR_LAND_COVER' into BR_v14_rc
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_CalculationCase_HeaderFile
20 #define HYDROData_CalculationCase_HeaderFile
21
22 #include <HYDROData_ShapesGroup.h>
23 #include <HYDROData_SplitToZonesTool.h>
24 #include <HYDROData_PriorityQueue.h>
25 #include <HYDROData_Zone.h>
26 #include <HYDROData_Warning.h>
27
28 // IDL includes
29 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(GEOM_Gen)
31
32 class gp_XY;
33
34 class TopoDS_Shape;
35 class TopoDS_Shell;
36 class TopTools_ListOfShape;
37
38 class Handle(HYDROData_Object);
39 class Handle(HYDROData_Region);
40 class Handle(HYDROData_Zone);
41 class Handle(HYDROData_PolylineXY);
42 class Handle(HYDROData_ShapesGroup);
43 class Handle(HYDROData_SplittedShapesGroup);
44 class Handle(HYDROData_Document);
45 class Handle(HYDROData_StricklerTable);
46 class Handle(HYDROData_LandCover);
47
48 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
49
50
51 /**\class HYDROData_CalculationCase
52  * \brief Calculation case is defined by selection of Geometry objects with or without \93Zone of water\94.
53  *
54  */
55 class HYDROData_CalculationCase : public HYDROData_Entity
56 {
57 public:
58
59   enum PointClassification
60   {
61     POINT_OUT,  ///< point is out of zone face
62     POINT_IN,   ///< point is inside of zone face
63     POINT_ON    ///< point is on the edge of zone face
64   };
65
66   enum AssignmentMode
67   {
68     MANUAL = 0,
69     AUTOMATIC,
70   };
71
72 public:
73
74   /**
75    * Enumeration of tags corresponding to the persistent object parameters.
76    */
77   enum DataTag
78   {
79     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
80     DataTag_GeometryObject,            ///< reference geometry objects
81     DataTag_ChildRegion,               ///< child regions
82     DataTag_Region,                    ///< reference regions
83     DataTag_Polyline,                  ///< reference boundary polyline
84     DataTag_GeometryGroup,             ///< reference geometry groups
85     DataTag_SplittedGroups,            ///< reference splitted groups
86     DataTag_CustomRules,               ///< custom rules
87     DataTag_AssignmentMode,            ///< assignment mode
88     DataTag_StricklerTable,            ///< reference Strickler table
89     DataTag_LandCover,                 ///< reference land covers
90     DataTag_CustomLandCoverRules,      ///< custom rules for land covers priority
91     DataTag_AssignmentLandCoverMode    ///< assignment mode of land covers priority
92   };
93
94 public:
95
96   DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
97
98   /**
99    * Returns the kind of this object. Must be redefined in all objects of known type.
100    */
101   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
102
103   /**
104    * Updates the name of this object.
105    * Reimplemented to update the names of regions, zones and splitted groups.
106    */
107   HYDRODATA_EXPORT virtual void SetName( const QString& theName );
108
109   /**
110    * Dump Calculation object to Python script representation.
111    */
112   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
113
114   /**
115    * Update the calcualtion case object.
116    * Call this method whenever you made changes for object data.
117    */
118   HYDRODATA_EXPORT virtual void Update();
119
120   /**
121    * Returns the list of all reference objects of this object.
122    */
123   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
124
125 public:      
126   // Public methods to work with Calculation
127
128   /**
129    * Add new one reference geometry object for calculation case.
130    */
131   HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
132
133   /**
134    * Returns all reference geometry objects of calculation case.
135    */
136   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
137
138   /**
139    * Removes reference geometry object from calculation case.
140    */
141   HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
142
143   /**
144    * Removes all reference geometry objects from calculation case.
145    */
146   HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
147
148
149   /**
150    * Add new one reference geometry group for calculation case.
151    */
152   HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
153
154   /**
155    * Returns all reference geometry groups of calculation case.
156    */
157   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
158
159   /**
160    * Removes reference geometry group from calculation case.
161    */
162   HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
163
164   /**
165    * Removes all reference geometry groups from calculation case.
166    */
167   HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
168
169
170   /**
171    * Sets reference boundary polyline object for calculation case.
172    */
173   HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
174
175   /**
176    * Returns reference boundary polyline object of calculation case.
177    */
178   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
179
180   /**
181    * Remove reference boundary polyline object from calculation case.
182    */
183   HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
184
185
186     /**
187    * Sets reference Strickler table for calculation case.
188    */
189   HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
190
191   /**
192    * Returns reference Strickler table of calculation case.
193    */
194   HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
195
196   /**
197    * Remove reference Strickler table from calculation case.
198    */
199   HYDRODATA_EXPORT virtual void RemoveStricklerTable();
200
201
202   /**
203    * Add new one reference land cover for calculation case.
204    */
205   HYDRODATA_EXPORT virtual bool AddLandCover( const Handle(HYDROData_LandCover)& theLandCover );
206
207   /**
208    * Returns all reference land covers of calculation case.
209    */
210   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetLandCovers() const;
211
212   /**
213    * Removes reference land cover from calculation case.
214    */
215   HYDRODATA_EXPORT virtual void RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover );
216
217   /**
218    * Removes all reference land covers from calculation case.
219    */
220   HYDRODATA_EXPORT virtual void RemoveLandCovers();
221
222
223   /**
224    * Add new one child region for calculation case.
225    * The new region is added into the list of reference regions.
226    * The label of theZone is changed during this operation
227    * because of new region becomes the new parent for this zone.
228    */
229   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
230
231
232   /**
233    * Add new one reference region for calculation case.
234    * The label of theRegion is changed in case if old parent is not this calculation.
235    */
236   HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
237
238   /**
239    * Returns all reference regions of calculation case.
240    */
241   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
242
243   /**
244    * Updates names of regions to correct order.
245    */
246   HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
247
248   /**
249    * Removes reference region from calculation case.
250    */
251   HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
252
253   /**
254    * Removes all reference regions from calculation case.
255    */
256   HYDRODATA_EXPORT virtual void RemoveRegions();
257
258   
259   /**
260    * Returns all reference geometry groups of calculation case.
261    */
262   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
263
264   /**
265    * Removes all reference geometry groups from calculation case.
266    */
267   HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
268
269   /**
270    * Exports the calculation case data (shell and groups) to GEOM module.
271    * \param theStudyId the id of the study where the GEOM module should be used for export
272    * \return the entry of the GEOM object (empty string in the case of error)
273    */
274   HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
275
276   /**
277    * Exports the calculation case data (shell and groups) to GEOM module.
278    * \param theGeomEngine GEOM module engine
279    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
280    * \return true in case of success
281    */
282   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
283                                         SALOMEDS::Study_ptr theStudy,
284                                         QString& theGeomObjEntry ) const;
285
286 public:      
287   // Public methods to work with Calculation services
288
289   /**
290    * Returns altitude for given point.
291    * \param thePoint the point to examine
292    * \return result altitude value
293    */
294   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
295
296   /**
297    * Returns altitude for given point on given region.
298    * \param thePoint the point to examine
299    * \param theRegion reference region to check
300    * \return result altitude value
301    */
302   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                    thePoint,
303                                                        const Handle(HYDROData_Region)& theRegion ) const;
304
305   /**
306    * Returns altitude for given point on given zone.
307    * \param thePoint the point to examine
308    * \param theZone reference zone to check
309    * \return result altitude value
310    */
311   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
312                                                        const Handle(HYDROData_Zone)& theZone ) const;
313
314   /**
315    * Returns altitudes for given points on given region.
316    * \param thePoints the points to examine
317    * \param theRegion reference region to check
318    * \return result altitude value
319    */
320   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
321     const NCollection_Sequence<gp_XY>& thePoints,
322     const Handle(HYDROData_Region)&    theRegion ) const;
323
324   /**
325    * Returns altitudes for given points on given zone.
326    * \param thePoints the points to examine
327    * \param theZone reference zone to check
328    * \return result altitude value
329    */
330   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
331     const NCollection_Sequence<gp_XY>& thePoints,
332     const Handle(HYDROData_Zone)&      theZone ) const;
333
334   /**
335    * Returns region to which the point is belongs.
336    * \param thePoint the point to examine
337    * \return result region
338    */
339   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
340
341   /**
342    * Returns zone to which the point is belongs.
343    * \param thePoint the point to examine
344    * \return result zone
345    */
346   HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
347
348   /**
349    * Returns classification of point for given zone.
350    * \param thePoint the point to examine
351    * \param theZone the zone to examine
352    * \return result classification
353    */
354   HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
355     const gp_XY&                  thePoint,
356     const Handle(HYDROData_Zone)& theZone ) const;
357
358   HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
359   HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
360
361   HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
362                                     const bool theIsSetToUpdate = true );
363   HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)&     theObject1,
364                                  HYDROData_PriorityType              thePriority,
365                                  const Handle(HYDROData_Entity)&     theObject2,
366                                  HYDROData_Zone::MergeAltitudesType  theMergeType,
367                                  HYDROData_CalculationCase::DataTag  theDataTag );
368   HYDRODATA_EXPORT bool GetRule( int theIndex, 
369                                  Handle(HYDROData_Entity)&           theObject1,
370                                  HYDROData_PriorityType&             thePriority,
371                                  Handle(HYDROData_Entity)&           theObject2,
372                                  HYDROData_Zone::MergeAltitudesType& theMergeType,
373                                  HYDROData_CalculationCase::DataTag& theDataTag ) const;
374
375   HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode );
376   HYDRODATA_EXPORT AssignmentMode GetAssignmentLandCoverMode() const;
377
378   HYDRODATA_EXPORT QString DumpRules() const;
379
380   HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
381
382 private:
383
384   /**
385    * Add new one region for calculation case.
386    * The new region is added into the list of reference regions.
387    */
388   Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
389                                          const QString& thePrefixOrName,
390                                          bool isPrefix = true );
391
392   /**
393    * Add new one splitted edges group for calculation case.
394    */
395   Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
396
397   /**
398    * Exports the given faces as shell and the given groups to GEOM module.
399    * \param theGeomEngine GEOM module engine
400    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
401    * \param theFaces the list of faces to make shell 
402    * \param theSplittedGroups the list of groups
403    * \return true in case of success
404    */
405   bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
406                SALOMEDS::Study_ptr                           theStudy,
407                const TopTools_ListOfShape&                   theFaces,
408                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
409                QString& theGeomObjEntry ) const;
410   
411   void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
412                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
413   void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
414                           const HYDROData_SplitToZonesTool::SplitDataList& theZones );
415
416   void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
417                             const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
418
419   void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
420
421   void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
422
423 protected:
424   friend class HYDROData_Iterator;
425
426   /**
427    * Creates new object in the internal data structure. Use higher level objects 
428    * to create objects with real content.
429    */
430   HYDRODATA_EXPORT HYDROData_CalculationCase();
431
432   /**
433    * Destructs properties of the object and object itself, removes it from the document.
434    */
435   HYDRODATA_EXPORT ~HYDROData_CalculationCase();
436
437   void DumpSampleMeshing( QStringList& theScript,
438                           const QString& theStudyName,
439                           const QString& theGeomShapeName,
440                           const QString& theMeshName ) const;
441
442 private:
443   HYDROData_Warning myLastWarning;
444 };
445
446 #endif