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