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