Salome HOME
Merge remote-tracking branch 'origin/BR_quadtree' into V7_dev
[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 ) const
403   [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Region& )];
404   %MethodCode
405
406     NCollection_Sequence<gp_XY> aPnts;
407
408     int aLen = qMin( a0->Length(), a1->Length() );
409     for ( int i = 1; i <= aLen; ++i )
410     {
411       gp_XY aPnt( a0->Value( i ), a1->Value( i ) );
412       aPnts.Append( aPnt );
413     }
414
415     Handle(HYDROData_Region) aRefRegion =
416       Handle(HYDROData_Region)::DownCast( createHandle( a2 ) );
417
418     NCollection_Sequence<double> aRes;
419     Py_BEGIN_ALLOW_THREADS
420     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefRegion ) : 
421                            sipCpp->GetAltitudesForPoints( aPnts, aRefRegion );
422     Py_END_ALLOW_THREADS
423     
424     sipRes = new NCollection_Sequence<double>( aRes );
425   %End
426
427   /**
428    * Returns altitudes for given points on given zone.
429    * \param thePoints the points to examine
430    * \param theZone reference zone to check
431    * \return result altitude value
432    */
433   NCollection_Sequence<double> GetAltitudesForPoints( const NCollection_Sequence<double>& theCoordsX,
434                                                       const NCollection_Sequence<double>& theCoordsY,
435                                                       HYDROData_Zone                      theZone ) const
436   [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Zone& )];
437   %MethodCode
438
439     NCollection_Sequence<gp_XY> aPnts;
440
441     int aLen = qMin( a0->Length(), a1->Length() );
442     for ( int i = 1; i <= aLen; ++i )
443     {
444       gp_XY aPnt( a0->Value( i ), a1->Value( i ) );
445       aPnts.Append( aPnt );
446     }
447
448     Handle(HYDROData_Zone) aRefZone =
449       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
450
451     NCollection_Sequence<double> aRes;
452     Py_BEGIN_ALLOW_THREADS
453     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefZone ) : 
454                            sipCpp->GetAltitudesForPoints( aPnts, aRefZone );
455     Py_END_ALLOW_THREADS
456     
457     sipRes = new NCollection_Sequence<double>( aRes );
458   %End
459   
460   /**
461    * Returns region to which the point is belongs.
462    * \param thePoint the point to examine
463    * \return result region
464    */
465   HYDROData_Region GetRegionFromPoint( const double theCoordX,
466                                        const double theCoordY ) const
467   [Handle_HYDROData_Region ( const gp_XY& )];
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 ) : 
475                            sipCpp->GetRegionFromPoint( aPnt );
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 ) const
488   [Handle_HYDROData_Zone ( const gp_XY& )];
489   %MethodCode
490     Handle(HYDROData_Zone) aRes;
491     
492     gp_XY aPnt( a0, a1 );
493   
494     Py_BEGIN_ALLOW_THREADS
495     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetZoneFromPoint( aPnt ) : 
496                            sipCpp->GetZoneFromPoint( aPnt );
497     Py_END_ALLOW_THREADS
498     
499     sipRes = (HYDROData_Zone*)createPointer( aRes );
500   %End
501
502   /**
503    * Returns classification of point for given zone.
504    * \param thePoint the point to examine
505    * \param theZone the zone to examine
506    * \return result classification
507    */
508   PointClassification GetPointClassification( const double theCoordX,
509                                               const double theCoordY,
510                                               HYDROData_Zone theZone ) const 
511   [PointClassification ( const gp_XY&, const Handle_HYDROData_Zone& )];    
512   %MethodCode
513     gp_XY aPnt( a0, a1 );
514
515     Handle(HYDROData_Zone) aRef =
516       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
517
518     Py_BEGIN_ALLOW_THREADS
519     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetPointClassification( aPnt, aRef ) : 
520                              sipCpp->GetPointClassification( aPnt, aRef );
521     Py_END_ALLOW_THREADS
522   %End
523
524
525   void ClearRules( HYDROData_CalculationCase::DataTag theDataTag );
526
527   void AddRule( HYDROData_Entity                   theObject1,
528                 HYDROData_PriorityType             thePriority,
529                 HYDROData_Entity                   theObject2,
530                 HYDROData_Zone::MergeType          theMergeType,
531                                 HYDROData_CalculationCase::DataTag theDataTag )
532   [void ( const Handle_HYDROData_Entity&, HYDROData_PriorityType, const Handle_HYDROData_Entity&, HYDROData_Zone::MergeType, HYDROData_CalculationCase::DataTag )];
533   %MethodCode
534     Handle(HYDROData_Entity) anObject1 =
535       Handle(HYDROData_Entity)::DownCast( createHandle( a0 ) );
536     Handle(HYDROData_Entity) anObject2 =
537       Handle(HYDROData_Entity)::DownCast( createHandle( a2 ) );
538
539     Py_BEGIN_ALLOW_THREADS
540     sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRule( anObject1, a1, anObject2, a3, a4 ) : 
541                     sipCpp->AddRule( anObject1, a1, anObject2, a3, a4 );
542     Py_END_ALLOW_THREADS
543   %End
544
545   QString DumpRules();
546
547   void SetAssignmentMode( AssignmentMode theMode );
548   AssignmentMode GetAssignmentMode() const;
549
550 protected:
551
552   /**
553    * Creates new object in the internal data structure. Use higher level objects 
554    * to create objects with real content.
555    */
556   HYDROData_CalculationCase();
557
558   /**
559    * Destructs properties of the object and object itself, removes it from the document.
560    */
561   ~HYDROData_CalculationCase();
562 };
563
564