]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_CalculationCase.cxx
Salome HOME
2def6341fea3e25e97106aaa636ea80f21feb606
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.cxx
1
2 #include "HYDROData_CalculationCase.h"
3
4 #include "HYDROData_ArtificialObject.h"
5 #include "HYDROData_IAltitudeObject.h"
6 #include "HYDROData_Document.h"
7 #include "HYDROData_ShapesGroup.h"
8 #include "HYDROData_Iterator.h"
9 #include "HYDROData_NaturalObject.h"
10 #include "HYDROData_PolylineXY.h"
11 #include "HYDROData_SplittedShapesGroup.h"
12 #include "HYDROData_Region.h"
13 #include "HYDROData_Tool.h"
14
15 #include <GEOMBase.h>
16
17 #include <QSet>
18
19 #include <TopoDS.hxx>
20 #include <TopoDS_Shell.hxx>
21 #include <TopoDS_Edge.hxx>
22
23 #include <BRep_Builder.hxx>
24 #include <BRepBuilderAPI_Sewing.hxx>
25 #include <BRepTopAdaptor_FClass2d.hxx>
26
27 #include <BRepTools.hxx>
28
29 #include <TopAbs.hxx>
30 #include <TopExp_Explorer.hxx>
31 #include <TopExp.hxx>
32 #include <TopTools_ListOfShape.hxx>
33 #include <TopTools_ListIteratorOfListOfShape.hxx>
34 #include <TDataStd_Integer.hxx>
35
36 //#define  DEB_CALCULATION 1
37 #ifdef DEB_CALCULATION
38 #include <BRepTools.hxx>
39 #include <TopLoc_Location.hxx>
40 #endif 
41 #define CALCULATION_REGIONS_PREF GetName() + "_Reg"
42 #define CALCULATION_ZONES_PREF GetName() + "_Zone"
43 #define CALCULATION_GROUPS_PREF GetName() + "_"
44 //#define DEB_CLASS2D 1
45 #ifdef DEB_CLASS2D
46 #include <BRepBuilderAPI_MakeVertex.hxx>
47 #endif
48
49 #define EXPORT_NAME "HYDRO_" + GetName()
50
51 IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
52 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
53
54 HYDROData_CalculationCase::HYDROData_CalculationCase()
55 : HYDROData_Entity()
56 {
57 }
58
59 HYDROData_CalculationCase::~HYDROData_CalculationCase()
60 {
61 }
62
63 void HYDROData_CalculationCase::SetName( const QString& theName )
64 {
65   QString anOldCaseName = GetName();
66   if ( anOldCaseName != theName )
67   {
68     HYDROData_SequenceOfObjects aRegions = GetRegions();
69
70     HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
71     for ( ; anIter.More(); anIter.Next() )
72     {
73       Handle(HYDROData_Region) aRegion =
74         Handle(HYDROData_Region)::DownCast( anIter.Value() );
75       if ( aRegion.IsNull() )
76         continue;
77
78       HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegion );
79
80       HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
81       HYDROData_SequenceOfObjects::Iterator anIter( aZones );
82       for ( ; anIter.More(); anIter.Next() )
83       {
84         Handle(HYDROData_Zone) aRegZone =
85           Handle(HYDROData_Zone)::DownCast( anIter.Value() );
86         if ( aRegZone.IsNull() )
87           continue;
88
89         HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegZone );
90       }
91     }
92
93     HYDROData_SequenceOfObjects aGroups = GetSplittedGroups();
94
95     anIter.Init( aGroups );
96     for ( ; anIter.More(); anIter.Next() )
97     {
98       Handle(HYDROData_SplittedShapesGroup) aGroup =
99         Handle(HYDROData_SplittedShapesGroup)::DownCast( anIter.Value() );
100       if ( aGroup.IsNull() )
101         continue;
102
103       HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aGroup );
104     }
105   }
106
107   HYDROData_Entity::SetName( theName );
108 }
109
110 QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
111 {
112   QStringList aResList = dumpObjectCreation( theTreatedObjects );
113
114   QString aCalculName = GetObjPyName();
115
116   AssignmentMode aMode = GetAssignmentMode();
117   QString aModeStr = aMode==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC";
118   aResList << QString( "%0.SetAssignmentMode( %1 )" ).arg( aCalculName ).arg( aModeStr );
119
120   HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
121   HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
122   for ( ; anIter.More(); anIter.Next() )
123   {
124     Handle(HYDROData_Object) aRefGeomObj =
125       Handle(HYDROData_Object)::DownCast( anIter.Value() );
126     setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
127   }
128   aResList << QString( "" );
129
130   QString aGroupName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "case_geom_group" );
131
132   HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
133   anIter.Init( aGeomGroups );
134   for ( ; anIter.More(); anIter.Next() )
135   {
136     Handle(HYDROData_ShapesGroup) aGeomGroup =
137       Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
138     if ( aGeomGroup.IsNull() )
139       continue;
140
141     Handle(HYDROData_Object) aFatherGeom =
142       Handle(HYDROData_Object)::DownCast( aGeomGroup->GetFatherObject() );
143     if ( aFatherGeom.IsNull() )
144       continue;
145
146     int aGroupId = aFatherGeom->GetGroupId( aGeomGroup );
147     aResList << QString( "%1 = %2.GetGroup( %3 );" )
148               .arg( aGroupName ).arg( aFatherGeom->GetObjPyName() ).arg( aGroupId );
149
150     aResList << QString( "%1.AddGeometryGroup( %2 );" ).arg( aCalculName ).arg( aGroupName );
151   }
152   aResList << QString( "" );
153
154   Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
155   setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
156   aResList << QString( "" );
157
158   if( aMode==AUTOMATIC )
159     DumpRulesToPython( aCalculName, aResList );
160
161   aResList << QString( "" );
162   aResList << QString( "%1.Update();" ).arg( aCalculName );
163   aResList << QString( "" );
164
165   if( aMode==MANUAL )
166   {
167     // Now we restore the regions and zones order
168     HYDROData_SequenceOfObjects aRegions = GetRegions();
169     anIter.Init( aRegions );
170     for ( ; anIter.More(); anIter.Next() )
171     {
172       Handle(HYDROData_Region) aRegion =
173         Handle(HYDROData_Region)::DownCast( anIter.Value() );
174       if ( aRegion.IsNull() )
175         continue;
176
177       QString aRegionName = aRegion->GetName();
178
179       HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
180       HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
181       for ( ; aZonesIter.More(); aZonesIter.Next() )
182       {
183         Handle(HYDROData_Zone) aRegZone =
184           Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
185         if ( aRegZone.IsNull() )
186           continue;
187
188         // TODO
189       }
190     }
191   }
192
193   aResList << QString( "" );
194   return aResList;
195 }
196
197 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() const
198 {
199   HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
200
201   Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
202   if ( !aBoundaryPolyline.IsNull() )
203     aResSeq.Append( aBoundaryPolyline );
204
205   HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
206   aResSeq.Append( aSeqOfRegions );
207
208   return aResSeq;
209 }
210
211 void HYDROData_CalculationCase::Update()
212 {
213   HYDROData_Entity::Update();
214   SetWarning();
215
216   // At first we remove previously created objects
217   RemoveRegions();
218   RemoveSplittedGroups();
219
220   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
221   if ( aDocument.IsNull() )
222     return;
223
224   Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
225   HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
226   if ( aGeomObjects.IsEmpty() )
227     return;
228
229   HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
230
231   HYDROData_SplitToZonesTool::SplitDataList aSplitObjects =
232     HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline );
233   if ( aSplitObjects.isEmpty() )
234     return;
235
236   HYDROData_SplitToZonesTool::SplitDataList aZonesList, anEdgesList;
237
238   HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitObjects );
239   while( anIter.hasNext() )
240   {
241     const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
242     if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
243       aZonesList.append( aSplitData );
244     else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
245       anEdgesList.append( aSplitData );
246   }
247
248   switch( GetAssignmentMode() )
249   {
250   case MANUAL:
251     CreateRegionsDef( aDocument, aZonesList );
252     break;
253   case AUTOMATIC:
254     CreateRegionsAuto( aDocument, aZonesList );
255     break;
256   }
257   CreateEdgeGroupsDef( aDocument, anEdgesList );
258 }
259
260 void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
261                                                   const HYDROData_SplitToZonesTool::SplitDataList& theZones )
262 {
263   // Create result regions for case, by default one zone for one region
264   QString aRegsPref = CALCULATION_REGIONS_PREF;
265   QString aZonesPref = CALCULATION_ZONES_PREF;
266
267   HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
268   while( anIter.hasNext() )
269   {
270     const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
271     // Create new region
272     Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref );
273
274     // Add the zone for region
275     Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
276   }
277 }
278
279 void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
280                                                    const HYDROData_SplitToZonesTool::SplitDataList& theZones )
281 {
282   QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
283   QMap<QString, QString> aRegionNameToObjNameMap;
284   QString aZonesPref = CALCULATION_ZONES_PREF;
285   HYDROData_PriorityQueue aPr( this );
286
287   // 1. First we create a default region for each object included into the calculation case
288   HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
289   for( int i=aGeomObjects.Lower(), n=aGeomObjects.Upper(); i<=n; i++ )
290   {
291     Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( aGeomObjects.Value( i ) );
292     if( anObj.IsNull() )
293       continue;
294     QString anObjName = anObj->GetName();
295     QString aRegName = anObjName + "_reg";
296     Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false );
297     aRegionsMap.insert( anObjName, aRegion );
298     aRegionNameToObjNameMap.insert( aRegName, anObjName );
299   }
300
301   // 2. Now for each zone it is necessary to determine the most priority object
302   //    and assign to zone to corresponding region
303   HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
304   while( anIter.hasNext() )
305   {
306     const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
307     HYDROData_Zone::MergeAltitudesType aMergeType;
308     Handle(HYDROData_Object) aRegObj = aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType );
309     if( aRegObj.IsNull() )
310       continue;
311     Handle(HYDROData_Region) aRegion = aRegionsMap[aRegObj->GetName()];
312     if( aRegion.IsNull() )
313       continue;
314     Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
315
316     if( aSplitData.ObjectNames.count() > 1 && aMergeType==HYDROData_Zone::Merge_UNKNOWN )
317     {
318       qDebug( "Error in algorithm: unresolved conflicts" );
319     }
320
321     switch( aMergeType )
322     {
323     case HYDROData_Zone::Merge_ZMIN:
324     case HYDROData_Zone::Merge_ZMAX:
325       aRegionZone->SetMergeType( aMergeType );
326       break;
327     case HYDROData_Zone::Merge_Object:
328       aRegionZone->SetMergeType( aMergeType );
329       aRegionZone->RemoveMergeAltitude();
330       aRegionZone->SetMergeAltitude( aRegObj->GetAltitudeObject() );
331       break;
332     }
333   }
334
335   QStringList anObjectsWithEmptyRegions;
336   QMap<QString, Handle(HYDROData_Region)>::const_iterator
337     anIt = aRegionsMap.begin(), aLast = aRegionsMap.end();
338   for( ; anIt!=aLast; anIt++ )
339   {
340     Handle(HYDROData_Region) aRegion = anIt.value();
341     if( aRegion->GetZones().IsEmpty() )
342     {
343       QString aRegName = aRegion->GetName();
344       QString anObjName = aRegionNameToObjNameMap[aRegName];
345       anObjectsWithEmptyRegions.append( anObjName );
346     }
347   }
348   
349   if( !anObjectsWithEmptyRegions.empty() )
350   {
351     QString aData = anObjectsWithEmptyRegions.join( ", " );
352     SetWarning( WARN_EMPTY_REGIONS, aData );
353   }
354 }
355
356 void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
357                                                      const HYDROData_SplitToZonesTool::SplitDataList& theEdges )
358 {
359   QMap<QString,Handle(HYDROData_SplittedShapesGroup)> aSplittedEdgesGroupsMap;
360
361   HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges );
362   while( anIter.hasNext() )
363   {
364     const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
365     // Create new edges group
366     if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
367       continue;
368
369     QString anObjName = aSplitData.ObjectNames.first();
370     if ( anObjName.isEmpty() )
371       continue;
372 #ifdef DEB_CALCULATION
373     QString aStr = aSplitData.ObjectNames.join(" "); 
374           cout << " CCase: Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size() <<endl; 
375 #endif
376     Handle(HYDROData_SplittedShapesGroup) aSplittedGroup;
377     if ( !aSplittedEdgesGroupsMap.contains( anObjName ) )
378     {
379       aSplittedGroup = addNewSplittedGroup( CALCULATION_GROUPS_PREF + anObjName );
380       aSplittedEdgesGroupsMap.insert( anObjName, aSplittedGroup );
381     }
382     else
383     {
384       aSplittedGroup = aSplittedEdgesGroupsMap[ anObjName ];
385     }
386     if ( aSplittedGroup.IsNull() )
387       continue;
388
389     aSplittedGroup->AddShape( aSplitData.Shape );
390   }
391 }
392
393 bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
394 {
395   if ( !HYDROData_Tool::IsGeometryObject( theObject ) )
396     return false; // Wrong type of object
397
398   if ( HasReference( theObject, DataTag_GeometryObject ) )
399     return false; // Object is already in reference list
400
401   AddReferenceObject( theObject, DataTag_GeometryObject );
402   
403   // Indicate model of the need to update splitting
404   SetToUpdate( true );
405
406   return true;
407 }
408
409 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryObjects() const
410 {
411   return GetReferenceObjects( DataTag_GeometryObject );
412 }
413
414 void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject )
415 {
416   if ( theObject.IsNull() )
417     return;
418
419   RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
420
421   // Indicate model of the need to update splitting
422   SetToUpdate( true );
423 }
424
425 void HYDROData_CalculationCase::RemoveGeometryObjects()
426 {
427   ClearReferenceObjects( DataTag_GeometryObject );
428
429   // Indicate model of the need to update splitting
430   SetToUpdate( true );
431 }
432
433 bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
434 {
435   if ( theGroup.IsNull() )
436     return false;
437
438   if ( HasReference( theGroup, DataTag_GeometryGroup ) )
439     return false; // Object is already in reference list
440
441   AddReferenceObject( theGroup, DataTag_GeometryGroup );
442   
443   // Indicate model of the need to update splitting
444   SetToUpdate( true );
445
446   return true;
447 }
448
449 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryGroups() const
450 {
451   return GetReferenceObjects( DataTag_GeometryGroup );
452 }
453
454 void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
455 {
456   if ( theGroup.IsNull() )
457     return;
458
459   RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
460
461   // Indicate model of the need to update splitting
462   SetToUpdate( true );
463 }
464
465 void HYDROData_CalculationCase::RemoveGeometryGroups()
466 {
467   ClearReferenceObjects( DataTag_GeometryGroup );
468
469   // Indicate model of the need to update splitting
470   SetToUpdate( true );
471 }
472
473 void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
474 {
475   Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
476
477   SetReferenceObject( thePolyline, DataTag_Polyline );
478
479   // Indicate model of the need to update zones splitting
480   SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() );
481 }
482
483 Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
484 {
485   return Handle(HYDROData_PolylineXY)::DownCast( 
486            GetReferenceObject( DataTag_Polyline ) );
487 }
488
489 void HYDROData_CalculationCase::RemoveBoundaryPolyline()
490 {
491   Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
492
493   ClearReferenceObjects( DataTag_Polyline );
494
495   // Indicate model of the need to update zones splitting
496   SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() );
497 }
498
499 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
500 {
501   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
502   Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
503   if ( aNewRegion.IsNull() )
504     return aNewRegion;
505
506   aNewRegion->AddZone( theZone );
507
508   return aNewRegion;
509 }
510
511 bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion )
512 {
513   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
514
515   if ( theRegion.IsNull() )
516     return false;
517   
518   if ( HasReference( theRegion, DataTag_Region ) )
519     return false; // Object is already in reference list
520
521   // Move the region from other calculation
522   Handle(HYDROData_CalculationCase) aFatherCalc = 
523     Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
524   if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
525   {
526     Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
527     theRegion->CopyTo( aNewRegion );
528
529     aFatherCalc->RemoveRegion( theRegion );
530
531     theRegion->SetLabel( aNewRegion->Label() );
532   }
533   else
534   {
535     AddReferenceObject( theRegion, DataTag_Region );
536   }
537
538   return true;
539 }
540
541 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const
542 {
543   return GetReferenceObjects( DataTag_Region );
544 }
545
546 void HYDROData_CalculationCase::UpdateRegionsOrder()
547 {
548   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
549   if ( aDocument.IsNull() )
550     return;
551
552   HYDROData_SequenceOfObjects aRegions = GetRegions();
553
554   HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
555   for ( ; anIter.More(); anIter.Next() )
556   {
557     Handle(HYDROData_Region) aRegion =
558       Handle(HYDROData_Region)::DownCast( anIter.Value() );
559     if ( aRegion.IsNull() )
560       continue;
561
562     aRegion->SetName( "" );
563   }
564
565   QString aRegsPref = CALCULATION_REGIONS_PREF;
566
567   anIter.Init( aRegions );
568   for ( ; anIter.More(); anIter.Next() )
569   {
570     Handle(HYDROData_Region) aRegion =
571       Handle(HYDROData_Region)::DownCast( anIter.Value() );
572     if ( aRegion.IsNull() )
573       continue;
574
575     QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
576     aRegion->SetName( aRegionName );
577   }
578 }
579
580 void HYDROData_CalculationCase::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
581 {
582   if ( theRegion.IsNull() )
583     return;
584
585   RemoveReferenceObject( theRegion->Label(), DataTag_Region );
586
587   // Remove region from data model
588   Handle(HYDROData_CalculationCase) aFatherCalc = 
589     Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
590   if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab )
591     theRegion->Remove();
592 }
593
594 void HYDROData_CalculationCase::RemoveRegions()
595 {
596   myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes();
597 }
598
599 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetSplittedGroups() const
600 {
601   return GetReferenceObjects( DataTag_SplittedGroups );
602 }
603
604 void HYDROData_CalculationCase::RemoveSplittedGroups()
605 {
606   myLab.FindChild( DataTag_SplittedGroups ).ForgetAllAttributes();
607 }
608
609 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) const
610 {
611   Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
612   return GetAltitudeForPoint( thePoint, aZone );
613 }
614
615 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&                    thePoint,
616                                                        const Handle(HYDROData_Region)& theRegion ) const
617 {
618   double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
619
620   Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
621   if ( !aZone.IsNull() )
622   {
623     Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
624     if ( IsEqual( aRefRegion, theRegion ) )
625       aResAltitude = GetAltitudeForPoint( thePoint, aZone );
626   }
627
628   return aResAltitude;
629 }
630
631 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&                  thePoint,
632                                                        const Handle(HYDROData_Zone)& theZone ) const
633 {
634   double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
635   if ( theZone.IsNull() )
636     return aResAltitude;
637
638   HYDROData_Zone::MergeAltitudesType aZoneMergeType = theZone->GetMergeType();
639   if ( !theZone->IsMergingNeed() )
640   {
641     aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN;
642   }
643   else if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
644   {
645     return aResAltitude;
646   }
647
648   HYDROData_IInterpolator* aZoneInterpolator = theZone->GetInterpolator();
649   if ( aZoneMergeType == HYDROData_Zone::Merge_Object )
650   {
651     Handle(HYDROData_IAltitudeObject) aMergeAltitude = theZone->GetMergeAltitude();
652     if ( !aMergeAltitude.IsNull() )
653     {
654       if ( aZoneInterpolator != NULL )
655       {
656         aZoneInterpolator->SetAltitudeObject( aMergeAltitude );
657         aResAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
658       }
659       else
660         aResAltitude = aMergeAltitude->GetAltitudeForPoint( thePoint );
661     }
662   }
663   else
664   {
665     HYDROData_SequenceOfObjects aZoneObjects = theZone->GetGeometryObjects();
666     HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects );
667     for ( ; anIter.More(); anIter.Next() )
668     {
669       Handle(HYDROData_Object) aZoneObj =
670         Handle(HYDROData_Object)::DownCast( anIter.Value() );
671       if ( aZoneObj.IsNull() )
672         continue;
673
674       Handle(HYDROData_IAltitudeObject) anObjAltitude = aZoneObj->GetAltitudeObject();
675       if ( anObjAltitude.IsNull() )
676         continue;
677
678       double aPointAltitude = 0.0;
679       if ( aZoneInterpolator != NULL )
680       {
681         aZoneInterpolator->SetAltitudeObject( anObjAltitude );
682         aPointAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
683       }
684       else
685         aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint );
686
687       if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) )
688         continue;
689
690       if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
691       {
692         aResAltitude = aPointAltitude;
693         break;
694       }
695       else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMIN )
696       {
697         if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
698              aResAltitude > aPointAltitude )
699         {
700           aResAltitude = aPointAltitude;
701         }
702       }
703       else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMAX )
704       {
705         if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
706              aResAltitude < aPointAltitude )
707         {
708           aResAltitude = aPointAltitude;
709         }
710       }
711     }
712   }
713
714   return aResAltitude;
715 }
716
717 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints( 
718   const NCollection_Sequence<gp_XY>& thePoints,
719   const Handle(HYDROData_Region)&    theRegion ) const
720 {
721   NCollection_Sequence<double> aResSeq;
722
723   for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
724   {
725     const gp_XY& thePnt = thePoints.Value( i );
726     
727     double anAltitude = GetAltitudeForPoint( thePnt, theRegion );
728     aResSeq.Append( anAltitude );
729   }
730
731   return aResSeq;
732 }
733
734 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints( 
735   const NCollection_Sequence<gp_XY>& thePoints,
736   const Handle(HYDROData_Zone)&      theZone ) const
737 {
738   NCollection_Sequence<double> aResSeq;
739
740   for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
741   {
742     const gp_XY& thePnt = thePoints.Value( i );
743     
744     double anAltitude = GetAltitudeForPoint( thePnt, theZone );
745     aResSeq.Append( anAltitude );
746   }
747
748   return aResSeq;
749 }
750
751 Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
752 {
753   Handle(HYDROData_Region) aResRegion;
754
755   Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
756   if ( !aZone.IsNull() )
757     aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
758
759   return aResRegion;
760 }
761
762 Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
763 {
764   Handle(HYDROData_Zone) aResZone;
765
766   HYDROData_SequenceOfObjects aRegions = GetRegions();
767
768   HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
769   for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() )
770   {
771     Handle(HYDROData_Region) aRegion =
772       Handle(HYDROData_Region)::DownCast( anIter.Value() );
773     if ( aRegion.IsNull() )
774       continue;
775
776     HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
777     HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
778     for ( ; aZonesIter.More() && aResZone.IsNull(); aZonesIter.Next() )
779     {
780       Handle(HYDROData_Zone) aRegZone =
781         Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
782       if ( aRegZone.IsNull() )
783         continue;
784
785       PointClassification aPointRelation = GetPointClassification( thePoint, aRegZone );
786       if ( aPointRelation != POINT_OUT )
787         aResZone = aRegZone; // We found the desired zone
788     }
789   }
790
791   return aResZone;
792 }
793
794 HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPointClassification(
795   const gp_XY&                  thePoint,
796   const Handle(HYDROData_Zone)& theZone ) const
797 {
798   PointClassification aRes = POINT_OUT;
799   if ( theZone.IsNull() )
800     return aRes;
801
802   TopoDS_Face aZoneFace = TopoDS::Face( theZone->GetShape() );
803   if ( aZoneFace.IsNull() )
804     return aRes;
805 #ifdef DEB_CLASS2D      
806           TopoDS_Compound aCmp;
807       BRep_Builder aBB;
808       aBB.MakeCompound(aCmp);
809           aBB.Add(aCmp, aZoneFace);
810           gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
811           BRepBuilderAPI_MakeVertex aMk(aPnt);
812           aBB.Add(aCmp, aMk.Vertex());
813           BRepTools::Write(aCmp, "FCL2d.brep");
814 #endif  
815   TopAbs_State State = HYDROData_Tool::ComputePointState(thePoint, aZoneFace);
816   if (State == TopAbs_OUT)
817     aRes =  POINT_OUT;
818   else if(State == TopAbs_IN)
819     aRes =  POINT_IN;
820   else if(State == TopAbs_ON)
821     aRes =  POINT_ON;
822   return aRes;
823 }
824
825 Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(HYDROData_Document)& theDoc,
826                                                                   const QString& thePrefixOrName,
827                                                                   bool isPrefix )
828 {
829   TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
830
831   Handle(HYDROData_Region) aNewRegion =
832     Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
833   AddRegion( aNewRegion );
834
835   QString aRegionName = isPrefix ? HYDROData_Tool::GenerateObjectName( theDoc, thePrefixOrName ) : thePrefixOrName;
836   aNewRegion->SetName( aRegionName );
837
838   return aNewRegion;
839 }
840
841 Handle(HYDROData_SplittedShapesGroup) HYDROData_CalculationCase::addNewSplittedGroup( const QString& theName )
842 {
843   TDF_Label aNewLab = myLab.FindChild( DataTag_SplittedGroups ).NewChild();
844
845   Handle(HYDROData_SplittedShapesGroup) aNewGroup =
846     Handle(HYDROData_SplittedShapesGroup)::DownCast( 
847       HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLITTED_GROUP ) );
848   AddReferenceObject( aNewGroup, DataTag_SplittedGroups );
849
850   aNewGroup->SetName( theName );
851
852   return aNewGroup;
853 }
854
855 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
856                                         SALOMEDS::Study_ptr theStudy ) const
857 {
858   HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
859
860   // Get groups definitions
861   HYDROData_SequenceOfObjects aSplittedGroups = GetSplittedGroups();
862
863   HYDROData_SequenceOfObjects::Iterator anIter( aSplittedGroups );
864   for ( ; anIter.More(); anIter.Next() )
865   {
866     // Get shapes group
867     Handle(HYDROData_ShapesGroup) aGroup =
868       Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
869     if ( aGroup.IsNull() )
870       continue;
871
872     HYDROData_ShapesGroup::GroupDefinition aGroupDef;
873
874     aGroupDef.Name = aGroup->GetName().toLatin1().constData();
875     aGroup->GetShapes( aGroupDef.Shapes );
876
877     aSeqOfGroupsDefs.Append( aGroupDef );
878   }
879   
880   // Get faces
881   TopTools_ListOfShape aFaces;
882   HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
883   HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
884   for ( ; aRegionIter.More(); aRegionIter.Next() )
885   {
886     Handle(HYDROData_Region) aRegion =
887       Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
888     if( aRegion.IsNull() )
889       continue;
890
891     TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
892     aFaces.Append( aRegionShape );
893   }
894
895   return Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs );
896 }
897
898 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var                            theGeomEngine,
899                                         SALOMEDS::Study_ptr                           theStudy,
900                                         const TopTools_ListOfShape&                   theFaces,
901                                         const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const
902 {
903   // Sew faces
904   BRepBuilderAPI_Sewing aSewing( Precision::Confusion() * 10.0 );
905   aSewing.SetNonManifoldMode( Standard_False );
906 #ifdef DEB_CALCULATION
907   TCollection_AsciiString aNam("Sh_");
908   int i=1;
909 #endif
910   TopTools_ListIteratorOfListOfShape aFaceIter( theFaces );
911   for ( ; aFaceIter.More(); aFaceIter.Next() )
912   {
913     TopoDS_Shape aShape = aFaceIter.Value();
914     if ( aShape.IsNull() )
915       continue;
916
917     if ( aShape.ShapeType() == TopAbs_FACE )
918     {
919       aSewing.Add( aShape );
920 #ifdef DEB_CALCULATION
921       TCollection_AsciiString aName = aNam + ++i + ".brep";
922       BRepTools::Write(aShape ,aName.ToCString());
923 #endif
924     }
925     else
926     {
927 #ifdef DEB_CALCULATION
928       int j = 1;
929 #endif
930       TopExp_Explorer anExp( aShape, TopAbs_FACE );
931       for (; anExp.More(); anExp.Next() ) {
932         aSewing.Add( anExp.Current() );
933 #ifdef DEB_CALCULATION
934
935         TCollection_AsciiString aName = aNam + i + "_" + ++j + ".brep";
936         BRepTools::Write(anExp.Current() ,aName.ToCString());
937 #endif
938       }
939     }
940   } // faces iterator
941   
942   aSewing.Perform();
943   TopoDS_Shape aSewedShape = aSewing.SewedShape();
944
945   // If the sewed shape is empty - return false
946   if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() )
947     return false;
948
949 #ifdef DEB_CALCULATION
950   BRepTools::Write(aSewedShape ,"Sew.brep");
951 #endif
952   // Publish the sewed shape
953   QString aName = EXPORT_NAME;
954   GEOM::GEOM_Object_ptr aMainShape = 
955     publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName );
956
957   if ( aMainShape->_is_nil() )  
958     return false;
959
960   if ( theGroupsDefs.IsEmpty() )
961     return true;
962
963   // Create groups
964   TopTools_IndexedMapOfShape aMapOfSubShapes;
965   TopExp::MapShapes( aSewedShape, aMapOfSubShapes );
966
967   NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> > aGroupsData;
968
969   for ( int aGrId = 1, nbGroups = theGroupsDefs.Length(); aGrId <= nbGroups; ++aGrId )
970   {
971     const HYDROData_ShapesGroup::GroupDefinition& aGroupDef = theGroupsDefs.Value( aGrId );
972
973     NCollection_Sequence<int> aGroupIndexes;
974     for( int i = 1, n = aGroupDef.Shapes.Length(); i <= n; i++ )
975     {
976       const TopoDS_Shape& aShape = aGroupDef.Shapes.Value( i );
977 #ifdef DEB_CALCULATION
978       cout << "\nOld shape(" << i << ") = " << aShape.TShape() <<endl;
979 #endif
980       
981       TopoDS_Shape aModifiedShape = aShape;
982       if ( aSewing.IsModified( aShape ) )
983         aModifiedShape = aSewing.Modified( aShape );
984       else if ( aSewing.IsModifiedSubShape( aShape ) )
985         aModifiedShape = aSewing.ModifiedSubShape( aShape );
986
987 #ifdef DEB_CALCULATION
988       const TopLoc_Location& aL1 = aShape.Location();
989       const TopLoc_Location& aL2 = aModifiedShape.Location();
990       cout << "\nNew shape(" << i << ") = " << aModifiedShape.TShape() << " Location is Equal = " << aL1.IsEqual(aL2)<<endl;
991 #endif
992
993       int anIndex = aMapOfSubShapes.FindIndex(aModifiedShape);
994       if ( anIndex > 0 ) {
995         aGroupIndexes.Append( anIndex );
996       } else {
997 #ifdef DEB_CALCULATION    
998         TCollection_AsciiString aNam("Lost_");
999         if(!aMapOfSubShapes.Contains(aModifiedShape)) {
1000         for ( int anIndex = 1; anIndex <= aMapOfSubShapes.Extent(); anIndex++ )
1001         {
1002            const TopoDS_Shape& aS = aMapOfSubShapes.FindKey( anIndex );
1003            if ( aModifiedShape.IsPartner( aS ) )
1004            {
1005              cout <<"\nIndex in Map = " << anIndex << "TShape = " << aS.TShape() <<endl;
1006              TCollection_AsciiString aName = aNam + i + "_" + anIndex + ".brep";
1007              BRepTools::Write(aS ,aName.ToCString());
1008             break;
1009            }
1010          }
1011         }
1012 #endif
1013       }
1014     }
1015     if ( !aGroupIndexes.IsEmpty() )
1016       aGroupsData.Bind( aGroupDef.Name, aGroupIndexes );
1017   }
1018  
1019   if ( !aGroupsData.IsEmpty() )
1020   {
1021     GEOM::GEOM_IGroupOperations_var aGroupOp = 
1022       theGeomEngine->GetIGroupOperations( theStudy->StudyId() );  
1023
1024     NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> >::Iterator aMapIt( aGroupsData );
1025     for ( ; aMapIt.More(); aMapIt.Next() )
1026     {
1027       const TCollection_AsciiString& aGroupName = aMapIt.Key(); 
1028       const NCollection_Sequence<int>& aGroupIndexes = aMapIt.Value();
1029
1030       GEOM::GEOM_Object_var aGeomGroup = aGroupOp->CreateGroup( aMainShape, TopAbs_EDGE );
1031       if ( CORBA::is_nil( aGeomGroup ) || !aGroupOp->IsDone() )
1032         continue;
1033
1034       GEOM::ListOfLong_var aGeomIndexes = new GEOM::ListOfLong;
1035       aGeomIndexes->length( aGroupIndexes.Length() );
1036
1037       for( int i = 1, n = aGroupIndexes.Length(); i <= n; i++ )
1038         aGeomIndexes[ i - 1 ] = aGroupIndexes.Value( i );
1039
1040       aGroupOp->UnionIDs( aGeomGroup, aGeomIndexes );
1041       if ( aGroupOp->IsDone() )
1042       {
1043         SALOMEDS::SObject_var aGroupSO = 
1044           theGeomEngine->AddInStudy( theStudy, aGeomGroup, aGroupName.ToCString(), aMainShape );
1045       }
1046     }
1047   }
1048
1049   return true;
1050 }
1051
1052 GEOM::GEOM_Object_ptr HYDROData_CalculationCase::publishShapeInGEOM( 
1053   GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy,
1054   const TopoDS_Shape& theShape, const QString& theName ) const
1055 {
1056   GEOM::GEOM_Object_var aGeomObj;
1057
1058   if ( theGeomEngine->_is_nil() || theStudy->_is_nil() ||
1059        theShape.IsNull() ) {
1060     return aGeomObj._retn();
1061   }
1062
1063   std::ostringstream aStreamShape;
1064   // Write TopoDS_Shape in ASCII format to the stream
1065   BRepTools::Write( theShape, aStreamShape );
1066   // Returns the number of bytes that have been stored in the stream's buffer.
1067   int aSize = aStreamShape.str().size();
1068   // Allocate octect buffer of required size
1069   CORBA::Octet* anOctetBuf = SALOMEDS::TMPFile::allocbuf( aSize );
1070   // Copy ostrstream content to the octect buffer
1071   memcpy( anOctetBuf, aStreamShape.str().c_str(), aSize );
1072   // Create TMPFile
1073   SALOMEDS::TMPFile_var aSeqFile = new SALOMEDS::TMPFile( aSize, aSize, anOctetBuf, 1 );
1074
1075   // Restore shape from the stream and get the GEOM object
1076   GEOM::GEOM_IInsertOperations_var anInsOp = theGeomEngine->GetIInsertOperations( theStudy->StudyId() );
1077   aGeomObj = anInsOp->RestoreShape( aSeqFile );
1078   
1079   // Puplish the GEOM object
1080   if ( !aGeomObj->_is_nil() ) {
1081     QString aName = GEOMBase::GetDefaultName( theName );
1082
1083     SALOMEDS::SObject_var aResultSO = 
1084       theGeomEngine->PublishInStudy( theStudy, SALOMEDS::SObject::_nil(), 
1085                                      aGeomObj, qPrintable( aName ) );
1086     if ( aResultSO->_is_nil() ) {
1087       aGeomObj = GEOM::GEOM_Object::_nil();
1088     }
1089   }
1090
1091   return aGeomObj._retn();
1092 }
1093
1094 void HYDROData_CalculationCase::ClearRules( const bool theIsSetToUpdate )
1095 {
1096   TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1097   HYDROData_PriorityQueue::ClearRules( aRulesLab );
1098
1099   // Indicate model of the need to update splitting
1100   if ( theIsSetToUpdate ) {
1101     SetToUpdate( true );
1102   }
1103 }
1104
1105 void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Object)&    theObject1,
1106                                          HYDROData_PriorityType             thePriority,
1107                                          const Handle(HYDROData_Object)&    theObject2,
1108                                          HYDROData_Zone::MergeAltitudesType theMergeType )
1109 {
1110   TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1111   HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
1112
1113   // Indicate model of the need to update splitting
1114   SetToUpdate( true );
1115 }
1116
1117 QString HYDROData_CalculationCase::DumpRules() const
1118 {
1119   TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1120   return HYDROData_PriorityQueue::DumpRules( aRulesLab );
1121 }
1122
1123 void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
1124 {
1125   TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode );
1126   TDataStd_Integer::Set( aModeLab, ( int ) theMode );
1127
1128   // Indicate model of the need to update splitting
1129   SetToUpdate( true );
1130 }
1131
1132 HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const
1133 {
1134   Handle(TDataStd_Integer) aModeAttr;
1135   bool isOK = myLab.FindChild( DataTag_AssignmentMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
1136   if( isOK )
1137     return ( AssignmentMode ) aModeAttr->Get();
1138   else
1139     return MANUAL;
1140 }
1141
1142 void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseName,
1143                                                    QStringList& theScript ) const
1144 {
1145   TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1146   HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
1147 }
1148
1149 HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const
1150 {
1151   return myLastWarning;
1152 }
1153
1154 void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const QString& theData )
1155 {
1156   myLastWarning.Type = theType;
1157   myLastWarning.Data = theData;
1158 }
1159
1160 int HYDROData_CalculationCase::GetRulesCount() const
1161 {
1162   TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1163   return HYDROData_PriorityQueue::GetRulesCount( aRulesLab );
1164 }
1165
1166 bool HYDROData_CalculationCase::GetRule( int theIndex, 
1167                                          Handle(HYDROData_Object)&           theObject1,
1168                                          HYDROData_PriorityType&             thePriority,
1169                                          Handle(HYDROData_Object)&           theObject2,
1170                                          HYDROData_Zone::MergeAltitudesType& theMergeType ) const
1171 {
1172   TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1173   return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
1174     theObject1, thePriority, theObject2, theMergeType );
1175 }