Salome HOME
parametrization
[modules/hydro.git] / src / HYDROPy / HYDROData_CalculationCase.sip
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 %ExportedHeaderCode
24 #include <HYDROData_CalculationCase.h>
25 #include <HYDROData_PriorityQueue.h>
26 %End
27
28 enum HYDROData_PriorityType
29 {
30   LESS,
31   GREATER,
32 };
33
34 class HYDROData_CalculationCase : public HYDROData_Entity
35 {
36
37 %TypeHeaderCode
38 #include <HYDROData_CalculationCase.h>
39 %End
40
41 %ConvertToSubClassCode
42     switch ( sipCpp->GetKind() )
43     {
44       case KIND_CALCULATION:
45         sipClass = sipClass_HYDROData_CalculationCase;
46         break;
47
48       default:
49         // We don't recognise the type.
50         sipClass = NULL;
51     }
52 %End
53
54 public:
55
56   enum PointClassification
57   {
58     POINT_OUT,  ///< point is out of zone face
59     POINT_IN,   ///< point is inside of zone face
60     POINT_ON    ///< point is on the edge of zone face
61   };
62
63 public:      
64   /**
65    * Add new one reference geometry object for calculation case.
66    */
67   bool AddGeometryObject( HYDROData_Object theObject ) [bool ( const Handle_HYDROData_Object& )];
68   %MethodCode
69     Handle(HYDROData_Object) aRef =
70       Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
71     if ( !aRef.IsNull() )
72     {
73       Py_BEGIN_ALLOW_THREADS
74       sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddGeometryObject( aRef ):
75                                sipCpp->AddGeometryObject( aRef );
76       Py_END_ALLOW_THREADS
77     }
78   %End
79
80   /**
81    * Returns all reference geometry objects of calculation case.
82    */
83   HYDROData_SequenceOfObjects GetGeometryObjects() const;
84
85   /**
86    * Removes reference geometry object from calculation case.
87    */
88   void RemoveGeometryObject( HYDROData_Object theObject ) [void ( 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       if ( sipSelfWasArg ) {
96         sipCpp->HYDROData_CalculationCase::RemoveGeometryObject( aRef );
97       } else {
98         sipCpp->RemoveGeometryObject( aRef );
99       }
100       Py_END_ALLOW_THREADS
101     }
102   %End
103
104   /**
105    * Removes all reference geometry objects from calculation case.
106    */
107   void RemoveGeometryObjects();
108
109
110   /**
111    * Add new one reference geometry group for calculation case.
112    */
113   bool AddGeometryGroup( HYDROData_ShapesGroup theGroup ) [bool ( const Handle_HYDROData_ShapesGroup& )];
114   %MethodCode
115     Handle(HYDROData_ShapesGroup) aRef =
116       Handle(HYDROData_ShapesGroup)::DownCast( createHandle( a0 ) );
117     if ( !aRef.IsNull() )
118     {
119       Py_BEGIN_ALLOW_THREADS
120       sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddGeometryGroup( aRef ):
121                                sipCpp->AddGeometryGroup( aRef );
122       Py_END_ALLOW_THREADS
123     }
124   %End
125
126   /**
127    * Returns all reference geometry groups of calculation case.
128    */
129   HYDROData_SequenceOfObjects GetGeometryGroups() const;
130
131   /**
132    * Removes reference geometry group from calculation case.
133    */
134   void RemoveGeometryGroup( HYDROData_ShapesGroup theGroup ) [void ( 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       if ( sipSelfWasArg ) {
142         sipCpp->HYDROData_CalculationCase::RemoveGeometryGroup( aRef );
143       } else {
144         sipCpp->RemoveGeometryGroup( aRef );
145       }
146       Py_END_ALLOW_THREADS
147     }
148   %End
149
150   /**
151    * Removes all reference geometry groups from calculation case.
152    */
153   void RemoveGeometryGroups();
154
155
156   /**
157    * Sets reference boundary polyline object for calculation case.
158    */
159   void SetBoundaryPolyline( HYDROData_PolylineXY thePolyline ) [void ( const Handle_HYDROData_PolylineXY& )];
160   %MethodCode
161     Handle(HYDROData_PolylineXY) aRef =
162       Handle(HYDROData_PolylineXY)::DownCast( createHandle( a0 ) );
163     if ( !aRef.IsNull() )
164     {
165       Py_BEGIN_ALLOW_THREADS
166       if ( sipSelfWasArg ) {
167         sipCpp->HYDROData_CalculationCase::SetBoundaryPolyline( aRef );
168       } else {
169         sipCpp->SetBoundaryPolyline( aRef );
170       }
171       Py_END_ALLOW_THREADS
172     }
173   %End
174
175   /**
176    * Returns reference boundary polyline object of calculation case.
177    */
178   HYDROData_PolylineXY GetBoundaryPolyline() const [Handle_HYDROData_PolylineXY ()];
179   %MethodCode
180     Handle(HYDROData_PolylineXY) aRef;
181     
182     Py_BEGIN_ALLOW_THREADS
183     aRef = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetBoundaryPolyline() : 
184                            sipCpp->GetBoundaryPolyline();
185     Py_END_ALLOW_THREADS
186     
187     sipRes = (HYDROData_PolylineXY*)createPointer( aRef );
188   %End
189
190   /**
191    * Remove reference boundary polyline object from calculation case.
192    */
193   void RemoveBoundaryPolyline();
194
195
196   /**
197    * Add new one child region for calculation case.
198    * The new region is added into the list of reference regions.
199    * The label of theZone is changed during this operation
200    * because of new region becomes the new parent for this zone.
201    */
202   HYDROData_Region AddNewRegion( HYDROData_Zone theZone ) [Handle_HYDROData_Region ( const Handle_HYDROData_Zone& )];
203   %MethodCode
204     Handle(HYDROData_Zone) aRef =
205       Handle(HYDROData_Zone)::DownCast( createHandle( a0 ) );
206     Handle(HYDROData_Region) aRes;
207     
208     if ( !aRef.IsNull() )
209     {
210       Py_BEGIN_ALLOW_THREADS
211       aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddNewRegion( aRef ) : 
212                              sipCpp->AddNewRegion( aRef );
213       Py_END_ALLOW_THREADS
214     }
215     
216     sipRes = (HYDROData_Region*)createPointer( aRes );
217   %End
218
219   /**
220    * Add new one reference region for calculation case.
221    * The label of theRegion is changed in case if old parent is not this calculation.
222    */
223   bool AddRegion( HYDROData_Region theRegion ) [bool ( const Handle_HYDROData_Region& )];
224   %MethodCode
225     Handle(HYDROData_Region) aRef =
226       Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
227     if ( !aRef.IsNull() )
228     {
229       Py_BEGIN_ALLOW_THREADS
230       sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRegion( aRef ):
231                                sipCpp->AddRegion( aRef );
232       Py_END_ALLOW_THREADS
233     }
234   %End
235
236   /**
237    * Returns all reference regions of calculation case.
238    */
239   HYDROData_SequenceOfObjects GetRegions() const;
240
241   /**
242    * Updates names of regions to correct order.
243    */
244   void UpdateRegionsOrder();
245
246   /**
247    * Removes reference region from calculation case.
248    */
249   void RemoveRegion( HYDROData_Region theRegion ) [void ( const Handle_HYDROData_Region& )];
250   %MethodCode
251     Handle(HYDROData_Region) aRef =
252       Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
253     if ( !aRef.IsNull() )
254     {
255       Py_BEGIN_ALLOW_THREADS
256       if ( sipSelfWasArg ) {
257         sipCpp->HYDROData_CalculationCase::RemoveRegion( aRef );
258       } else {
259         sipCpp->RemoveRegion( aRef );
260       }
261       Py_END_ALLOW_THREADS
262     }
263   %End
264
265   /**
266    * Removes all reference regions from calculation case.
267    */
268   void RemoveRegions();
269
270   
271   /**
272    * Returns all reference geometry groups of calculation case.
273    */
274   HYDROData_SequenceOfObjects GetSplittedGroups() const;
275
276   /**
277    * Removes all reference geometry groups from calculation case.
278    */
279   void RemoveSplittedGroups();
280
281
282   /**
283    * Exports the calculation case data (shell and groups) to GEOM module.
284    * \param theGeomEngine GEOM module engine
285    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
286    * \return true in case of success
287    */
288 //TODO:  virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
289 //                       SALOMEDS::Study_ptr theStudy );
290
291 public:      
292   // Public methods to work with Calculation services
293
294   /**
295    * Returns altitude for given point.
296    * \param thePoint the point to examine
297    * \return result altitude value
298    */
299   double GetAltitudeForPoint( const double theCoordX,
300                               const double theCoordY ) const [double ( const gp_XY& )];
301   %MethodCode
302     gp_XY aPnt( a0, a1 );
303   
304     Py_BEGIN_ALLOW_THREADS
305     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudeForPoint( aPnt ) : 
306                              sipCpp->GetAltitudeForPoint( aPnt );
307     Py_END_ALLOW_THREADS
308   %End
309
310   /**
311    * Returns altitude for given point on given region.
312    * \param thePoint the point to examine
313    * \param theRegion reference region to check
314    * \return result altitude value
315    */
316   double GetAltitudeForPoint( const double     theCoordX,
317                               const double     theCoordY,
318                               HYDROData_Region theRegion ) const
319   [double ( const gp_XY&, const Handle_HYDROData_Region& )];
320   %MethodCode
321     gp_XY aPnt( a0, a1 );
322     Handle(HYDROData_Region) aRefRegion =
323       Handle(HYDROData_Region)::DownCast( createHandle( a2 ) );
324
325     Py_BEGIN_ALLOW_THREADS
326     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudeForPoint( aPnt, aRefRegion ) : 
327                              sipCpp->GetAltitudeForPoint( aPnt, aRefRegion );
328     Py_END_ALLOW_THREADS
329   %End
330
331   /**
332    * Returns altitude for given point on given zone.
333    * \param thePoint the point to examine
334    * \param theZone reference zone to check
335    * \return result altitude value
336    */
337   double GetAltitudeForPoint( const double theCoordX,
338                               const double theCoordY,
339                               HYDROData_Zone theZone ) const
340   [double ( const gp_XY&, const Handle_HYDROData_Zone& )];
341   %MethodCode
342     gp_XY aPnt( a0, a1 );
343     Handle(HYDROData_Zone) aRefZone =
344       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
345
346     Py_BEGIN_ALLOW_THREADS
347     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudeForPoint( aPnt, aRefZone ) : 
348                              sipCpp->GetAltitudeForPoint( aPnt, aRefZone );
349     Py_END_ALLOW_THREADS
350   %End
351
352   /**
353    * Returns altitudes for given points on given region.
354    * \param thePoints the points to examine
355    * \param theZone reference region to check
356    * \return result altitude value
357    */
358   NCollection_Sequence<double> GetAltitudesForPoints( const NCollection_Sequence<double>& theCoordsX,
359                                                       const NCollection_Sequence<double>& theCoordsY,
360                                                       HYDROData_Region                    theRegion ) const
361   [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Region& )];
362   %MethodCode
363
364     NCollection_Sequence<gp_XY> aPnts;
365
366     int aLen = qMin( a0->Length(), a1->Length() );
367     for ( int i = 1; i <= aLen; ++i )
368     {
369       gp_XY aPnt( a0->Value( i ), a1->Value( i ) );
370       aPnts.Append( aPnt );
371     }
372
373     Handle(HYDROData_Region) aRefRegion =
374       Handle(HYDROData_Region)::DownCast( createHandle( a2 ) );
375
376     NCollection_Sequence<double> aRes;
377     Py_BEGIN_ALLOW_THREADS
378     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefRegion ) : 
379                            sipCpp->GetAltitudesForPoints( aPnts, aRefRegion );
380     Py_END_ALLOW_THREADS
381     
382     sipRes = new NCollection_Sequence<double>( aRes );
383   %End
384
385   /**
386    * Returns altitudes for given points on given zone.
387    * \param thePoints the points to examine
388    * \param theZone reference zone to check
389    * \return result altitude value
390    */
391   NCollection_Sequence<double> GetAltitudesForPoints( const NCollection_Sequence<double>& theCoordsX,
392                                                       const NCollection_Sequence<double>& theCoordsY,
393                                                       HYDROData_Zone                      theZone ) const
394   [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Zone& )];
395   %MethodCode
396
397     NCollection_Sequence<gp_XY> aPnts;
398
399     int aLen = qMin( a0->Length(), a1->Length() );
400     for ( int i = 1; i <= aLen; ++i )
401     {
402       gp_XY aPnt( a0->Value( i ), a1->Value( i ) );
403       aPnts.Append( aPnt );
404     }
405
406     Handle(HYDROData_Zone) aRefZone =
407       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
408
409     NCollection_Sequence<double> aRes;
410     Py_BEGIN_ALLOW_THREADS
411     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefZone ) : 
412                            sipCpp->GetAltitudesForPoints( aPnts, aRefZone );
413     Py_END_ALLOW_THREADS
414     
415     sipRes = new NCollection_Sequence<double>( aRes );
416   %End
417   
418   /**
419    * Returns region to which the point is belongs.
420    * \param thePoint the point to examine
421    * \return result region
422    */
423   HYDROData_Region GetRegionFromPoint( const double theCoordX,
424                                        const double theCoordY ) const
425   [Handle_HYDROData_Region ( const gp_XY& )];
426   %MethodCode
427     Handle(HYDROData_Region) aRes;
428     
429     gp_XY aPnt( a0, a1 );
430   
431     Py_BEGIN_ALLOW_THREADS
432     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetRegionFromPoint( aPnt ) : 
433                            sipCpp->GetRegionFromPoint( aPnt );
434     Py_END_ALLOW_THREADS
435     
436     sipRes = (HYDROData_Region*)createPointer( aRes );
437   %End
438
439   /**
440    * Returns zone to which the point is belongs.
441    * \param thePoint the point to examine
442    * \return result zone
443    */
444   HYDROData_Zone GetZoneFromPoint( const double theCoordX,
445                                    const double theCoordY ) const
446   [Handle_HYDROData_Zone ( const gp_XY& )];
447   %MethodCode
448     Handle(HYDROData_Zone) aRes;
449     
450     gp_XY aPnt( a0, a1 );
451   
452     Py_BEGIN_ALLOW_THREADS
453     aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetZoneFromPoint( aPnt ) : 
454                            sipCpp->GetZoneFromPoint( aPnt );
455     Py_END_ALLOW_THREADS
456     
457     sipRes = (HYDROData_Zone*)createPointer( aRes );
458   %End
459
460   /**
461    * Returns classification of point for given zone.
462    * \param thePoint the point to examine
463    * \param theZone the zone to examine
464    * \return result classification
465    */
466   PointClassification GetPointClassification( const double theCoordX,
467                                               const double theCoordY,
468                                               HYDROData_Zone theZone ) const 
469   [PointClassification ( const gp_XY&, const Handle_HYDROData_Zone& )];    
470   %MethodCode
471     gp_XY aPnt( a0, a1 );
472
473     Handle(HYDROData_Zone) aRef =
474       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
475
476     Py_BEGIN_ALLOW_THREADS
477     sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetPointClassification( aPnt, aRef ) : 
478                              sipCpp->GetPointClassification( aPnt, aRef );
479     Py_END_ALLOW_THREADS
480   %End
481
482
483   void ClearRules();
484
485   void AddRule( HYDROData_Object                   theObject1,
486                 HYDROData_PriorityType             thePriority,
487                 HYDROData_Object                   theObject2,
488                 HYDROData_Zone::MergeAltitudesType theMergeType )
489   [void ( const Handle_HYDROData_Object&, HYDROData_PriorityType, const Handle_HYDROData_Object&, HYDROData_Zone::MergeAltitudesType )];
490   %MethodCode
491     Handle(HYDROData_Object) anObject1 =
492       Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
493     Handle(HYDROData_Object) anObject2 =
494       Handle(HYDROData_Object)::DownCast( createHandle( a2 ) );
495
496     Py_BEGIN_ALLOW_THREADS
497     sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRule( anObject1, a1, anObject2, a3 ) : 
498                     sipCpp->AddRule( anObject1, a1, anObject2, a3 );
499     Py_END_ALLOW_THREADS
500   %End
501
502   QString DumpRules();
503
504 protected:
505
506   /**
507    * Creates new object in the internal data structure. Use higher level objects 
508    * to create objects with real content.
509    */
510   HYDROData_CalculationCase();
511
512   /**
513    * Destructs properties of the object and object itself, removes it from the document.
514    */
515   ~HYDROData_CalculationCase();
516 };
517
518