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