1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROData_CalculationCase.h"
21 #include "HYDROData_ArtificialObject.h"
22 #include "HYDROData_IAltitudeObject.h"
23 #include "HYDROData_Document.h"
24 #include "HYDROData_ShapesGroup.h"
25 #include "HYDROData_Iterator.h"
26 #include "HYDROData_NaturalObject.h"
27 #include "HYDROData_PolylineXY.h"
28 #include "HYDROData_StricklerTable.h"
29 #include "HYDROData_LandCover.h"
30 #include "HYDROData_SplittedShapesGroup.h"
31 #include "HYDROData_Region.h"
32 #include "HYDROData_Tool.h"
33 #include "HYDROData_GeomTool.h"
40 #include <TopoDS_Shell.hxx>
41 #include <TopoDS_Edge.hxx>
43 #include <BRep_Builder.hxx>
44 #include <BRepBuilderAPI_Sewing.hxx>
45 #include <BRepTopAdaptor_FClass2d.hxx>
47 #include <BRepTools.hxx>
50 #include <TopExp_Explorer.hxx>
52 #include <TopTools_ListOfShape.hxx>
53 #include <TopTools_ListIteratorOfListOfShape.hxx>
54 #include <TDataStd_Integer.hxx>
56 //#define DEB_CALCULATION 1
57 #ifdef DEB_CALCULATION
58 #include <BRepTools.hxx>
59 #include <TopLoc_Location.hxx>
61 #define CALCULATION_REGIONS_PREF GetName() + "_Reg"
62 #define CALCULATION_ZONES_PREF GetName() + "_Zone"
63 #define CALCULATION_GROUPS_PREF GetName() + "_"
64 //#define DEB_CLASS2D 1
66 #include <BRepBuilderAPI_MakeVertex.hxx>
69 #define EXPORT_NAME "HYDRO_" + GetName()
71 #include <SALOME_NamingService.hxx>
72 #include <SALOME_LifeCycleCORBA.hxx>
75 #include "HYDRO_trace.hxx"
77 IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
78 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
80 HYDROData_CalculationCase::HYDROData_CalculationCase()
85 HYDROData_CalculationCase::~HYDROData_CalculationCase()
89 void HYDROData_CalculationCase::SetName( const QString& theName )
91 QString anOldCaseName = GetName();
92 if ( anOldCaseName != theName )
94 HYDROData_SequenceOfObjects aRegions = GetRegions();
96 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
97 for ( ; anIter.More(); anIter.Next() )
99 Handle(HYDROData_Region) aRegion =
100 Handle(HYDROData_Region)::DownCast( anIter.Value() );
101 if ( aRegion.IsNull() )
104 HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegion );
106 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
107 HYDROData_SequenceOfObjects::Iterator anIter( aZones );
108 for ( ; anIter.More(); anIter.Next() )
110 Handle(HYDROData_Zone) aRegZone =
111 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
112 if ( aRegZone.IsNull() )
115 HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegZone );
119 HYDROData_SequenceOfObjects aGroups = GetSplittedGroups();
121 anIter.Init( aGroups );
122 for ( ; anIter.More(); anIter.Next() )
124 Handle(HYDROData_SplittedShapesGroup) aGroup =
125 Handle(HYDROData_SplittedShapesGroup)::DownCast( anIter.Value() );
126 if ( aGroup.IsNull() )
129 HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aGroup );
133 HYDROData_Entity::SetName( theName );
136 QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
138 QStringList aResList = dumpObjectCreation( theTreatedObjects );
139 aResList.prepend( "# Calculation case" );
141 QString aCalculName = GetObjPyName();
143 AssignmentMode aMode = GetAssignmentMode();
144 QString aModeStr = aMode==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC";
145 aResList << QString( "%0.SetAssignmentMode( %1 )" ).arg( aCalculName ).arg( aModeStr );
147 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
148 HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
149 for ( ; anIter.More(); anIter.Next() )
151 Handle(HYDROData_Object) aRefGeomObj =
152 Handle(HYDROData_Object)::DownCast( anIter.Value() );
153 setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
155 aResList << QString( "" );
157 QString aGroupName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "case_geom_group" );
159 HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
160 anIter.Init( aGeomGroups );
161 for ( ; anIter.More(); anIter.Next() )
163 Handle(HYDROData_ShapesGroup) aGeomGroup =
164 Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
165 if ( aGeomGroup.IsNull() )
168 Handle(HYDROData_Object) aFatherGeom =
169 Handle(HYDROData_Object)::DownCast( aGeomGroup->GetFatherObject() );
170 if ( aFatherGeom.IsNull() )
173 int aGroupId = aFatherGeom->GetGroupId( aGeomGroup );
174 aResList << QString( "%1 = %2.GetGroup( %3 );" )
175 .arg( aGroupName ).arg( aFatherGeom->GetObjPyName() ).arg( aGroupId );
177 aResList << QString( "%1.AddGeometryGroup( %2 );" ).arg( aCalculName ).arg( aGroupName );
180 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
181 setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
183 if( aMode==AUTOMATIC )
184 DumpRulesToPython( aCalculName, aResList );
186 aResList << QString( "" );
187 aResList << "# Start the algorithm of the partition and assignment";
188 aResList << QString( "%1.Update();" ).arg( aCalculName );
192 // Now we restore the regions and zones order
193 HYDROData_SequenceOfObjects aRegions = GetRegions();
194 anIter.Init( aRegions );
195 for ( ; anIter.More(); anIter.Next() )
197 Handle(HYDROData_Region) aRegion =
198 Handle(HYDROData_Region)::DownCast( anIter.Value() );
199 if ( aRegion.IsNull() )
202 theTreatedObjects.insert( aRegion->GetName(), aRegion );
203 QStringList aRegDump = aRegion->DumpToPython( theTreatedObjects );
204 aResList << aRegDump;
208 // Export calculation case
209 aResList << QString( "" );
210 aResList << "# Export of the calculation case";
211 QString aStudyName = "theStudy";
212 QString anEntryVar = aCalculName + "_entry";
213 aResList << QString( "%1 = %2.Export( %3._get_StudyId() )" ).arg( anEntryVar ).arg( aCalculName ).arg( aStudyName );
215 // Get geometry object and print debug information
217 aResList << "# Get geometry shape and print debug information";
218 aResList << "import GEOM";
219 aResList << QString( "print \"Entry:\", %1" ).arg( anEntryVar );
220 QString aGeomShapeName = aCalculName + "_geom";
221 aResList << QString( "%1 = salome.IDToObject( str( %2 ) )" ).arg( aGeomShapeName ).arg( anEntryVar );
222 aResList << QString( "print \"Geom shape:\", %1" ).arg( aGeomShapeName );
223 aResList << QString( "print \"Geom shape name:\", %1.GetName()" ).arg( aGeomShapeName );
225 DumpSampleMeshing( aResList, aStudyName, aGeomShapeName, aCalculName+"_mesh" );
227 aResList << QString( "" );
231 void HYDROData_CalculationCase::DumpSampleMeshing( QStringList& theResList,
232 const QString& theStudyName,
233 const QString& theGeomShapeName,
234 const QString& theMeshName ) const
237 theResList << "# Meshing";
238 theResList << "import SMESH, SALOMEDS";
239 theResList << "from salome.smesh import smeshBuilder";
240 theResList << "from salome.geom import geomBuilder";
242 theResList << QString( "smesh = smeshBuilder.New( %1 )" ).arg( theStudyName );
243 theResList << QString( "%1 = smesh.Mesh( %2 )" ).arg( theMeshName ).arg( theGeomShapeName );
244 theResList << QString( "MEFISTO_2D = %1.Triangle( algo=smeshBuilder.MEFISTO )" ).arg( theMeshName );
245 theResList << "Max_Element_Area_1 = MEFISTO_2D.MaxElementArea( 10 )";
246 theResList << QString( "Regular_1D = %1.Segment()" ).arg( theMeshName );
247 theResList << "Max_Size_1 = Regular_1D.MaxSize(10)";
248 theResList << QString( "isDone = %1.Compute()" ).arg( theMeshName );
251 theResList << "# Set names of Mesh objects";
252 theResList << "smesh.SetName( MEFISTO_2D.GetAlgorithm(), 'MEFISTO_2D' )";
253 theResList << "smesh.SetName( Regular_1D.GetAlgorithm(), 'Regular_1D' )";
254 theResList << "smesh.SetName( Max_Size_1, 'Max Size_1' )";
255 theResList << "smesh.SetName( Max_Element_Area_1, 'Max. Element Area_1' )";
256 theResList << QString( "smesh.SetName( %1.GetMesh(), '%1' )" ).arg( theMeshName );
259 theResList << "# Greate SMESH groups";
260 theResList << QString( "geompy = geomBuilder.New( %1 )" ).arg( theStudyName );
261 theResList << QString( "geom_groups = geompy.GetGroups( %1 )" ).arg( theGeomShapeName );
262 theResList << QString( "for group in geom_groups:" );
263 theResList << QString( " smesh_group = %1.GroupOnGeom(group, group.GetName(), SMESH.EDGE)" )
265 theResList << QString( " smesh.SetName(smesh_group, group.GetName())" );
266 theResList << QString( " print \"SMESH group '%s': %s\" % (smesh_group.GetName(), smesh_group)" );
269 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() const
271 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
273 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
274 if ( !aBoundaryPolyline.IsNull() )
275 aResSeq.Append( aBoundaryPolyline );
277 HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
278 aResSeq.Append( aSeqOfRegions );
283 void HYDROData_CalculationCase::Update()
285 HYDROData_Entity::Update();
288 // At first we remove previously created objects
290 RemoveSplittedGroups();
292 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
293 if ( aDocument.IsNull() )
296 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
297 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
298 if ( aGeomObjects.IsEmpty() )
301 HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
303 HYDROData_SplitToZonesTool::SplitDataList aSplitObjects =
304 HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline );
305 if ( aSplitObjects.isEmpty() )
308 HYDROData_SplitToZonesTool::SplitDataList aZonesList, anEdgesList;
310 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitObjects );
311 while( anIter.hasNext() )
313 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
314 if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
315 aZonesList.append( aSplitData );
316 else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
317 anEdgesList.append( aSplitData );
320 switch( GetAssignmentMode() )
323 CreateRegionsDef( aDocument, aZonesList );
326 CreateRegionsAuto( aDocument, aZonesList );
329 CreateEdgeGroupsDef( aDocument, anEdgesList );
332 void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
333 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
335 // Create result regions for case, by default one zone for one region
336 QString aRegsPref = CALCULATION_REGIONS_PREF;
337 QString aZonesPref = CALCULATION_ZONES_PREF;
339 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
340 while( anIter.hasNext() )
342 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
344 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref );
346 // Add the zone for region
347 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
351 void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
352 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
354 QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
355 QMap<QString, QString> aRegionNameToObjNameMap;
356 QString aZonesPref = CALCULATION_ZONES_PREF;
357 HYDROData_PriorityQueue aPr( this, DataTag_CustomRules );
359 // 1. First we create a default region for each object included into the calculation case
360 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
361 for( int i=aGeomObjects.Lower(), n=aGeomObjects.Upper(); i<=n; i++ )
363 Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( aGeomObjects.Value( i ) );
366 QString anObjName = anObj->GetName();
367 QString aRegName = anObjName + "_reg";
368 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false );
369 aRegionsMap.insert( anObjName, aRegion );
370 aRegionNameToObjNameMap.insert( aRegName, anObjName );
373 // 2. Now for each zone it is necessary to determine the most priority object
374 // and assign to zone to corresponding region
375 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
376 while( anIter.hasNext() )
378 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
379 HYDROData_Zone::MergeAltitudesType aMergeType;
380 Handle(HYDROData_Object) aRegObj =
381 Handle(HYDROData_Object)::DownCast( aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType ) );
382 if( aRegObj.IsNull() )
384 Handle(HYDROData_Region) aRegion = aRegionsMap[aRegObj->GetName()];
385 if( aRegion.IsNull() )
387 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
389 if( aSplitData.ObjectNames.count() > 1 && aMergeType==HYDROData_Zone::Merge_UNKNOWN )
391 qDebug( "Error in algorithm: unresolved conflicts" );
396 case HYDROData_Zone::Merge_ZMIN:
397 case HYDROData_Zone::Merge_ZMAX:
398 aRegionZone->SetMergeType( aMergeType );
400 case HYDROData_Zone::Merge_Object:
401 aRegionZone->SetMergeType( aMergeType );
402 aRegionZone->RemoveMergeAltitude();
403 aRegionZone->SetMergeAltitude( aRegObj->GetAltitudeObject() );
408 QStringList anObjectsWithEmptyRegions;
409 QMap<QString, Handle(HYDROData_Region)>::const_iterator
410 anIt = aRegionsMap.begin(), aLast = aRegionsMap.end();
411 for( ; anIt!=aLast; anIt++ )
413 Handle(HYDROData_Region) aRegion = anIt.value();
414 if( aRegion->GetZones().IsEmpty() )
416 QString aRegName = aRegion->GetName();
417 QString anObjName = aRegionNameToObjNameMap[aRegName];
418 anObjectsWithEmptyRegions.append( anObjName );
422 if( !anObjectsWithEmptyRegions.empty() )
424 QString aData = anObjectsWithEmptyRegions.join( ", " );
425 SetWarning( WARN_EMPTY_REGIONS, aData );
429 void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
430 const HYDROData_SplitToZonesTool::SplitDataList& theEdges )
432 QMap<QString,Handle(HYDROData_SplittedShapesGroup)> aSplittedEdgesGroupsMap;
434 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges );
435 while( anIter.hasNext() )
437 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
438 // Create new edges group
439 if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
442 QString anObjName = aSplitData.ObjectNames.first();
443 if ( anObjName.isEmpty() )
445 #ifdef DEB_CALCULATION
446 QString aStr = aSplitData.ObjectNames.join(" ");
447 cout << " CCase: Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size() <<endl;
449 Handle(HYDROData_SplittedShapesGroup) aSplittedGroup;
450 if ( !aSplittedEdgesGroupsMap.contains( anObjName ) )
452 aSplittedGroup = addNewSplittedGroup( CALCULATION_GROUPS_PREF + anObjName );
453 aSplittedEdgesGroupsMap.insert( anObjName, aSplittedGroup );
457 aSplittedGroup = aSplittedEdgesGroupsMap[ anObjName ];
459 if ( aSplittedGroup.IsNull() )
462 aSplittedGroup->AddShape( aSplitData.Shape );
466 bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
468 if ( !HYDROData_Tool::IsGeometryObject( theObject ) )
469 return false; // Wrong type of object
471 if ( HasReference( theObject, DataTag_GeometryObject ) )
472 return false; // Object is already in reference list
474 AddReferenceObject( theObject, DataTag_GeometryObject );
476 // Indicate model of the need to update splitting
482 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryObjects() const
484 return GetReferenceObjects( DataTag_GeometryObject );
487 void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject )
489 if ( theObject.IsNull() )
492 RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
494 // Indicate model of the need to update splitting
498 void HYDROData_CalculationCase::RemoveGeometryObjects()
500 ClearReferenceObjects( DataTag_GeometryObject );
502 // Indicate model of the need to update splitting
506 bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
508 if ( theGroup.IsNull() )
511 if ( HasReference( theGroup, DataTag_GeometryGroup ) )
512 return false; // Object is already in reference list
514 AddReferenceObject( theGroup, DataTag_GeometryGroup );
516 // Indicate model of the need to update splitting
522 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryGroups() const
524 return GetReferenceObjects( DataTag_GeometryGroup );
527 void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
529 if ( theGroup.IsNull() )
532 RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
534 // Indicate model of the need to update splitting
538 void HYDROData_CalculationCase::RemoveGeometryGroups()
540 ClearReferenceObjects( DataTag_GeometryGroup );
542 // Indicate model of the need to update splitting
546 void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
548 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
550 SetReferenceObject( thePolyline, DataTag_Polyline );
552 // Indicate model of the need to update zones splitting
553 SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() );
556 Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
558 return Handle(HYDROData_PolylineXY)::DownCast(
559 GetReferenceObject( DataTag_Polyline ) );
562 void HYDROData_CalculationCase::RemoveBoundaryPolyline()
564 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
566 ClearReferenceObjects( DataTag_Polyline );
568 // Indicate model of the need to update zones splitting
569 SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() );
572 void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
574 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
576 SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
578 // Indicate model of the need to update land covers partition
579 SetToUpdate( !IsEqual( aPrevStricklerTable, theStricklerTable ) || IsMustBeUpdated() );
582 Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
584 return Handle(HYDROData_StricklerTable)::DownCast(
585 GetReferenceObject( DataTag_StricklerTable ) );
588 void HYDROData_CalculationCase::RemoveStricklerTable()
590 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
592 ClearReferenceObjects( DataTag_StricklerTable );
594 // Indicate model of the need to update land covers partition
595 SetToUpdate( !aPrevStricklerTable.IsNull() || IsMustBeUpdated() );
598 bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& theLandCover )
600 if ( HasReference( theLandCover, DataTag_LandCover ) )
601 return false; // Land cover is already in reference list
603 AddReferenceObject( theLandCover, DataTag_LandCover );
605 // Indicate model of the need to update land covers partition
611 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetLandCovers() const
613 return GetReferenceObjects( DataTag_LandCover );
616 void HYDROData_CalculationCase::RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover )
618 if ( theLandCover.IsNull() )
621 RemoveReferenceObject( theLandCover->Label(), DataTag_LandCover );
623 // Indicate model of the need to update land cover partition
627 void HYDROData_CalculationCase::RemoveLandCovers()
629 ClearReferenceObjects( DataTag_LandCover );
631 // Indicate model of the need to update land cover partition
635 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
637 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
638 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
639 if ( aNewRegion.IsNull() )
642 aNewRegion->AddZone( theZone );
647 bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion )
649 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
651 if ( theRegion.IsNull() )
654 if ( HasReference( theRegion, DataTag_Region ) )
655 return false; // Object is already in reference list
657 // Move the region from other calculation
658 Handle(HYDROData_CalculationCase) aFatherCalc =
659 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
660 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
662 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
663 theRegion->CopyTo( aNewRegion );
665 aFatherCalc->RemoveRegion( theRegion );
667 theRegion->SetLabel( aNewRegion->Label() );
671 AddReferenceObject( theRegion, DataTag_Region );
677 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const
679 return GetReferenceObjects( DataTag_Region );
682 void HYDROData_CalculationCase::UpdateRegionsOrder()
684 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
685 if ( aDocument.IsNull() )
688 HYDROData_SequenceOfObjects aRegions = GetRegions();
690 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
691 for ( ; anIter.More(); anIter.Next() )
693 Handle(HYDROData_Region) aRegion =
694 Handle(HYDROData_Region)::DownCast( anIter.Value() );
695 if ( aRegion.IsNull() )
698 aRegion->SetName( "" );
701 QString aRegsPref = CALCULATION_REGIONS_PREF;
703 anIter.Init( aRegions );
704 for ( ; anIter.More(); anIter.Next() )
706 Handle(HYDROData_Region) aRegion =
707 Handle(HYDROData_Region)::DownCast( anIter.Value() );
708 if ( aRegion.IsNull() )
711 QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
712 aRegion->SetName( aRegionName );
716 void HYDROData_CalculationCase::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
718 if ( theRegion.IsNull() )
721 RemoveReferenceObject( theRegion->Label(), DataTag_Region );
723 // Remove region from data model
724 Handle(HYDROData_CalculationCase) aFatherCalc =
725 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
726 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab )
730 void HYDROData_CalculationCase::RemoveRegions()
732 myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes();
735 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetSplittedGroups() const
737 return GetReferenceObjects( DataTag_SplittedGroups );
740 void HYDROData_CalculationCase::RemoveSplittedGroups()
742 myLab.FindChild( DataTag_SplittedGroups ).ForgetAllAttributes();
745 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) const
747 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
748 return GetAltitudeForPoint( thePoint, aZone );
751 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
752 const Handle(HYDROData_Region)& theRegion ) const
754 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
756 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
757 if ( !aZone.IsNull() )
759 //DEBTRACE("GetAltitudeForPoint Region " << theRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString());
760 Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
761 if ( IsEqual( aRefRegion, theRegion ) )
762 aResAltitude = GetAltitudeForPoint( thePoint, aZone );
765 DEBTRACE("GetAltitudeForPoint Region " << aRefRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString() << " ---------------------------");
766 aResAltitude = GetAltitudeForPoint( thePoint, aZone );
771 DEBTRACE(" --- GetAltitudeForPoint No Zone ---");
777 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
778 const Handle(HYDROData_Zone)& theZone ) const
780 //DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString());
781 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
782 if ( theZone.IsNull() )
785 HYDROData_Zone::MergeAltitudesType aZoneMergeType = theZone->GetMergeType();
786 if ( !theZone->IsMergingNeed() )
788 aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN;
790 else if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
795 HYDROData_IInterpolator* aZoneInterpolator = theZone->GetInterpolator();
796 if ( aZoneMergeType == HYDROData_Zone::Merge_Object )
798 Handle(HYDROData_IAltitudeObject) aMergeAltitude = theZone->GetMergeAltitude();
799 if ( !aMergeAltitude.IsNull() )
801 if ( aZoneInterpolator != NULL )
803 aZoneInterpolator->SetAltitudeObject( aMergeAltitude );
804 aResAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
807 aResAltitude = aMergeAltitude->GetAltitudeForPoint( thePoint );
812 HYDROData_SequenceOfObjects aZoneObjects = theZone->GetGeometryObjects();
813 HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects );
814 for ( ; anIter.More(); anIter.Next() )
816 Handle(HYDROData_Object) aZoneObj =
817 Handle(HYDROData_Object)::DownCast( anIter.Value() );
818 if ( aZoneObj.IsNull() )
821 Handle(HYDROData_IAltitudeObject) anObjAltitude = aZoneObj->GetAltitudeObject();
822 if ( anObjAltitude.IsNull() )
825 double aPointAltitude = 0.0;
826 if ( aZoneInterpolator != NULL )
828 aZoneInterpolator->SetAltitudeObject( anObjAltitude );
829 aPointAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
832 aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint );
834 if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) )
837 if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
839 aResAltitude = aPointAltitude;
842 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMIN )
844 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
845 aResAltitude > aPointAltitude )
847 aResAltitude = aPointAltitude;
850 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMAX )
852 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
853 aResAltitude < aPointAltitude )
855 aResAltitude = aPointAltitude;
864 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
865 const NCollection_Sequence<gp_XY>& thePoints,
866 const Handle(HYDROData_Region)& theRegion ) const
868 //DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString());
869 NCollection_Sequence<double> aResSeq;
871 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
873 const gp_XY& thePnt = thePoints.Value( i );
875 double anAltitude = GetAltitudeForPoint( thePnt, theRegion );
876 aResSeq.Append( anAltitude );
882 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
883 const NCollection_Sequence<gp_XY>& thePoints,
884 const Handle(HYDROData_Zone)& theZone ) const
886 NCollection_Sequence<double> aResSeq;
888 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
890 const gp_XY& thePnt = thePoints.Value( i );
892 double anAltitude = GetAltitudeForPoint( thePnt, theZone );
893 aResSeq.Append( anAltitude );
899 Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
901 Handle(HYDROData_Region) aResRegion;
903 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
904 if ( !aZone.IsNull() )
905 aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
910 Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
912 Handle(HYDROData_Zone) aResZone;
914 HYDROData_SequenceOfObjects aRegions = GetRegions();
916 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
917 for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() )
919 Handle(HYDROData_Region) aRegion =
920 Handle(HYDROData_Region)::DownCast( anIter.Value() );
921 if ( aRegion.IsNull() )
924 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
925 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
926 for ( ; aZonesIter.More() && aResZone.IsNull(); aZonesIter.Next() )
928 Handle(HYDROData_Zone) aRegZone =
929 Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
930 if ( aRegZone.IsNull() )
933 PointClassification aPointRelation = GetPointClassification( thePoint, aRegZone );
934 if ( aPointRelation != POINT_OUT )
935 aResZone = aRegZone; // We found the desired zone
942 HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPointClassification(
943 const gp_XY& thePoint,
944 const Handle(HYDROData_Zone)& theZone ) const
946 PointClassification aRes = POINT_OUT;
947 if ( theZone.IsNull() )
950 TopoDS_Face aZoneFace = TopoDS::Face( theZone->GetShape() );
951 if ( aZoneFace.IsNull() )
954 TopoDS_Compound aCmp;
956 aBB.MakeCompound(aCmp);
957 aBB.Add(aCmp, aZoneFace);
958 gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
959 BRepBuilderAPI_MakeVertex aMk(aPnt);
960 aBB.Add(aCmp, aMk.Vertex());
961 BRepTools::Write(aCmp, "FCL2d.brep");
963 TopAbs_State State = HYDROData_Tool::ComputePointState(thePoint, aZoneFace);
964 if (State == TopAbs_OUT)
966 else if(State == TopAbs_IN)
968 else if(State == TopAbs_ON)
973 Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(HYDROData_Document)& theDoc,
974 const QString& thePrefixOrName,
977 TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
978 int aTag = aNewLab.Tag();
980 Handle(HYDROData_Region) aNewRegion =
981 Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
982 AddRegion( aNewRegion );
984 QString aRegionName = isPrefix ? HYDROData_Tool::GenerateObjectName( theDoc, thePrefixOrName ) : thePrefixOrName;
985 aNewRegion->SetName( aRegionName );
990 Handle(HYDROData_SplittedShapesGroup) HYDROData_CalculationCase::addNewSplittedGroup( const QString& theName )
992 TDF_Label aNewLab = myLab.FindChild( DataTag_SplittedGroups ).NewChild();
994 Handle(HYDROData_SplittedShapesGroup) aNewGroup =
995 Handle(HYDROData_SplittedShapesGroup)::DownCast(
996 HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLITTED_GROUP ) );
997 AddReferenceObject( aNewGroup, DataTag_SplittedGroups );
999 aNewGroup->SetName( theName );
1004 QString HYDROData_CalculationCase::Export( int theStudyId ) const
1006 GEOM::GEOM_Gen_var aGEOMEngine = HYDROData_GeomTool::GetGeomGen();
1007 SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId );
1009 QString aGeomObjEntry;
1010 bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry );
1011 return isOK ? aGeomObjEntry : QString();
1014 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
1015 SALOMEDS::Study_ptr theStudy,
1016 QString& theGeomObjEntry ) const
1018 HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
1020 // Get groups definitions
1021 HYDROData_SequenceOfObjects aSplittedGroups = GetSplittedGroups();
1023 HYDROData_SequenceOfObjects::Iterator anIter( aSplittedGroups );
1024 for ( ; anIter.More(); anIter.Next() )
1027 Handle(HYDROData_ShapesGroup) aGroup =
1028 Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
1029 if ( aGroup.IsNull() )
1032 HYDROData_ShapesGroup::GroupDefinition aGroupDef;
1034 aGroupDef.Name = aGroup->GetName().toLatin1().constData();
1035 aGroup->GetShapes( aGroupDef.Shapes );
1037 aSeqOfGroupsDefs.Append( aGroupDef );
1041 TopTools_ListOfShape aFaces;
1042 HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
1043 HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
1044 for ( ; aRegionIter.More(); aRegionIter.Next() )
1046 Handle(HYDROData_Region) aRegion =
1047 Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
1048 if( aRegion.IsNull() || !aRegion->IsSubmersible() )
1051 TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
1052 aFaces.Append( aRegionShape );
1055 return Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );
1058 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
1059 SALOMEDS::Study_ptr theStudy,
1060 const TopTools_ListOfShape& theFaces,
1061 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
1062 QString& theGeomObjEntry ) const
1065 BRepBuilderAPI_Sewing aSewing( Precision::Confusion() * 10.0 );
1066 aSewing.SetNonManifoldMode( Standard_False );
1067 #ifdef DEB_CALCULATION
1068 TCollection_AsciiString aNam("Sh_");
1071 TopTools_ListIteratorOfListOfShape aFaceIter( theFaces );
1072 for ( ; aFaceIter.More(); aFaceIter.Next() )
1074 TopoDS_Shape aShape = aFaceIter.Value();
1075 if ( aShape.IsNull() )
1078 if ( aShape.ShapeType() == TopAbs_FACE )
1080 aSewing.Add( aShape );
1081 #ifdef DEB_CALCULATION
1082 TCollection_AsciiString aName = aNam + ++i + ".brep";
1083 BRepTools::Write(aShape ,aName.ToCString());
1088 #ifdef DEB_CALCULATION
1091 TopExp_Explorer anExp( aShape, TopAbs_FACE );
1092 for (; anExp.More(); anExp.Next() ) {
1093 aSewing.Add( anExp.Current() );
1094 #ifdef DEB_CALCULATION
1096 TCollection_AsciiString aName = aNam + i + "_" + ++j + ".brep";
1097 BRepTools::Write(anExp.Current() ,aName.ToCString());
1104 TopoDS_Shape aSewedShape = aSewing.SewedShape();
1106 // If the sewed shape is empty - return false
1107 if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() )
1110 #ifdef DEB_CALCULATION
1111 BRepTools::Write(aSewedShape ,"Sew.brep");
1113 // Publish the sewed shape
1114 QString aName = EXPORT_NAME;
1115 GEOM::GEOM_Object_ptr aMainShape =
1116 HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry );
1118 if ( aMainShape->_is_nil() )
1121 if ( theGroupsDefs.IsEmpty() )
1125 TopTools_IndexedMapOfShape aMapOfSubShapes;
1126 TopExp::MapShapes( aSewedShape, aMapOfSubShapes );
1128 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> > aGroupsData;
1130 for ( int aGrId = 1, nbGroups = theGroupsDefs.Length(); aGrId <= nbGroups; ++aGrId )
1132 const HYDROData_ShapesGroup::GroupDefinition& aGroupDef = theGroupsDefs.Value( aGrId );
1134 NCollection_Sequence<int> aGroupIndexes;
1135 for( int i = 1, n = aGroupDef.Shapes.Length(); i <= n; i++ )
1137 const TopoDS_Shape& aShape = aGroupDef.Shapes.Value( i );
1138 #ifdef DEB_CALCULATION
1139 cout << "\nOld shape(" << i << ") = " << aShape.TShape() <<endl;
1142 TopoDS_Shape aModifiedShape = aShape;
1143 if ( aSewing.IsModified( aShape ) )
1144 aModifiedShape = aSewing.Modified( aShape );
1145 else if ( aSewing.IsModifiedSubShape( aShape ) )
1146 aModifiedShape = aSewing.ModifiedSubShape( aShape );
1148 #ifdef DEB_CALCULATION
1149 const TopLoc_Location& aL1 = aShape.Location();
1150 const TopLoc_Location& aL2 = aModifiedShape.Location();
1151 cout << "\nNew shape(" << i << ") = " << aModifiedShape.TShape() << " Location is Equal = " << aL1.IsEqual(aL2)<<endl;
1154 int anIndex = aMapOfSubShapes.FindIndex(aModifiedShape);
1155 if ( anIndex > 0 ) {
1156 aGroupIndexes.Append( anIndex );
1158 #ifdef DEB_CALCULATION
1159 TCollection_AsciiString aNam("Lost_");
1160 if(!aMapOfSubShapes.Contains(aModifiedShape)) {
1161 for ( int anIndex = 1; anIndex <= aMapOfSubShapes.Extent(); anIndex++ )
1163 const TopoDS_Shape& aS = aMapOfSubShapes.FindKey( anIndex );
1164 if ( aModifiedShape.IsPartner( aS ) )
1166 cout <<"\nIndex in Map = " << anIndex << "TShape = " << aS.TShape() <<endl;
1167 TCollection_AsciiString aName = aNam + i + "_" + anIndex + ".brep";
1168 BRepTools::Write(aS ,aName.ToCString());
1176 if ( !aGroupIndexes.IsEmpty() )
1177 aGroupsData.Bind( aGroupDef.Name, aGroupIndexes );
1180 if ( !aGroupsData.IsEmpty() )
1182 GEOM::GEOM_IGroupOperations_var aGroupOp =
1183 theGeomEngine->GetIGroupOperations( theStudy->StudyId() );
1185 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> >::Iterator aMapIt( aGroupsData );
1186 for ( ; aMapIt.More(); aMapIt.Next() )
1188 const TCollection_AsciiString& aGroupName = aMapIt.Key();
1189 const NCollection_Sequence<int>& aGroupIndexes = aMapIt.Value();
1191 GEOM::GEOM_Object_var aGeomGroup = aGroupOp->CreateGroup( aMainShape, TopAbs_EDGE );
1192 if ( CORBA::is_nil( aGeomGroup ) || !aGroupOp->IsDone() )
1195 GEOM::ListOfLong_var aGeomIndexes = new GEOM::ListOfLong;
1196 aGeomIndexes->length( aGroupIndexes.Length() );
1198 for( int i = 1, n = aGroupIndexes.Length(); i <= n; i++ )
1199 aGeomIndexes[ i - 1 ] = aGroupIndexes.Value( i );
1201 aGroupOp->UnionIDs( aGeomGroup, aGeomIndexes );
1202 if ( aGroupOp->IsDone() )
1204 SALOMEDS::SObject_var aGroupSO =
1205 theGeomEngine->AddInStudy( theStudy, aGeomGroup, aGroupName.ToCString(), aMainShape );
1213 void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
1214 const bool theIsSetToUpdate )
1216 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1217 HYDROData_PriorityQueue::ClearRules( aRulesLab );
1219 // Indicate model of the need to update splitting
1220 if ( theIsSetToUpdate ) {
1221 SetToUpdate( true );
1225 void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theObject1,
1226 HYDROData_PriorityType thePriority,
1227 const Handle(HYDROData_Entity)& theObject2,
1228 HYDROData_Zone::MergeAltitudesType theMergeType,
1229 HYDROData_CalculationCase::DataTag theDataTag )
1231 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1232 HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
1234 // Indicate model of the need to update splitting
1235 SetToUpdate( true );
1238 QString HYDROData_CalculationCase::DumpRules() const
1240 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1241 return HYDROData_PriorityQueue::DumpRules( aRulesLab );
1244 void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
1246 TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode );
1247 TDataStd_Integer::Set( aModeLab, ( int ) theMode );
1249 // Indicate model of the need to update splitting
1250 SetToUpdate( true );
1253 HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const
1255 Handle(TDataStd_Integer) aModeAttr;
1256 bool isOK = myLab.FindChild( DataTag_AssignmentMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
1258 return ( AssignmentMode ) aModeAttr->Get();
1263 void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseName,
1264 QStringList& theScript ) const
1266 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1267 HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
1270 HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const
1272 return myLastWarning;
1275 void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const QString& theData )
1277 myLastWarning.Type = theType;
1278 myLastWarning.Data = theData;
1281 bool HYDROData_CalculationCase::GetRule( int theIndex,
1282 Handle(HYDROData_Entity)& theObject1,
1283 HYDROData_PriorityType& thePriority,
1284 Handle(HYDROData_Entity)& theObject2,
1285 HYDROData_Zone::MergeAltitudesType& theMergeType,
1286 HYDROData_CalculationCase::DataTag& theDataTag) const
1288 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1289 return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
1290 theObject1, thePriority, theObject2, theMergeType );
1293 void HYDROData_CalculationCase::SetAssignmentLandCoverMode( AssignmentMode theMode )
1295 TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentLandCoverMode );
1296 TDataStd_Integer::Set( aModeLab, ( int ) theMode );
1298 // Indicate model of the need to update land covers partition
1299 SetToUpdate( true );
1302 HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentLandCoverMode() const
1304 Handle(TDataStd_Integer) aModeAttr;
1305 bool isOK = myLab.FindChild( DataTag_AssignmentLandCoverMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
1307 return ( AssignmentMode ) aModeAttr->Get();