Salome HOME
5a5b3ad2dc78fe86434a6d11b93dcf041520135c
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.cxx
1
2 #include "HYDROData_CalculationCase.h"
3
4 #include "HYDROData_ArtificialObject.h"
5 #include "HYDROData_Bathymetry.h"
6 #include "HYDROData_Document.h"
7 #include "HYDROData_Iterator.h"
8 #include "HYDROData_NaturalObject.h"
9 #include "HYDROData_PolylineXY.h"
10 #include "HYDROData_SplitToZonesTool.h"
11 #include "HYDROData_Region.h"
12 #include "HYDROData_Tool.h"
13 #include "HYDROData_Zone.h"
14
15 #include <TopoDS.hxx>
16 #include <TopoDS_Shell.hxx>
17 #include <BRep_Builder.hxx>
18 #include <BRepBuilderAPI_Sewing.hxx>
19 #include <TopExp_Explorer.hxx>
20 #include <TopExp.hxx>
21 #include <TopTools_ListOfShape.hxx>
22 #include <TopTools_ListIteratorOfListOfShape.hxx>
23 #include <BRepTopAdaptor_FClass2d.hxx>
24 #include <TopAbs.hxx>
25 #define CALCULATION_REGIONS_PREF GetName() + "_Reg"
26 #define CALCULATION_ZONES_PREF GetName() + "_Zone"
27
28 #define PYTHON_CALCULATION_ID "KIND_CALCULATION"
29
30 IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
31 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
32
33 HYDROData_CalculationCase::HYDROData_CalculationCase()
34 : HYDROData_Entity()
35 {
36 }
37
38 HYDROData_CalculationCase::~HYDROData_CalculationCase()
39 {
40 }
41
42 void HYDROData_CalculationCase::SetName( const QString& theName )
43 {
44   QString anOldCaseName = GetName();
45   if ( anOldCaseName != theName )
46   {
47     HYDROData_SequenceOfObjects aRegions = GetRegions();
48
49     HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
50     for ( ; anIter.More(); anIter.Next() )
51     {
52       Handle(HYDROData_Region) aRegion =
53         Handle(HYDROData_Region)::DownCast( anIter.Value() );
54       if ( aRegion.IsNull() )
55         continue;
56
57       QString aRegionName = aRegion->GetName();
58       if ( aRegionName.startsWith( anOldCaseName ) )
59       {
60         aRegionName.replace( anOldCaseName, theName );
61         aRegion->SetName( aRegionName );
62       }
63
64       HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
65       HYDROData_SequenceOfObjects::Iterator anIter( aZones );
66       for ( ; anIter.More(); anIter.Next() )
67       {
68         Handle(HYDROData_Zone) aRegZone =
69           Handle(HYDROData_Zone)::DownCast( anIter.Value() );
70         if ( aRegZone.IsNull() )
71           continue;
72
73         QString aRegionZoneName = aRegZone->GetName();
74         if ( aRegionZoneName.startsWith( anOldCaseName ) )
75         {
76           aRegionZoneName.replace( anOldCaseName, theName );
77           aRegZone->SetName( aRegionZoneName );
78         }
79       }
80     }
81   }
82
83   HYDROData_Entity::SetName( theName );
84 }
85
86 QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
87 {
88   QStringList aResList;
89
90   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
91   if ( aDocument.IsNull() )
92     return aResList;
93                              
94   QString aDocName = aDocument->GetDocPyName();
95   QString aCalculName = GetName();
96
97   aResList << QString( "%1 = %2.CreateObject( %3 );" )
98               .arg( aCalculName ).arg( aDocName ).arg( PYTHON_CALCULATION_ID );
99   aResList << QString( "%1.SetName( \"%2\" );" )
100               .arg( aCalculName ).arg( aCalculName );
101   aResList << QString( "" );
102
103   HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
104   HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
105   for ( ; anIter.More(); anIter.Next() )
106   {
107     Handle(HYDROData_Object) aRefGeomObj =
108       Handle(HYDROData_Object)::DownCast( anIter.Value() );
109     if ( !aRefGeomObj.IsNull() )
110       setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
111   }
112   aResList << QString( "" );
113
114   aResList << QString( "%1.SplitGeometryObjects();" ).arg( aCalculName );
115   aResList << QString( "" );
116
117   // Now we restore the regions and zones order
118   HYDROData_SequenceOfObjects aRegions = GetRegions();
119   anIter.Init( aRegions );
120   for ( ; anIter.More(); anIter.Next() )
121   {
122     Handle(HYDROData_Region) aRegion =
123       Handle(HYDROData_Region)::DownCast( anIter.Value() );
124     if ( aRegion.IsNull() )
125       continue;
126
127     QString aRegionName = aRegion->GetName();
128     // TODO
129   }
130
131   return aResList;
132 }
133
134 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() const
135 {
136   HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
137
138   Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
139   if ( !aBoundaryPolyline.IsNull() )
140     aResSeq.Append( aBoundaryPolyline );
141
142   HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
143   aResSeq.Append( aSeqOfRegions );
144
145   return aResSeq;
146 }
147
148 void HYDROData_CalculationCase::Update()
149 {
150   HYDROData_Entity::Update();
151
152   // At first we remove previously created regions
153   RemoveRegions();
154
155   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
156   if ( aDocument.IsNull() )
157     return;
158
159   Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
160   HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
161   if ( aGeomObjects.IsEmpty() )
162     return;
163
164   HYDROData_SplitToZonesTool::SplitDataList aSplitedZones =
165     HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects, aBoundaryPolyline );
166   if ( aSplitedZones.isEmpty() )
167     return;
168
169   QString aRegsPref = CALCULATION_REGIONS_PREF;
170   QString aZonesPref = CALCULATION_ZONES_PREF;
171
172   // Create result regions for case, by default one zone for one region
173   HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitedZones );
174   while( anIter.hasNext() )
175   {
176     const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
177
178     // Create new region
179     Handle(HYDROData_Region) aRegion = addNewRegion();
180
181     QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
182     aRegion->SetName( aRegionName );
183
184     // Add the zone for region
185     Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone();
186
187     QString aZoneName = HYDROData_Tool::GenerateObjectName( aDocument, aZonesPref );
188     aRegionZone->SetName( aZoneName );
189
190     aRegionZone->SetShape( aSplitData.Face() );
191
192     // Add the reference object for zone
193     for ( int i = 0, n = aSplitData.ObjectNames.length(); i < n; ++i )
194     {
195       const QString& anObjName = aSplitData.ObjectNames.at( i );
196       
197       Handle(HYDROData_Object) aRefObject = Handle(HYDROData_Object)::DownCast(
198         HYDROData_Tool::FindObjectByName( aDocument, anObjName ) );
199       if ( aRefObject.IsNull() )
200         continue;
201
202       aRegionZone->AddGeometryObject( aRefObject );
203     }
204   }
205 }
206
207 bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
208 {
209   if ( !HYDROData_Tool::IsGeometryObject( theObject ) )
210     return false; // Wrong type of object
211
212   if ( HasReference( theObject, DataTag_GeometryObject ) )
213     return false; // Object is already in reference list
214
215   AddReferenceObject( theObject, DataTag_GeometryObject );
216   
217   // Indicate model of the need to update zones splitting
218   SetToUpdate( true );
219
220   return true;
221 }
222
223 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryObjects() const
224 {
225   return GetReferenceObjects( DataTag_GeometryObject );
226 }
227
228 void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject )
229 {
230   if ( theObject.IsNull() )
231     return;
232
233   RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
234
235   // Indicate model of the need to update zones splitting
236   SetToUpdate( true );
237 }
238
239 void HYDROData_CalculationCase::RemoveGeometryObjects()
240 {
241   ClearReferenceObjects( DataTag_GeometryObject );
242
243   // Indicate model of the need to update zones splitting
244   SetToUpdate( true );
245 }
246
247 void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
248 {
249   Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
250
251   SetReferenceObject( thePolyline, DataTag_Polyline );
252
253   // Indicate model of the need to update zones splitting
254   SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() );
255 }
256
257 Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
258 {
259   return Handle(HYDROData_PolylineXY)::DownCast( 
260            GetReferenceObject( DataTag_Polyline ) );
261 }
262
263 void HYDROData_CalculationCase::RemoveBoundaryPolyline()
264 {
265   Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
266
267   ClearReferenceObjects( DataTag_Polyline );
268
269   // Indicate model of the need to update zones splitting
270   SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() );
271 }
272
273 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
274 {
275   Handle(HYDROData_Region) aNewRegion = addNewRegion();
276   if ( aNewRegion.IsNull() )
277     return aNewRegion;
278
279   // Generate new name for new region
280   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
281   if ( !aDocument.IsNull() )
282   {
283     QString aRegsPref = CALCULATION_REGIONS_PREF;
284
285     QString aNewRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
286     aNewRegion->SetName( aNewRegionName );
287   }
288
289   aNewRegion->AddZone( theZone );
290
291   return aNewRegion;
292 }
293
294 bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion )
295 {
296   if ( theRegion.IsNull() )
297     return false;
298   
299   if ( HasReference( theRegion, DataTag_Region ) )
300     return false; // Object is already in reference list
301
302   // Move the region from other calculation
303   Handle(HYDROData_CalculationCase) aFatherCalc = 
304     Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
305   if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
306   {
307     Handle(HYDROData_Region) aNewRegion = addNewRegion();
308     theRegion->CopyTo( aNewRegion );
309
310     aFatherCalc->RemoveRegion( theRegion );
311
312     theRegion->SetLabel( aNewRegion->Label() );
313   }
314   else
315   {
316     AddReferenceObject( theRegion, DataTag_Region );
317   }
318
319   return true;
320 }
321
322 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const
323 {
324   return GetReferenceObjects( DataTag_Region );
325 }
326
327 void HYDROData_CalculationCase::UpdateRegionsOrder()
328 {
329   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
330   if ( aDocument.IsNull() )
331     return;
332
333   HYDROData_SequenceOfObjects aRegions = GetRegions();
334
335   HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
336   for ( ; anIter.More(); anIter.Next() )
337   {
338     Handle(HYDROData_Region) aRegion =
339       Handle(HYDROData_Region)::DownCast( anIter.Value() );
340     if ( aRegion.IsNull() )
341       continue;
342
343     aRegion->SetName( "" );
344   }
345
346   QString aRegsPref = CALCULATION_REGIONS_PREF;
347
348   anIter.Init( aRegions );
349   for ( ; anIter.More(); anIter.Next() )
350   {
351     Handle(HYDROData_Region) aRegion =
352       Handle(HYDROData_Region)::DownCast( anIter.Value() );
353     if ( aRegion.IsNull() )
354       continue;
355
356     QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
357     aRegion->SetName( aRegionName );
358   }
359 }
360
361 void HYDROData_CalculationCase::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
362 {
363   if ( theRegion.IsNull() )
364     return;
365
366   RemoveReferenceObject( theRegion->Label(), DataTag_Region );
367
368   // Remove region from data model
369   Handle(HYDROData_CalculationCase) aFatherCalc = 
370     Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
371   if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab )
372     theRegion->Remove();
373 }
374
375 void HYDROData_CalculationCase::RemoveRegions()
376 {
377   ClearReferenceObjects( DataTag_Region );
378   myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes( true );
379 }
380
381 Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion()
382 {
383   TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
384
385   Handle(HYDROData_Region) aNewRegion =
386     Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
387   AddRegion( aNewRegion );
388
389   return aNewRegion;
390 }
391
392 TopoDS_Shell HYDROData_CalculationCase::GetShell()
393 {
394   TopoDS_Shell aShell;
395
396   TopTools_ListOfShape aFacesList;
397
398   // Make shell containing all region shapes
399   BRepBuilderAPI_Sewing aSewing( Precision::Confusion()*10.0 );
400
401   HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
402   HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
403   for ( ; aRegionIter.More(); aRegionIter.Next() ) {
404     Handle(HYDROData_Region) aRegion =
405       Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
406     if( aRegion.IsNull() ) {
407       continue;
408     }
409
410     TopoDS_Shape aRegionShape = aRegion->GetShape();
411     if( !aRegionShape.IsNull() ) {
412       if ( aRegionShape.ShapeType() == TopAbs_FACE ) {
413         TopoDS_Face aFace = TopoDS::Face( aRegionShape );
414         if ( !aFace.IsNull() ) {
415           aFacesList.Append( aFace );
416           aSewing.Add( aFace );
417         }
418       } else {
419         TopExp_Explorer anExp( aRegionShape, TopAbs_FACE );
420         for ( ; anExp.More(); anExp.Next() ) {
421           TopoDS_Face aFace = TopoDS::Face( anExp.Current() );
422           if ( !aFace.IsNull() ) {
423             aFacesList.Append( aFace );
424             aSewing.Add( aFace );
425           }
426         }
427       }
428     }
429   } // regions iterator
430   
431   aSewing.Perform();
432   TopoDS_Shape aSewedShape = aSewing.SewedShape();
433
434   if ( !aSewedShape.IsNull() )
435   {
436     if ( aSewedShape.ShapeType() == TopAbs_FACE && aCaseRegions.Length() ==1 ) {
437       // create shell from one face
438       BRep_Builder aBuilder;
439       aBuilder.MakeShell( aShell );
440       aBuilder.Add( aShell, aSewedShape);
441     } else {
442       TopExp_Explorer anExpShells( aSewedShape, TopAbs_SHELL );
443       Standard_Integer aNbOfShells = 0;
444       for ( ; anExpShells.More(); anExpShells.Next() ) {
445         aShell = TopoDS::Shell( anExpShells.Current() );
446         aNbOfShells++;
447       }
448
449       if ( aNbOfShells != 1 ) {
450         aShell.Nullify();
451         BRep_Builder aBuilder;
452         aBuilder.MakeShell( aShell );
453
454         TopExp_Explorer anExpFaces( aSewedShape, TopAbs_FACE );
455         for ( ; anExpFaces.More(); anExpFaces.Next() ) {
456           TopoDS_Face aFace = TopoDS::Face( anExpFaces.Current() );
457           if ( !aFace.IsNull() ) {
458             aBuilder.Add( aShell, aFace );
459           }
460         }
461       }
462     }
463   }
464
465   if ( !aShell.IsNull() ) {
466     TopTools_IndexedMapOfShape aMapOfFaces;
467     TopExp::MapShapes( aShell, TopAbs_FACE, aMapOfFaces );
468     if ( aMapOfFaces.Extent() != aFacesList.Extent() ) {
469       aShell.Nullify();
470       BRep_Builder aBuilder;
471       aBuilder.MakeShell( aShell );
472
473       TopTools_ListIteratorOfListOfShape anIter( aFacesList );
474       for ( ; anIter.More(); anIter.Next() ) {
475         TopoDS_Face aFace = TopoDS::Face( anIter.Value() );
476         aBuilder.Add( aShell, aFace );
477       }
478     }
479   }
480
481 /* TODO: old version
482   // Make shell
483   BRep_Builder aBuilder;
484   aBuilder.MakeShell( aShell );
485
486   // Make shell containing all region shapes
487   HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
488   HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
489   for ( ; aRegionIter.More(); aRegionIter.Next() ) {
490     Handle(HYDROData_Region) aRegion =
491       Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
492     if( aRegion.IsNull() ) {
493       continue;
494     }
495
496     TopoDS_Shape aRegionShape = aRegion->GetShape();
497
498     // Add shape (face or shell) corresponding to the region into the shell
499     if( !aRegionShape.IsNull() ) {
500       if ( aRegionShape.ShapeType() == TopAbs_FACE ) {
501         aBuilder.Add( aShell, aRegionShape );
502       } else {
503         TopExp_Explorer anExp( aRegionShape, TopAbs_FACE );
504         for( ; anExp.More(); anExp.Next() ) {
505           TopoDS_Face aFace = TopoDS::Face( anExp.Current() );
506           if( !aFace.IsNull() ) {
507             aBuilder.Add( aShell, aFace );
508           }
509         }
510       }
511     }
512   } // regions iterator
513 */
514
515   // Nullify shell if it is empty
516   if ( !aShell.IsNull() && !TopoDS_Iterator(aShell).More() ) {
517     aShell.Nullify();
518   }
519
520   return aShell;
521 }
522
523 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) const
524 {
525   double aResAltitude = HYDROData_Bathymetry::GetInvalidAltitude();
526
527   Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
528   if ( aZone.IsNull() )
529     return aResAltitude;
530
531   HYDROData_Zone::MergeBathymetriesType aZoneMergeType = aZone->GetMergeType();
532   if ( !aZone->IsMergingNeed() )
533   {
534     aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN;
535   }
536   else if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
537   {
538     return aResAltitude;
539   }
540
541   if ( aZoneMergeType == HYDROData_Zone::Merge_Object )
542   {
543     Handle(HYDROData_Bathymetry) aMergeBathymetry = aZone->GetMergeBathymetry();
544     if ( !aMergeBathymetry.IsNull() )
545       aResAltitude = aMergeBathymetry->GetAltitudeForPoint( thePoint );
546   }
547   else
548   {
549     HYDROData_SequenceOfObjects aZoneObjects = aZone->GetGeometryObjects();
550     HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects );
551     for ( ; anIter.More(); anIter.Next() )
552     {
553       Handle(HYDROData_Object) aZoneObj =
554         Handle(HYDROData_Object)::DownCast( anIter.Value() );
555       if ( aZoneObj.IsNull() )
556         continue;
557
558       Handle(HYDROData_Bathymetry) anObjBathymetry = aZoneObj->GetBathymetry();
559       if ( anObjBathymetry.IsNull() )
560         continue;
561
562       double aPointAltitude = anObjBathymetry->GetAltitudeForPoint( thePoint );
563       if ( ValuesEquals( aPointAltitude, HYDROData_Bathymetry::GetInvalidAltitude() ) )
564         continue;
565
566       if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
567       {
568         aResAltitude = aPointAltitude;
569         break;
570       }
571       else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMIN )
572       {
573         if ( ValuesEquals( aResAltitude, HYDROData_Bathymetry::GetInvalidAltitude() ) ||
574              aResAltitude > aPointAltitude )
575         {
576           aResAltitude = aPointAltitude;
577         }
578       }
579       else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMAX )
580       {
581         if ( ValuesEquals( aResAltitude, HYDROData_Bathymetry::GetInvalidAltitude() ) ||
582              aResAltitude < aPointAltitude )
583         {
584           aResAltitude = aPointAltitude;
585         }
586       }
587     }
588   }
589
590   return aResAltitude;
591 }
592
593 Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
594 {
595   Handle(HYDROData_Zone) aResZone;
596
597   HYDROData_SequenceOfObjects aRegions = GetRegions();
598
599   HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
600   for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() )
601   {
602     Handle(HYDROData_Region) aRegion =
603       Handle(HYDROData_Region)::DownCast( anIter.Value() );
604     if ( aRegion.IsNull() )
605       continue;
606
607     HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
608     HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
609     for ( ; aZonesIter.More() && aResZone.IsNull(); aZonesIter.Next() )
610     {
611       Handle(HYDROData_Zone) aRegZone =
612         Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
613       if ( aRegZone.IsNull() )
614         continue;
615
616       PointClassification aPointRelation = GetPointClassification( thePoint, aRegZone );
617       if ( aPointRelation != POINT_OUT )
618         aResZone = aRegZone; // We found the desired zone
619     }
620   }
621
622   return aResZone;
623 }
624 HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPointClassification(
625   const gp_XY&                  thePoint,
626   const Handle(HYDROData_Zone)& theZone ) const
627 {
628   PointClassification aRes = POINT_OUT;
629   if ( theZone.IsNull() )
630     return aRes;
631
632   TopoDS_Face aZoneFace = TopoDS::Face( theZone->GetShape() );
633   if ( aZoneFace.IsNull() )
634     return aRes;
635
636   BRepTopAdaptor_FClass2d aClassifier( aZoneFace, Precision::Confusion() );
637   TopAbs_State State = aClassifier.Perform( gp_Pnt2d(thePoint), Standard_False );
638   if (State == TopAbs_OUT)
639         aRes =  POINT_OUT;
640   else if(State == TopAbs_IN)
641     aRes =  POINT_IN;
642   else if(State == TopAbs_ON)
643     aRes =  POINT_ON;     
644   return aRes;
645 }