Salome HOME
Merge branch 'BR_LAND_COVER_MAP' into BR_DBF_SUPPORT
[modules/hydro.git] / src / HYDROPy / HYDROData_CalculationCase.sip
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 %ExportedHeaderCode
20 #include <HYDROData_CalculationCase.h>
21 #include <HYDROData_PriorityQueue.h>
22 %End
23
24 enum HYDROData_PriorityType
25 {
26   LESS,
27   GREATER,
28 };
29
30 class HYDROData_CalculationCase : public HYDROData_Entity
31 {
32
33 %TypeHeaderCode
34 #include <HYDROData_CalculationCase.h>
35 %End
36
37 %ConvertToSubClassCode
38     switch ( sipCpp->GetKind() )
39     {
40       case KIND_CALCULATION:
41         sipClass = sipClass_HYDROData_CalculationCase;
42         break;
43
44       default:
45         // We don't recognise the type.
46         sipClass = NULL;
47     }
48 %End
49
50 public:
51
52   enum PointClassification
53   {
54     POINT_OUT,  ///< point is out of zone face
55     POINT_IN,   ///< point is inside of zone face
56     POINT_ON    ///< point is on the edge of zone face
57   };
58
59   enum AssignmentMode
60   {
61     MANUAL = 0,
62     AUTOMATIC,
63   };
64
65 public:
66
67   enum DataTag
68   {
69     DataTag_First = 100,               ///< first tag, to reserve
70     DataTag_GeometryObject,            ///< reference geometry objects
71     DataTag_ChildRegion,               ///< child regions
72     DataTag_Region,                    ///< reference regions
73     DataTag_Polyline,                  ///< reference boundary polyline
74     DataTag_GeometryGroup,             ///< reference geometry groups
75     DataTag_SplittedGroups,            ///< reference splitted groups
76     DataTag_CustomRules,               ///< custom rules
77     DataTag_AssignmentMode,            ///< assignment mode
78     DataTag_StricklerTable,            ///< reference Strickler table
79     DataTag_LandCover,                 ///< reference land covers
80     DataTag_CustomLandCoverRules,      ///< custom rules for land covers priority
81     DataTag_AssignmentLandCoverMode,   ///< assignment mode of land covers priority
82         DataTag_ChildLandCoverRegion,      ///< child land cover regions
83     DataTag_LandCoverRegion            ///< reference land cover regions
84   };
85
86 public:      
87   /**
88    * Add new one reference geometry object for calculation case.
89    */
90   bool AddGeometryObject( HYDROData_Object theObject ) [bool ( const Handle_HYDROData_Object& )];
91   %MethodCode
92     Handle(HYDROData_Object) aRef =
93       Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
94     if ( !aRef.IsNull() )
95     {
96       Py_BEGIN_ALLOW_THREADS
97       sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddGeometryObject( aRef ):
98                                sipCpp->AddGeometryObject( aRef );
99       Py_END_ALLOW_THREADS
100     }
101   %End
102
103   /**
104    * Returns all reference geometry objects of calculation case.
105    */
106   HYDROData_SequenceOfObjects GetGeometryObjects() const;
107
108   /**
109    * Removes reference geometry object from calculation case.
110    */
111   void RemoveGeometryObject( HYDROData_Object theObject ) [void ( const Handle_HYDROData_Object& )];
112   %MethodCode
113     Handle(HYDROData_Object) aRef =
114       Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
115     if ( !aRef.IsNull() )
116     {
117       Py_BEGIN_ALLOW_THREADS
118       if ( sipSelfWasArg ) {
119         sipCpp->HYDROData_CalculationCase::RemoveGeometryObject( aRef );
120       } else {
121         sipCpp->RemoveGeometryObject( aRef );
122       }
123       Py_END_ALLOW_THREADS
124     }
125   %End
126
127   /**
128    * Removes all reference geometry objects from calculation case.
129    */
130   void RemoveGeometryObjects();
131
132
133   /**
134    * Add new one reference geometry group for calculation case.
135    */
136   bool AddGeometryGroup( HYDROData_ShapesGroup theGroup ) [bool ( const Handle_HYDROData_ShapesGroup& )];
137   %MethodCode
138     Handle(HYDROData_ShapesGroup) aRef =
139       Handle(HYDROData_ShapesGroup)::DownCast( createHandle( a0 ) );
140     if ( !aRef.IsNull() )
141     {
142       Py_BEGIN_ALLOW_THREADS
143       sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddGeometryGroup( aRef ):
144                                sipCpp->AddGeometryGroup( aRef );
145       Py_END_ALLOW_THREADS
146     }
147   %End
148
149   /**
150    * Returns all reference geometry groups of calculation case.
151    */
152   HYDROData_SequenceOfObjects GetGeometryGroups() const;
153
154   /**
155    * Removes reference geometry group from calculation case.
156    */
157   void RemoveGeometryGroup( HYDROData_ShapesGroup theGroup ) [void ( const Handle_HYDROData_ShapesGroup& )];
158   %MethodCode
159     Handle(HYDROData_ShapesGroup) aRef =
160       Handle(HYDROData_ShapesGroup)::DownCast( createHandle( a0 ) );
161     if ( !aRef.IsNull() )
162     {
163       Py_BEGIN_ALLOW_THREADS
164       if ( sipSelfWasArg ) {
165         sipCpp->HYDROData_CalculationCase::RemoveGeometryGroup( aRef );
166       } else {
167         sipCpp->RemoveGeometryGroup( aRef );
168       }
169       Py_END_ALLOW_THREADS
170     }
171   %End
172
173   /**
174    * Removes all reference geometry groups from calculation case.
175    */
176   void RemoveGeometryGroups();
177
178
179   /**
180    * Sets reference boundary polyline object for calculation case.
181    */
182   void SetBoundaryPolyline( HYDROData_PolylineXY thePolyline ) [void ( const Handle_HYDROData_PolylineXY& )];
183   %MethodCode
184     Handle(HYDROData_PolylineXY) aRef =
185       Handle(HYDROData_PolylineXY)::DownCast( createHandle( a0 ) );
186     if ( !aRef.IsNull() )
187     {
188       Py_BEGIN_ALLOW_THREADS
189       if ( sipSelfWasArg ) {
190         sipCpp->HYDROData_CalculationCase::SetBoundaryPolyline( aRef );
191       } else {
192         sipCpp->SetBoundaryPolyline( aRef );
193       }
194       Py_END_ALLOW_THREADS
195     }
196   %End
197
198   /**
199    * Returns reference boundary polyline object of calculation case.
200    */
201   HYDROData_PolylineXY GetBoundaryPolyline() const [Handle_HYDROData_PolylineXY ()];
202   %MethodCode
203     Handle(HYDROData_PolylineXY) aRef;
204     
205     Py_BEGIN_ALLOW_THREADS
206     aRef = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetBoundaryPolyline() : 
207                            sipCpp->GetBoundaryPolyline();
208     Py_END_ALLOW_THREADS
209     
210     sipRes = (HYDROData_PolylineXY*)createPointer( aRef );
211   %End
212
213   /**
214    * Remove reference boundary polyline object from calculation case.
215    */
216   void RemoveBoundaryPolyline();
217
218
219   /**
220    * Add new one child region for calculation case.
221    * The new region is added into the list of reference regions.
222    * The label of theZone is changed during this operation
223    * because of new region becomes the new parent for this zone.
224    */
225   HYDROData_Region AddNewRegion( HYDROData_Zone theZone, const bool theLandCover ) [Handle_HYDROData_Region ( const Handle_HYDROData_Zone&, const bool )];
226   %MethodCode
227     Handle(HYDROData_Zone) aRef =
228       Handle(HYDROData_Zone)::DownCast( createHandle( a0 ) );
229     Handle(HYDROData_Region) aRes;
230     
231     if ( !aRef.IsNull() )
232     {
233       Py_BEGIN_ALLOW_THREADS
234       aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddNewRegion( aRef, a1 ) : 
235                              sipCpp->AddNewRegion( aRef, a1 );
236       Py_END_ALLOW_THREADS
237     }
238     
239     sipRes = (HYDROData_Region*)createPointer( aRes );
240   %End
241
242   /**
243    * Add new one reference region for calculation case.
244    * The label of theRegion is changed in case if old parent is not this calculation.
245    */
246   bool AddRegion( HYDROData_Region theRegion, const bool theLandCover ) [bool ( const Handle_HYDROData_Region&, const bool )];
247   %MethodCode
248     Handle(HYDROData_Region) aRef =
249       Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
250     if ( !aRef.IsNull() )
251     {
252       Py_BEGIN_ALLOW_THREADS
253       sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRegion( aRef, a1 ):
254                                sipCpp->AddRegion( aRef, a1 );
255       Py_END_ALLOW_THREADS
256     }
257   %End
258
259   /**
260    * Returns all reference regions of calculation case.
261    */
262   HYDROData_SequenceOfObjects GetRegions( const bool theLandCover ) const;
263
264   /**
265    * Updates names of regions to correct order.
266    */
267   void UpdateRegionsOrder();
268
269   /**
270    * Removes reference region from calculation case.
271    */
272   void RemoveRegion( HYDROData_Region theRegion, const bool theLandCover ) [void ( const Handle_HYDROData_Region&, const bool )];
273   %MethodCode
274     Handle(HYDROData_Region) aRef =
275       Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
276     if ( !aRef.IsNull() )
277     {
278       Py_BEGIN_ALLOW_THREADS
279       if ( sipSelfWasArg ) {
280         sipCpp->HYDROData_CalculationCase::RemoveRegion( aRef, a1 );
281       } else {
282         sipCpp->RemoveRegion( aRef, a1 );
283       }
284       Py_END_ALLOW_THREADS
285     }
286   %End
287
288   /**
289    * Removes all reference regions from calculation case.
290    */
291   void RemoveRegions( const bool theLandCover );
292
293   
294   /**
295    * Returns all reference geometry groups of calculation case.
296    */
297   HYDROData_SequenceOfObjects GetSplittedGroups() const;
298
299   /**
300    * Removes all reference geometry groups from calculation case.
301    */
302   void RemoveSplittedGroups();
303
304
305   /**
306    * Exports the calculation case data (shell and groups) to GEOM module.
307    * \param theGeomEngine GEOM module engine
308    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
309    * \return true in case of success
310    */
311 //TODO:  virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
312 //                       SALOMEDS::Study_ptr theStudy );
313         
314         QString Export( int theStudyId ) const;
315
316 public:      
317   // Public methods to work with Calculation services
318
319   /**
320    * Returns strickler coefficient for given point.
321    * \param thePoint the point to examine
322    * \return result strickler coefficient
323    */
324   double GetStricklerCoefficientForPoint( const double theCoordX,
325                                           const double theCoordY ) const [double ( const gp_XY& ) ];
326   %MethodCode
327     gp_XY aPnt( a0, a1 );
328   
329     Py_BEGIN_ALLOW_THREADS
330     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetStricklerCoefficientForPoint( aPnt ) : 
331                              sipCpp->GetStricklerCoefficientForPoint( aPnt );
332     Py_END_ALLOW_THREADS
333   %End
334
335   /**
336    * Returns altitude for given point.
337    * \param thePoint the point to examine
338    * \return result altitude value
339    */
340   double GetAltitudeForPoint( const double theCoordX,
341                               const double theCoordY ) const [double ( const gp_XY& )];
342   %MethodCode
343     gp_XY aPnt( a0, a1 );
344   
345     Py_BEGIN_ALLOW_THREADS
346     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudeForPoint( aPnt ) : 
347                              sipCpp->GetAltitudeForPoint( aPnt );
348     Py_END_ALLOW_THREADS
349   %End
350
351   /**
352    * Returns altitude for given point on given region.
353    * \param thePoint the point to examine
354    * \param theRegion reference region to check
355    * \return result altitude value
356    */
357   double GetAltitudeForPoint( const double     theCoordX,
358                               const double     theCoordY,
359                               HYDROData_Region theRegion ) const
360   [double ( const gp_XY&, const Handle_HYDROData_Region& )];
361   %MethodCode
362     gp_XY aPnt( a0, a1 );
363     Handle(HYDROData_Region) aRefRegion =
364       Handle(HYDROData_Region)::DownCast( createHandle( a2 ) );
365
366     Py_BEGIN_ALLOW_THREADS
367     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudeForPoint( aPnt, aRefRegion ) : 
368                              sipCpp->GetAltitudeForPoint( aPnt, aRefRegion );
369     Py_END_ALLOW_THREADS
370   %End
371
372   /**
373    * Returns altitude for given point on given zone.
374    * \param thePoint the point to examine
375    * \param theZone reference zone to check
376    * \return result altitude value
377    */
378   double GetAltitudeForPoint( const double theCoordX,
379                               const double theCoordY,
380                               HYDROData_Zone theZone ) const
381   [double ( const gp_XY&, const Handle_HYDROData_Zone& )];
382   %MethodCode
383     gp_XY aPnt( a0, a1 );
384     Handle(HYDROData_Zone) aRefZone =
385       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
386
387     Py_BEGIN_ALLOW_THREADS
388     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudeForPoint( aPnt, aRefZone ) : 
389                              sipCpp->GetAltitudeForPoint( aPnt, aRefZone );
390     Py_END_ALLOW_THREADS
391   %End
392
393   /**
394    * Returns altitudes for given points on given region.
395    * \param thePoints the points to examine
396    * \param theZone reference region to check
397    * \return result altitude value
398    */
399   NCollection_Sequence<double> GetAltitudesForPoints( const NCollection_Sequence<double>& theCoordsX,
400                                                       const NCollection_Sequence<double>& theCoordsY,
401                                                       HYDROData_Region                    theRegion ) const
402   [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Region& )];
403   %MethodCode
404
405     NCollection_Sequence<gp_XY> aPnts;
406
407     int aLen = qMin( a0->Length(), a1->Length() );
408     for ( int i = 1; i <= aLen; ++i )
409     {
410       gp_XY aPnt( a0->Value( i ), a1->Value( i ) );
411       aPnts.Append( aPnt );
412     }
413
414     Handle(HYDROData_Region) aRefRegion =
415       Handle(HYDROData_Region)::DownCast( createHandle( a2 ) );
416
417     NCollection_Sequence<double> aRes;
418     Py_BEGIN_ALLOW_THREADS
419     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefRegion ) : 
420                            sipCpp->GetAltitudesForPoints( aPnts, aRefRegion );
421     Py_END_ALLOW_THREADS
422     
423     sipRes = new NCollection_Sequence<double>( aRes );
424   %End
425
426   /**
427    * Returns altitudes for given points on given zone.
428    * \param thePoints the points to examine
429    * \param theZone reference zone to check
430    * \return result altitude value
431    */
432   NCollection_Sequence<double> GetAltitudesForPoints( const NCollection_Sequence<double>& theCoordsX,
433                                                       const NCollection_Sequence<double>& theCoordsY,
434                                                       HYDROData_Zone                      theZone ) const
435   [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Zone& )];
436   %MethodCode
437
438     NCollection_Sequence<gp_XY> aPnts;
439
440     int aLen = qMin( a0->Length(), a1->Length() );
441     for ( int i = 1; i <= aLen; ++i )
442     {
443       gp_XY aPnt( a0->Value( i ), a1->Value( i ) );
444       aPnts.Append( aPnt );
445     }
446
447     Handle(HYDROData_Zone) aRefZone =
448       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
449
450     NCollection_Sequence<double> aRes;
451     Py_BEGIN_ALLOW_THREADS
452     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefZone ) : 
453                            sipCpp->GetAltitudesForPoints( aPnts, aRefZone );
454     Py_END_ALLOW_THREADS
455     
456     sipRes = new NCollection_Sequence<double>( aRes );
457   %End
458   
459   /**
460    * Returns region to which the point is belongs.
461    * \param thePoint the point to examine
462    * \return result region
463    */
464   HYDROData_Region GetRegionFromPoint( const double theCoordX,
465                                        const double theCoordY,
466                                                                            const bool theLandCover ) const
467   [Handle_HYDROData_Region ( const gp_XY&, const bool )];
468   %MethodCode
469     Handle(HYDROData_Region) aRes;
470     
471     gp_XY aPnt( a0, a1 );
472   
473     Py_BEGIN_ALLOW_THREADS
474     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetRegionFromPoint( aPnt, a2 ) : 
475                            sipCpp->GetRegionFromPoint( aPnt, a2 );
476     Py_END_ALLOW_THREADS
477     
478     sipRes = (HYDROData_Region*)createPointer( aRes );
479   %End
480
481   /**
482    * Returns zone to which the point is belongs.
483    * \param thePoint the point to examine
484    * \return result zone
485    */
486   HYDROData_Zone GetZoneFromPoint( const double theCoordX,
487                                    const double theCoordY,
488                                                                    const bool theLandCover ) const
489   [Handle_HYDROData_Zone ( const gp_XY&, const bool )];
490   %MethodCode
491     Handle(HYDROData_Zone) aRes;
492     
493     gp_XY aPnt( a0, a1 );
494   
495     Py_BEGIN_ALLOW_THREADS
496     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetZoneFromPoint( aPnt, a2 ) : 
497                            sipCpp->GetZoneFromPoint( aPnt, a2 );
498     Py_END_ALLOW_THREADS
499     
500     sipRes = (HYDROData_Zone*)createPointer( aRes );
501   %End
502
503   /**
504    * Returns classification of point for given zone.
505    * \param thePoint the point to examine
506    * \param theZone the zone to examine
507    * \return result classification
508    */
509   PointClassification GetPointClassification( const double theCoordX,
510                                               const double theCoordY,
511                                               HYDROData_Zone theZone ) const 
512   [PointClassification ( const gp_XY&, const Handle_HYDROData_Zone& )];    
513   %MethodCode
514     gp_XY aPnt( a0, a1 );
515
516     Handle(HYDROData_Zone) aRef =
517       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
518
519     Py_BEGIN_ALLOW_THREADS
520     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetPointClassification( aPnt, aRef ) : 
521                              sipCpp->GetPointClassification( aPnt, aRef );
522     Py_END_ALLOW_THREADS
523   %End
524
525
526   void ClearRules( HYDROData_CalculationCase::DataTag theDataTag );
527
528   void AddRule( HYDROData_Entity                   theObject1,
529                 HYDROData_PriorityType             thePriority,
530                 HYDROData_Entity                   theObject2,
531                 HYDROData_Zone::MergeType          theMergeType,
532                                 HYDROData_CalculationCase::DataTag theDataTag )
533   [void ( const Handle_HYDROData_Entity&, HYDROData_PriorityType, const Handle_HYDROData_Entity&, HYDROData_Zone::MergeType, HYDROData_CalculationCase::DataTag )];
534   %MethodCode
535     Handle(HYDROData_Entity) anObject1 =
536       Handle(HYDROData_Entity)::DownCast( createHandle( a0 ) );
537     Handle(HYDROData_Entity) anObject2 =
538       Handle(HYDROData_Entity)::DownCast( createHandle( a2 ) );
539
540     Py_BEGIN_ALLOW_THREADS
541     sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRule( anObject1, a1, anObject2, a3, a4 ) : 
542                     sipCpp->AddRule( anObject1, a1, anObject2, a3, a4 );
543     Py_END_ALLOW_THREADS
544   %End
545
546   QString DumpRules();
547   QString DumpLandCoverRules();
548
549   void SetAssignmentMode( AssignmentMode theMode );
550   AssignmentMode GetAssignmentMode() const;
551
552   void SetAssignmentLandCoverMode( AssignmentMode theMode );
553   AssignmentMode GetAssignmentLandCoverMode() const;
554
555 protected:
556
557   /**
558    * Creates new object in the internal data structure. Use higher level objects 
559    * to create objects with real content.
560    */
561   HYDROData_CalculationCase();
562
563   /**
564    * Destructs properties of the object and object itself, removes it from the document.
565    */
566   ~HYDROData_CalculationCase();
567 };
568
569