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