]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_CalculationCase.h
Salome HOME
af03f9518a787a415296d1f9b3f8bac641ba69a4
[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 #ifdef WIN32
29   #pragma warning ( disable: 4251 )
30 #endif
31
32 #ifndef LIGHT_MODE
33 // IDL includes
34 #include <SALOMEconfig.h>
35 #include CORBA_SERVER_HEADER(GEOM_Gen)
36 #endif
37
38 #ifdef WIN32
39   #pragma warning( default: 4251 )
40 #endif
41
42 class gp_XY;
43
44 class TopoDS_Shape;
45 class TopoDS_Shell;
46
47 class HYDROData_Object;
48 class HYDROData_Region;
49 class HYDROData_Zone;
50 class HYDROData_PolylineXY;
51 class HYDROData_ShapesGroup;
52 class HYDROData_SplitShapesGroup;
53 class HYDROData_Document;
54 class HYDROData_StricklerTable;
55 class HYDROData_LandCoverMap;
56
57 /**\class HYDROData_CalculationCase
58  * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
59  *
60  */
61 class HYDROData_CalculationCase : public HYDROData_Entity
62 {
63 public:
64
65   enum PointClassification
66   {
67     POINT_OUT,  ///< point is out of zone face
68     POINT_IN,   ///< point is inside of zone face
69     POINT_ON    ///< point is on the edge of zone face
70   };
71
72   enum AssignmentMode
73   {
74     MANUAL = 0,
75     AUTOMATIC,
76   };
77
78 public:
79
80   /**
81    * Enumeration of tags corresponding to the persistent object parameters.
82    */
83   enum DataTag
84   {
85     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
86     DataTag_GeometryObject,            ///< reference geometry objects
87     DataTag_ChildRegion,               ///< child regions
88     DataTag_Region,                    ///< reference regions
89     DataTag_Polyline,                  ///< reference boundary polyline
90     DataTag_GeometryGroup,             ///< reference geometry groups
91     DataTag_SplitGroups,               ///< reference split groups
92     DataTag_CustomRules,               ///< custom rules
93     DataTag_AssignmentMode,            ///< assignment mode
94     DataTag_StricklerTable,            ///< reference Strickler table
95
96     DataTag_LandCover_Obsolete,                 ///< reference land covers
97     DataTag_CustomLandCoverRules_Obsolete,      ///< custom rules for land covers priority
98     DataTag_AssignmentLandCoverMode_Obsolete,   ///< assignment mode of land covers priority
99     DataTag_ChildLandCoverRegion_Obsolete,      ///< child land cover regions
100     DataTag_LandCoverRegion_Obsolete,           ///< reference land cover regions
101
102     DataTag_LandCoverMap,              ///< reference to land cover map
103   };
104
105 public:
106   DEFINE_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity);
107
108   /**
109    * Returns the kind of this object. Must be redefined in all objects of known type.
110    */
111   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
112
113   /**
114    * Updates the name of this object.
115    * Reimplemented to update the names of regions, zones and split groups.
116    */
117   HYDRODATA_EXPORT virtual void SetName( const QString& theName );  
118
119   /**
120    * Dump Calculation object to Python script representation.
121    */
122   HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
123                                                      MapOfTreatedObjects& theTreatedObjects ) const;
124
125   /**
126    * Update the calcualtion case object.
127    * Call this method whenever you made changes for object data.
128    */
129   HYDRODATA_EXPORT virtual void Update();
130
131   /**
132    * Returns the list of all reference objects of this object.
133    */
134   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
135
136 public:      
137   // Public methods to work with Calculation
138
139   /**
140    * Add new one reference geometry object for calculation case.
141    */
142   HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
143
144   /**
145    * Returns all reference geometry objects of calculation case.
146    */
147   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
148
149   /**
150    * Removes reference geometry object from calculation case.
151    * \param theObject the object to remove
152    */
153   HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
154
155   /**
156    * Removes all reference geometry objects from calculation case.
157    */
158   HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
159
160
161   /**
162    * Add new one reference geometry group for calculation case.
163    * \param theGroup the group to add
164    */
165   HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
166
167   /**
168    * Returns all reference geometry groups of calculation case.
169    */
170   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
171
172   /**
173    * Removes reference geometry group from calculation case.
174    * \param theGroup the group to remove
175    */
176   HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
177
178   /**
179    * Removes all reference geometry groups from calculation case.
180    */
181   HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
182
183
184   /**
185    * Sets reference boundary polyline object for calculation case.
186    */
187   HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
188
189   /**
190    * Returns reference boundary polyline object of calculation case.
191    */
192   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
193
194   /**
195    * Remove reference boundary polyline object from calculation case.
196    */
197   HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
198
199
200   /**
201    * Sets reference Strickler table for calculation case.
202    */
203   HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
204
205   /**
206    * Returns reference Strickler table of calculation case.
207    */
208   HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
209
210   /**
211    * Remove reference Strickler table from calculation case.
212    */
213   HYDRODATA_EXPORT virtual void RemoveStricklerTable();
214
215   /**
216    * Returns reference Land Cover Map of calculation case.
217    * \return the referenced Land Cover Map
218    */
219   HYDRODATA_EXPORT Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
220
221   HYDRODATA_EXPORT void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
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    * \return the created region
229    */
230   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone ); 
231
232
233   /**
234    * Add new one reference region for calculation case.
235    * The label of theRegion is changed in case if old parent is not this calculation.
236    * \return true in case of success
237    */
238   HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
239
240   /**
241    * Returns all reference regions of calculation case.
242    * \return the list of reference regions
243    */
244   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
245
246   /**
247    * Updates names of regions to correct order.
248    */
249   HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
250
251   /**
252    * Removes reference region from calculation case.
253    * \param theRegion the region to remove
254    */
255   HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion ); 
256
257   /**
258    * Removes all reference regions from calculation case.
259    */
260   HYDRODATA_EXPORT virtual void RemoveRegions();
261
262   /**
263    * Returns all reference geometry groups of calculation case.
264    */
265   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplitGroups() const;
266
267   /**
268    * Removes all reference geometry groups from calculation case.
269    */
270   HYDRODATA_EXPORT virtual void RemoveSplitGroups();
271
272   /**
273    * Exports the calculation case data (shell and groups) to GEOM module.
274    * \param theStudyId the id of the study where the GEOM module should be used for export
275    * \return the entry of the GEOM object (empty string in the case of error)
276    */
277   HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
278
279   /**
280    * Exports the calculation case data (shell and groups) to GEOM module.
281    * \param theGeomEngine GEOM module engine
282    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
283    * \param theGeomObjEntry the published GEOM object entry
284    * \param theErrorMsg the error message
285    * \return true in case of success
286    */
287 #ifndef LIGHT_MODE
288   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
289                                         SALOMEDS::Study_ptr theStudy,
290                                         QString& theGeomObjEntry,
291                                         QString& theErrorMsg ) const;
292 #endif
293
294 public:      
295   // Public methods to work with Calculation services
296
297   /**
298    * Returns altitude for given point.
299    * \param thePoint the point to examine
300    * \return result altitude value
301    */
302   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
303
304   /**
305    * Returns altitude for given point on given region.
306    * \param thePoint the point to examine
307    * \param theRegion reference region to check
308    * \return result altitude value
309    */
310   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                    thePoint,
311                                                        const Handle(HYDROData_Region)& theRegion,
312                                                        int theMethod = 0) const;
313
314   /**
315    * Returns altitude for given point on given zone.
316    * \param thePoint the point to examine
317    * \param theZone reference zone to check
318    * \return result altitude value
319    */
320   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
321                                                        const Handle(HYDROData_Zone)& theZone,
322                                                        int theMethod = 0) const;
323
324   /**
325    * Returns strickler coefficient for given point.
326    * \param thePoint the point to examine
327    * \return result strickler coefficient
328    */
329   HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
330
331   /**
332    * Returns altitudes for given points on given region.
333    * \param thePoints the points to examine
334    * \param theRegion reference region to check
335    * \return result altitude value
336    */
337   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
338     const NCollection_Sequence<gp_XY>& thePoints,
339     const Handle(HYDROData_Region)&    theRegion,
340     int theMethod = 0) const;
341
342   /**
343    * Returns altitudes for given points on given zone.
344    * \param thePoints the points to examine
345    * \param theZone reference zone to check
346    * \return result altitude value
347    */
348   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
349     const NCollection_Sequence<gp_XY>& thePoints,
350     const Handle(HYDROData_Zone)&      theZone,
351     int theMethod = 0) const;
352
353   /**
354    * Returns region to which the point is belongs.
355    * \param thePoint the point to examine
356    * if it is needed to search Land Cover region
357    * \return result region
358    */
359   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
360
361   /**
362    * Returns zone to which the point is belongs.
363    * \param thePoint the point to examine
364    * if it is needed to search Land Cover zone
365    * \return result zone
366    */
367   HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
368
369   /**
370    * Returns classification of point for given zone.
371    * \param thePoint the point to examine
372    * \param theZone the zone to examine
373    * \return result classification
374    */
375   HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
376     const gp_XY&                  thePoint,
377     const Handle(HYDROData_Zone)& theZone ) const;
378
379   HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
380   HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
381
382   HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
383                                     const bool theIsSetToUpdate = true );
384   HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)&     theObject1,
385                                  HYDROData_PriorityType              thePriority,
386                                  const Handle(HYDROData_Entity)&     theObject2,
387                                  HYDROData_Zone::MergeType theMergeType,
388                                  HYDROData_CalculationCase::DataTag  theDataTag );
389   HYDRODATA_EXPORT bool GetRule( int theIndex, 
390                                  Handle(HYDROData_Entity)&           theObject1,
391                                  HYDROData_PriorityType&             thePriority,
392                                  Handle(HYDROData_Entity)&           theObject2,
393                                  HYDROData_Zone::MergeType& theMergeType,
394                                  HYDROData_CalculationCase::DataTag& theDataTag ) const;
395
396   HYDRODATA_EXPORT QString DumpRules() const;
397
398   HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
399
400 private:
401
402   /**
403    * Add new one region for calculation case.
404    * The new region is added into the list of reference regions.
405    */
406   Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
407                                          const QString& thePrefixOrName,
408                                          bool isPrefix = true );
409
410   /**
411    * Add new one split edges group for calculation case.
412    */
413   Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
414
415   /**
416    * Exports the given faces as shell and the given groups to GEOM module.
417    * \param theGeomEngine GEOM module engine
418    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
419    * \param theFaces the list of faces to make shell 
420    * \param theSplitGroups the list of groups
421    * \return true in case of success
422    */
423 #ifndef LIGHT_MODE
424   bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
425                SALOMEDS::Study_ptr                           theStudy,
426                const TopTools_ListOfShape&                   theFaces,
427                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
428                QString& theGeomObjEntry ) const;
429 #endif
430   
431   void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
432                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
433   void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
434                           const HYDROData_SplitToZonesTool::SplitDataList& theZones );
435
436   void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
437                             const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
438
439   void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
440
441   void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
442
443   void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
444                            const QString& theOldCaseName,
445                            const QString& theName );
446   
447   void DumpRegionsToPython( QStringList&                       theResList,
448                             const QString&                     thePyScriptPath,
449                             MapOfTreatedObjects&               theTreatedObjects,
450                             const HYDROData_SequenceOfObjects& theRegions ) const;
451
452 protected:
453   friend class HYDROData_Iterator;
454
455   /**
456    * Creates new object in the internal data structure. Use higher level objects 
457    * to create objects with real content.
458    */
459   HYDRODATA_EXPORT HYDROData_CalculationCase();
460
461   /**
462    * Destructs properties of the object and object itself, removes it from the document.
463    */
464   HYDRODATA_EXPORT ~HYDROData_CalculationCase();
465
466   void DumpSampleMeshing( QStringList& theScript,
467                           const QString& theStudyName,
468                           const QString& theGeomShapeName,
469                           const QString& theMeshName ) const;
470
471 private:
472   HYDROData_Warning myLastWarning;
473 };
474
475 #endif