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