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"
20 #include "HYDROData_ArtificialObject.h"
21 #include "HYDROData_IAltitudeObject.h"
22 #include "HYDROData_Document.h"
23 #include "HYDROData_ShapesGroup.h"
24 #include "HYDROData_Iterator.h"
25 #include "HYDROData_NaturalObject.h"
26 #include "HYDROData_PolylineXY.h"
27 #include "HYDROData_StricklerTable.h"
28 #include "HYDROData_LandCoverMap.h"
29 #include "HYDROData_SplitShapesGroup.h"
30 #include "HYDROData_Region.h"
31 #include "HYDROData_Tool.h"
32 #include "HYDROData_GeomTool.h"
35 #pragma warning ( disable: 4251 )
43 #pragma warning ( default: 4251 )
49 #include <TopoDS_Shell.hxx>
50 #include <TopoDS_Edge.hxx>
52 #include <BRep_Builder.hxx>
53 #include <BRepBuilderAPI_Sewing.hxx>
54 #include <BRepTopAdaptor_FClass2d.hxx>
56 #include <BRepTools.hxx>
59 #include <TopExp_Explorer.hxx>
61 #include <TopTools_ListOfShape.hxx>
62 #include <TopTools_ListIteratorOfListOfShape.hxx>
63 #include <TDataStd_Integer.hxx>
65 //#define DEB_CALCULATION 1
66 #ifdef DEB_CALCULATION
67 #include <BRepTools.hxx>
68 #include <TopLoc_Location.hxx>
70 #define CALCULATION_REGIONS_PREF GetName() + "_Reg"
71 #define CALCULATION_ZONES_PREF GetName() + "_Zone"
72 #define CALCULATION_GROUPS_PREF GetName() + "_"
73 //#define DEB_CLASS2D 1
75 #include <BRepBuilderAPI_MakeVertex.hxx>
78 #define EXPORT_NAME "HYDRO_" + GetName()
80 IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
81 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
83 HYDROData_CalculationCase::HYDROData_CalculationCase()
84 : HYDROData_Entity( Geom_2d_and_groups )
88 HYDROData_CalculationCase::~HYDROData_CalculationCase()
92 void HYDROData_CalculationCase::SetName( const QString& theName )
94 QString anOldCaseName = GetName();
95 if ( anOldCaseName != theName )
97 // Update names of regions and its zones
98 UpdateRegionsNames( GetRegions(), anOldCaseName, theName );
100 HYDROData_SequenceOfObjects aGroups = GetSplitGroups();
102 HYDROData_SequenceOfObjects::Iterator anIter;
103 anIter.Init( aGroups );
104 for ( ; anIter.More(); anIter.Next() )
106 Handle(HYDROData_SplitShapesGroup) aGroup =
107 Handle(HYDROData_SplitShapesGroup)::DownCast( anIter.Value() );
108 if ( aGroup.IsNull() )
111 HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aGroup );
115 HYDROData_Entity::SetName( theName );
118 QStringList HYDROData_CalculationCase::DumpToPython( const QString& thePyScriptPath,
119 MapOfTreatedObjects& theTreatedObjects ) const
121 QStringList aResList = dumpObjectCreation( theTreatedObjects );
122 aResList.prepend( "# Calculation case" );
124 QString aCalculName = GetObjPyName();
126 AssignmentMode aMode = GetAssignmentMode();
127 QString aModeStr = aMode==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC";
128 aResList << QString( "%0.SetAssignmentMode( %1 )" ).arg( aCalculName ).arg( aModeStr );
130 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
131 HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
132 for ( ; anIter.More(); anIter.Next() )
134 Handle(HYDROData_Object) aRefGeomObj =
135 Handle(HYDROData_Object)::DownCast( anIter.Value() );
136 setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
138 aResList << QString( "" );
140 QString aGroupName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "case_geom_group" );
142 HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
143 anIter.Init( aGeomGroups );
144 for ( ; anIter.More(); anIter.Next() )
146 Handle(HYDROData_ShapesGroup) aGeomGroup =
147 Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
148 if ( aGeomGroup.IsNull() )
151 Handle(HYDROData_Object) aFatherGeom =
152 Handle(HYDROData_Object)::DownCast( aGeomGroup->GetFatherObject() );
153 if ( aFatherGeom.IsNull() )
156 int aGroupId = aFatherGeom->GetGroupId( aGeomGroup );
157 aResList << QString( "%1 = %2.GetGroup( %3 )" )
158 .arg( aGroupName ).arg( aFatherGeom->GetObjPyName() ).arg( aGroupId );
160 aResList << QString( "%1.AddGeometryGroup( %2 )" ).arg( aCalculName ).arg( aGroupName );
163 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
164 setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
166 if( aMode==AUTOMATIC )
167 DumpRulesToPython( aCalculName, aResList );
169 aResList << QString( "" );
170 aResList << "# Start the algorithm of the partition and assignment";
171 aResList << QString( "%1.Update()" ).arg( aCalculName );
175 // Now we restore the
176 // - regions and zones order
177 DumpRegionsToPython( aResList, thePyScriptPath, theTreatedObjects, GetRegions() );
180 // Export calculation case
181 aResList << QString( "" );
182 aResList << "# Export of the calculation case";
183 QString aStudyName = "theStudy";
184 QString anEntryVar = aCalculName + "_entry";
185 aResList << QString( "%1 = %2.Export( %3._get_StudyId() )" ).arg( anEntryVar ).arg( aCalculName ).arg( aStudyName );
187 // Get geometry object and print debug information
189 aResList << "# Get geometry shape and print debug information";
190 aResList << "import GEOM";
191 aResList << QString( "print \"Entry:\", %1" ).arg( anEntryVar );
192 QString aGeomShapeName = aCalculName + "_geom";
193 aResList << QString( "%1 = salome.IDToObject( str( %2 ) )" ).arg( aGeomShapeName ).arg( anEntryVar );
194 aResList << QString( "print \"Geom shape:\", %1" ).arg( aGeomShapeName );
195 aResList << QString( "print \"Geom shape name:\", %1.GetName()" ).arg( aGeomShapeName );
197 //DumpSampleMeshing( aResList, aStudyName, aGeomShapeName, aCalculName+"_mesh" );
199 aResList << QString( "" );
203 void HYDROData_CalculationCase::DumpSampleMeshing( QStringList& theResList,
204 const QString& theStudyName,
205 const QString& theGeomShapeName,
206 const QString& theMeshName ) const
209 theResList << "# Meshing";
210 theResList << "import SMESH, SALOMEDS";
211 theResList << "from salome.smesh import smeshBuilder";
212 theResList << "from salome.geom import geomBuilder";
214 theResList << QString( "smesh = smeshBuilder.New( %1 )" ).arg( theStudyName );
215 theResList << QString( "%1 = smesh.Mesh( %2 )" ).arg( theMeshName ).arg( theGeomShapeName );
216 theResList << QString( "MEFISTO_2D = %1.Triangle( algo=smeshBuilder.MEFISTO )" ).arg( theMeshName );
217 theResList << "Max_Element_Area_1 = MEFISTO_2D.MaxElementArea( 10 )";
218 theResList << QString( "Regular_1D = %1.Segment()" ).arg( theMeshName );
219 theResList << "Max_Size_1 = Regular_1D.MaxSize(10)";
220 theResList << QString( "isDone = %1.Compute()" ).arg( theMeshName );
223 theResList << "# Set names of Mesh objects";
224 theResList << "smesh.SetName( MEFISTO_2D.GetAlgorithm(), 'MEFISTO_2D' )";
225 theResList << "smesh.SetName( Regular_1D.GetAlgorithm(), 'Regular_1D' )";
226 theResList << "smesh.SetName( Max_Size_1, 'Max Size_1' )";
227 theResList << "smesh.SetName( Max_Element_Area_1, 'Max. Element Area_1' )";
228 theResList << QString( "smesh.SetName( %1.GetMesh(), '%1' )" ).arg( theMeshName );
231 theResList << "# Greate SMESH groups";
232 theResList << QString( "geompy = geomBuilder.New( %1 )" ).arg( theStudyName );
233 theResList << QString( "geom_groups = geompy.GetGroups( %1 )" ).arg( theGeomShapeName );
234 theResList << QString( "for group in geom_groups:" );
235 theResList << QString( " smesh_group = %1.GroupOnGeom(group, group.GetName(), SMESH.EDGE)" )
237 theResList << QString( " smesh.SetName(smesh_group, group.GetName())" );
238 theResList << QString( " print \"SMESH group '%s': %s\" % (smesh_group.GetName(), smesh_group)" );
241 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() const
243 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
245 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
246 if ( !aBoundaryPolyline.IsNull() )
247 aResSeq.Append( aBoundaryPolyline );
249 HYDROData_SequenceOfObjects aSeqOfGeomObjs = GetGeometryObjects();
250 aResSeq.Append( aSeqOfGeomObjs );
253 HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
254 aResSeq.Append( aSeqOfRegions );
259 void HYDROData_CalculationCase::Update()
261 HYDROData_Entity::Update();
264 // At first we remove previously created objects
268 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
269 if ( aDocument.IsNull() )
273 HYDROData_SplitToZonesTool::SplitDataList aZonesList, anEdgesList;
275 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
276 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
277 if ( !aGeomObjects.IsEmpty() ) {
278 HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
280 HYDROData_SplitToZonesTool::SplitDataList aSplitObjects =
281 HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline );
282 if ( !aSplitObjects.isEmpty() ) {
283 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitObjects );
284 while( anIter.hasNext() ) {
285 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
286 if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
287 aZonesList.append( aSplitData );
288 else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
289 anEdgesList.append( aSplitData );
294 switch( GetAssignmentMode() )
297 CreateRegionsDef( aDocument, aZonesList );
300 CreateRegionsAuto( aDocument, aZonesList );
304 CreateEdgeGroupsDef( aDocument, anEdgesList );
307 void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
308 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
310 // Create result regions for case, by default one zone for one region
311 QString aRegsPref = CALCULATION_REGIONS_PREF;
312 QString aZonesPref = CALCULATION_ZONES_PREF;
314 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
315 while( anIter.hasNext() )
317 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
319 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref );
321 // Add the zone for region
322 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
326 void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
327 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
329 QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
330 QMap<QString, QString> aRegionNameToObjNameMap;
331 QString aZonesPref = CALCULATION_ZONES_PREF;
332 HYDROData_PriorityQueue aPr( this, DataTag_CustomRules );
334 // 1. First we create a default region for each object included into the calculation case
335 HYDROData_SequenceOfObjects anObjects = GetGeometryObjects();
336 for( int i = anObjects.Lower(), n = anObjects.Upper(); i<=n; i++ )
338 Handle(HYDROData_Entity) anObj = anObjects.Value( i );
341 QString anObjName = anObj->GetName();
342 QString aRegName = anObjName + "_reg";
343 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false );
344 aRegionsMap.insert( anObjName, aRegion );
345 aRegionNameToObjNameMap.insert( aRegName, anObjName );
348 // 2. Now for each zone it is necessary to determine the most priority object
349 // and assign to zone to corresponding region
350 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
351 while( anIter.hasNext() )
353 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
354 HYDROData_Zone::MergeType aMergeType;
355 Handle(HYDROData_Entity) aRegObj = aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType );
356 if( aRegObj.IsNull() )
358 Handle(HYDROData_Region) aRegion = aRegionsMap[aRegObj->GetName()];
359 if( aRegion.IsNull() )
361 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
363 if( aSplitData.ObjectNames.count() > 1 && aMergeType==HYDROData_Zone::Merge_UNKNOWN )
365 qDebug( "Error in algorithm: unresolved conflicts" );
368 Handle(HYDROData_Entity) aMergeEntity = aRegObj;
369 Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity );
370 if ( !aMergeObject.IsNull() ) {
371 aMergeEntity = aMergeObject->GetAltitudeObject();
376 case HYDROData_Zone::Merge_ZMIN:
377 case HYDROData_Zone::Merge_ZMAX:
378 aRegionZone->SetMergeType( aMergeType );
380 case HYDROData_Zone::Merge_Object:
381 aRegionZone->SetMergeType( aMergeType );
382 aRegionZone->RemoveMergeObject();
383 aRegionZone->SetMergeObject( aMergeEntity );
388 QStringList anObjectsWithEmptyRegions;
389 QMap<QString, Handle(HYDROData_Region)>::const_iterator
390 anIt = aRegionsMap.begin(), aLast = aRegionsMap.end();
391 for( ; anIt!=aLast; anIt++ )
393 Handle(HYDROData_Region) aRegion = anIt.value();
394 if( aRegion->GetZones().IsEmpty() )
396 QString aRegName = aRegion->GetName();
397 QString anObjName = aRegionNameToObjNameMap[aRegName];
398 anObjectsWithEmptyRegions.append( anObjName );
402 if( !anObjectsWithEmptyRegions.empty() )
404 QString aData = anObjectsWithEmptyRegions.join( ", " );
405 SetWarning( WARN_EMPTY_REGIONS, aData );
409 void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
410 const HYDROData_SplitToZonesTool::SplitDataList& theEdges )
412 QMap<QString,Handle(HYDROData_SplitShapesGroup)> aSplitEdgesGroupsMap;
414 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges );
415 while( anIter.hasNext() )
417 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
418 // Create new edges group
419 if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
422 QString anObjName = aSplitData.ObjectNames.first();
423 if ( anObjName.isEmpty() )
425 #ifdef DEB_CALCULATION
426 QString aStr = aSplitData.ObjectNames.join(" ");
427 cout << " CCase: Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size() <<endl;
429 Handle(HYDROData_SplitShapesGroup) aSplitGroup;
430 if ( !aSplitEdgesGroupsMap.contains( anObjName ) )
432 aSplitGroup = addNewSplitGroup( CALCULATION_GROUPS_PREF + anObjName );
433 aSplitEdgesGroupsMap.insert( anObjName, aSplitGroup );
437 aSplitGroup = aSplitEdgesGroupsMap[ anObjName ];
439 if ( aSplitGroup.IsNull() )
442 aSplitGroup->AddShape( aSplitData.Shape );
446 bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
448 if ( !HYDROData_Tool::IsGeometryObject( theObject ) )
449 return false; // Wrong type of object
451 if ( HasReference( theObject, DataTag_GeometryObject ) )
452 return false; // Object is already in reference list
454 AddReferenceObject( theObject, DataTag_GeometryObject );
456 // Indicate model of the need to update splitting
462 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryObjects() const
464 return GetReferenceObjects( DataTag_GeometryObject );
467 void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject )
469 if ( theObject.IsNull() )
472 RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
474 // Indicate model of the need to update splitting
478 void HYDROData_CalculationCase::RemoveGeometryObjects()
480 ClearReferenceObjects( DataTag_GeometryObject );
482 // Indicate model of the need to update splitting
486 bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
488 if ( theGroup.IsNull() )
491 if ( HasReference( theGroup, DataTag_GeometryGroup ) )
492 return false; // Object is already in reference list
494 AddReferenceObject( theGroup, DataTag_GeometryGroup );
496 // Indicate model of the need to update splitting
497 Changed( Geom_Groups );
502 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryGroups() const
504 return GetReferenceObjects( DataTag_GeometryGroup );
507 void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
509 if ( theGroup.IsNull() )
512 RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
514 // Indicate model of the need to update splitting
515 Changed( Geom_Groups );
518 void HYDROData_CalculationCase::RemoveGeometryGroups()
520 ClearReferenceObjects( DataTag_GeometryGroup );
522 // Indicate model of the need to update splitting
523 Changed( Geom_Groups );
526 void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
528 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
530 SetReferenceObject( thePolyline, DataTag_Polyline );
532 // Indicate model of the need to update zones splitting
533 if( !IsEqual( aPrevPolyline, thePolyline ) )
537 Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
539 return Handle(HYDROData_PolylineXY)::DownCast(
540 GetReferenceObject( DataTag_Polyline ) );
543 void HYDROData_CalculationCase::RemoveBoundaryPolyline()
545 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
547 ClearReferenceObjects( DataTag_Polyline );
549 // Indicate model of the need to update zones splitting
553 void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
555 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
557 SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
559 // Indicate model of the need to update land covers partition
560 if( !IsEqual( aPrevStricklerTable, theStricklerTable ) )
564 Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
566 return Handle(HYDROData_StricklerTable)::DownCast(
567 GetReferenceObject( DataTag_StricklerTable ) );
570 void HYDROData_CalculationCase::RemoveStricklerTable()
572 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
574 ClearReferenceObjects( DataTag_StricklerTable );
576 // Indicate model of the need to update land covers partition
580 Handle(HYDROData_LandCoverMap) HYDROData_CalculationCase::GetLandCoverMap() const
582 Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast(
583 GetReferenceObject( DataTag_LandCoverMap ) );
587 void HYDROData_CalculationCase::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
589 SetReferenceObject( theMap, DataTag_LandCoverMap );
592 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
597 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
598 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
599 if ( aNewRegion.IsNull() )
602 aNewRegion->AddZone( theZone );
607 bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion )
609 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
611 if ( theRegion.IsNull() )
614 HYDROData_CalculationCase::DataTag aDataTag = DataTag_Region;
616 if ( HasReference( theRegion, aDataTag ) )
617 return false; // Object is already in reference list
619 // Move the region from other calculation
620 Handle(HYDROData_CalculationCase) aFatherCalc =
621 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
622 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
624 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
625 theRegion->CopyTo( aNewRegion, true );
627 aFatherCalc->RemoveRegion( theRegion );
629 theRegion->SetLabel( aNewRegion->Label() );
633 AddReferenceObject( theRegion, aDataTag );
639 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const
641 return GetReferenceObjects( DataTag_Region );
644 void HYDROData_CalculationCase::UpdateRegionsOrder()
646 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
647 if ( aDocument.IsNull() )
650 HYDROData_SequenceOfObjects aRegions = GetRegions();
651 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
652 for ( ; anIter.More(); anIter.Next() )
654 Handle(HYDROData_Region) aRegion =
655 Handle(HYDROData_Region)::DownCast( anIter.Value() );
656 if ( aRegion.IsNull() )
659 aRegion->SetName( "" );
662 QString aRegsPref = CALCULATION_REGIONS_PREF;
664 anIter.Init( aRegions );
665 for ( ; anIter.More(); anIter.Next() )
667 Handle(HYDROData_Region) aRegion =
668 Handle(HYDROData_Region)::DownCast( anIter.Value() );
669 if ( aRegion.IsNull() )
672 QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
673 aRegion->SetName( aRegionName );
677 void HYDROData_CalculationCase::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
679 if ( theRegion.IsNull() )
682 HYDROData_CalculationCase::DataTag aDataTag = DataTag_Region;
683 RemoveReferenceObject( theRegion->Label(), aDataTag );
685 // Remove region from data model
686 Handle(HYDROData_CalculationCase) aFatherCalc =
687 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
688 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab )
692 void HYDROData_CalculationCase::RemoveRegions()
694 myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes();
697 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetSplitGroups() const
699 return GetReferenceObjects( DataTag_SplitGroups );
702 void HYDROData_CalculationCase::RemoveSplitGroups()
704 myLab.FindChild( DataTag_SplitGroups ).ForgetAllAttributes();
707 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) const
709 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
710 return GetAltitudeForPoint( thePoint, aZone );
713 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
714 const Handle(HYDROData_Region)& theRegion ) const
716 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
718 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
719 if ( !aZone.IsNull() )
721 Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
722 if ( IsEqual( aRefRegion, theRegion ) )
723 aResAltitude = GetAltitudeForPoint( thePoint, aZone );
729 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
730 const Handle(HYDROData_Zone)& theZone ) const
732 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
733 if ( theZone.IsNull() )
736 HYDROData_Zone::MergeType aZoneMergeType = theZone->GetMergeType();
737 if ( !theZone->IsMergingNeed() )
739 aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN;
741 else if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
746 HYDROData_IInterpolator* aZoneInterpolator = theZone->GetInterpolator();
747 if ( aZoneMergeType == HYDROData_Zone::Merge_Object )
749 Handle(HYDROData_IAltitudeObject) aMergeAltitude =
750 Handle(HYDROData_IAltitudeObject)::DownCast( theZone->GetMergeObject() );
751 if ( !aMergeAltitude.IsNull() )
753 if ( aZoneInterpolator != NULL )
755 aZoneInterpolator->SetAltitudeObject( aMergeAltitude );
756 aResAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
759 aResAltitude = aMergeAltitude->GetAltitudeForPoint( thePoint );
764 HYDROData_SequenceOfObjects aZoneObjects = theZone->GetObjects();
765 HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects );
766 for ( ; anIter.More(); anIter.Next() )
768 Handle(HYDROData_Object) aZoneObj =
769 Handle(HYDROData_Object)::DownCast( anIter.Value() );
770 if ( aZoneObj.IsNull() )
773 Handle(HYDROData_IAltitudeObject) anObjAltitude = aZoneObj->GetAltitudeObject();
774 if ( anObjAltitude.IsNull() )
777 double aPointAltitude = 0.0;
778 if ( aZoneInterpolator != NULL )
780 aZoneInterpolator->SetAltitudeObject( anObjAltitude );
781 aPointAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
784 aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint );
786 if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) )
789 if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
791 aResAltitude = aPointAltitude;
794 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMIN )
796 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
797 aResAltitude > aPointAltitude )
799 aResAltitude = aPointAltitude;
802 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMAX )
804 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
805 aResAltitude < aPointAltitude )
807 aResAltitude = aPointAltitude;
816 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
817 const NCollection_Sequence<gp_XY>& thePoints,
818 const Handle(HYDROData_Region)& theRegion ) const
820 NCollection_Sequence<double> aResSeq;
822 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
824 const gp_XY& thePnt = thePoints.Value( i );
826 double anAltitude = GetAltitudeForPoint( thePnt, theRegion );
827 aResSeq.Append( anAltitude );
833 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
834 const NCollection_Sequence<gp_XY>& thePoints,
835 const Handle(HYDROData_Zone)& theZone ) const
837 NCollection_Sequence<double> aResSeq;
839 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
841 const gp_XY& thePnt = thePoints.Value( i );
843 double anAltitude = GetAltitudeForPoint( thePnt, theZone );
844 aResSeq.Append( anAltitude );
850 double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const
852 Handle( HYDROData_LandCoverMap ) aMap = GetLandCoverMap();
853 Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable();
858 aMap->FindByPoint( thePoint, aType );
859 double aCoeff = aTable->Get( aType, 0.0 );
863 Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
865 Handle(HYDROData_Region) aResRegion;
867 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
868 if ( !aZone.IsNull() )
869 aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
874 Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
876 Handle(HYDROData_Zone) aResZone;
878 HYDROData_SequenceOfObjects aRegions = GetRegions();
880 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
881 for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() )
883 Handle(HYDROData_Region) aRegion =
884 Handle(HYDROData_Region)::DownCast( anIter.Value() );
885 if ( aRegion.IsNull() )
888 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
889 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
890 for ( ; aZonesIter.More() && aResZone.IsNull(); aZonesIter.Next() )
892 Handle(HYDROData_Zone) aRegZone =
893 Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
894 if ( aRegZone.IsNull() )
897 PointClassification aPointRelation = GetPointClassification( thePoint, aRegZone );
898 if ( aPointRelation != POINT_OUT )
899 aResZone = aRegZone; // We found the desired zone
906 HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPointClassification(
907 const gp_XY& thePoint,
908 const Handle(HYDROData_Zone)& theZone ) const
910 PointClassification aRes = POINT_OUT;
911 if ( theZone.IsNull() )
914 TopoDS_Face aZoneFace = TopoDS::Face( theZone->GetShape() );
915 if ( aZoneFace.IsNull() )
918 TopoDS_Compound aCmp;
920 aBB.MakeCompound(aCmp);
921 aBB.Add(aCmp, aZoneFace);
922 gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
923 BRepBuilderAPI_MakeVertex aMk(aPnt);
924 aBB.Add(aCmp, aMk.Vertex());
925 BRepTools::Write(aCmp, "FCL2d.brep");
927 TopAbs_State State = HYDROData_Tool::ComputePointState(thePoint, aZoneFace);
928 if (State == TopAbs_OUT)
930 else if(State == TopAbs_IN)
932 else if(State == TopAbs_ON)
937 Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(HYDROData_Document)& theDoc,
938 const QString& thePrefixOrName,
941 TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
942 int aTag = aNewLab.Tag();
944 Handle(HYDROData_Region) aNewRegion =
945 Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
946 AddRegion( aNewRegion );
948 QString aRegionName = isPrefix ? HYDROData_Tool::GenerateObjectName( theDoc, thePrefixOrName ) : thePrefixOrName;
949 aNewRegion->SetName( aRegionName );
954 Handle(HYDROData_SplitShapesGroup) HYDROData_CalculationCase::addNewSplitGroup( const QString& theName )
956 TDF_Label aNewLab = myLab.FindChild( DataTag_SplitGroups ).NewChild();
958 Handle(HYDROData_SplitShapesGroup) aNewGroup =
959 Handle(HYDROData_SplitShapesGroup)::DownCast(
960 HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLIT_GROUP ) );
961 AddReferenceObject( aNewGroup, DataTag_SplitGroups );
963 aNewGroup->SetName( theName );
968 QString HYDROData_CalculationCase::Export( int theStudyId ) const
973 GEOM::GEOM_Gen_var aGEOMEngine = HYDROData_GeomTool::GetGeomGen();
974 SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId );
976 QString aGeomObjEntry, anErrorMsg;
977 bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg );
978 return isOK ? aGeomObjEntry : QString();
983 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
984 SALOMEDS::Study_ptr theStudy,
985 QString& theGeomObjEntry,
986 QString& theErrorMsg ) const
988 HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
990 // Get groups definitions
991 HYDROData_SequenceOfObjects aSplitGroups = GetSplitGroups();
993 HYDROData_SequenceOfObjects::Iterator anIter( aSplitGroups );
994 for ( ; anIter.More(); anIter.Next() )
997 Handle(HYDROData_ShapesGroup) aGroup =
998 Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
999 if ( aGroup.IsNull() )
1002 HYDROData_ShapesGroup::GroupDefinition aGroupDef;
1004 aGroupDef.Name = aGroup->GetName().toLatin1().constData();
1005 aGroup->GetShapes( aGroupDef.Shapes );
1007 aSeqOfGroupsDefs.Append( aGroupDef );
1011 bool isAllNotSubmersible = true;
1012 TopTools_ListOfShape aFaces;
1013 HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
1014 HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
1015 for ( ; aRegionIter.More(); aRegionIter.Next() )
1017 Handle(HYDROData_Region) aRegion =
1018 Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
1019 if( aRegion.IsNull() || !aRegion->IsSubmersible() )
1022 if ( isAllNotSubmersible )
1023 isAllNotSubmersible = false;
1025 TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
1026 aFaces.Append( aRegionShape );
1031 if ( aCaseRegions.IsEmpty() ) {
1032 theErrorMsg = QString("the list of regions is empty.");
1033 } else if ( isAllNotSubmersible ) {
1034 theErrorMsg = QString("there are no submersible regions.");
1036 aRes = Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );;
1039 if( aRes && !GetLandCoverMap().IsNull() && !GetStricklerTable().IsNull() )
1041 QString aTelemacFileName = GetName() + ".telemac";
1042 aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable() );
1047 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
1048 SALOMEDS::Study_ptr theStudy,
1049 const TopTools_ListOfShape& theFaces,
1050 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
1051 QString& theGeomObjEntry ) const
1054 BRepBuilderAPI_Sewing aSewing( Precision::Confusion() * 10.0 );
1055 aSewing.SetNonManifoldMode( Standard_False );
1056 #ifdef DEB_CALCULATION
1057 TCollection_AsciiString aNam("Sh_");
1060 TopTools_ListIteratorOfListOfShape aFaceIter( theFaces );
1061 for ( ; aFaceIter.More(); aFaceIter.Next() )
1063 TopoDS_Shape aShape = aFaceIter.Value();
1064 if ( aShape.IsNull() )
1067 if ( aShape.ShapeType() == TopAbs_FACE )
1069 aSewing.Add( aShape );
1070 #ifdef DEB_CALCULATION
1071 TCollection_AsciiString aName = aNam + ++i + ".brep";
1072 BRepTools::Write(aShape ,aName.ToCString());
1077 #ifdef DEB_CALCULATION
1080 TopExp_Explorer anExp( aShape, TopAbs_FACE );
1081 for (; anExp.More(); anExp.Next() ) {
1082 aSewing.Add( anExp.Current() );
1083 #ifdef DEB_CALCULATION
1085 TCollection_AsciiString aName = aNam + i + "_" + ++j + ".brep";
1086 BRepTools::Write(anExp.Current() ,aName.ToCString());
1093 TopoDS_Shape aSewedShape = aSewing.SewedShape();
1095 // If the sewed shape is empty - return false
1096 if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() )
1099 #ifdef DEB_CALCULATION
1100 BRepTools::Write(aSewedShape ,"Sew.brep");
1102 // Publish the sewed shape
1103 QString aName = EXPORT_NAME;
1104 GEOM::GEOM_Object_ptr aMainShape =
1105 HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry );
1107 if ( aMainShape->_is_nil() )
1110 if ( theGroupsDefs.IsEmpty() )
1114 TopTools_IndexedMapOfShape aMapOfSubShapes;
1115 TopExp::MapShapes( aSewedShape, aMapOfSubShapes );
1117 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> > aGroupsData;
1119 for ( int aGrId = 1, nbGroups = theGroupsDefs.Length(); aGrId <= nbGroups; ++aGrId )
1121 const HYDROData_ShapesGroup::GroupDefinition& aGroupDef = theGroupsDefs.Value( aGrId );
1123 NCollection_Sequence<int> aGroupIndexes;
1124 for( int i = 1, n = aGroupDef.Shapes.Length(); i <= n; i++ )
1126 const TopoDS_Shape& aShape = aGroupDef.Shapes.Value( i );
1127 #ifdef DEB_CALCULATION
1128 cout << "\nOld shape(" << i << ") = " << aShape.TShape() <<endl;
1131 TopoDS_Shape aModifiedShape = aShape;
1132 if ( aSewing.IsModified( aShape ) )
1133 aModifiedShape = aSewing.Modified( aShape );
1134 else if ( aSewing.IsModifiedSubShape( aShape ) )
1135 aModifiedShape = aSewing.ModifiedSubShape( aShape );
1137 #ifdef DEB_CALCULATION
1138 const TopLoc_Location& aL1 = aShape.Location();
1139 const TopLoc_Location& aL2 = aModifiedShape.Location();
1140 cout << "\nNew shape(" << i << ") = " << aModifiedShape.TShape() << " Location is Equal = " << aL1.IsEqual(aL2)<<endl;
1143 int anIndex = aMapOfSubShapes.FindIndex(aModifiedShape);
1144 if ( anIndex > 0 ) {
1145 aGroupIndexes.Append( anIndex );
1147 #ifdef DEB_CALCULATION
1148 TCollection_AsciiString aNam("Lost_");
1149 if(!aMapOfSubShapes.Contains(aModifiedShape)) {
1150 for ( int anIndex = 1; anIndex <= aMapOfSubShapes.Extent(); anIndex++ )
1152 const TopoDS_Shape& aS = aMapOfSubShapes.FindKey( anIndex );
1153 if ( aModifiedShape.IsPartner( aS ) )
1155 cout <<"\nIndex in Map = " << anIndex << "TShape = " << aS.TShape() <<endl;
1156 TCollection_AsciiString aName = aNam + i + "_" + anIndex + ".brep";
1157 BRepTools::Write(aS ,aName.ToCString());
1165 if ( !aGroupIndexes.IsEmpty() )
1166 aGroupsData.Bind( aGroupDef.Name, aGroupIndexes );
1169 if ( !aGroupsData.IsEmpty() )
1171 GEOM::GEOM_IGroupOperations_var aGroupOp =
1172 theGeomEngine->GetIGroupOperations( theStudy->StudyId() );
1174 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> >::Iterator aMapIt( aGroupsData );
1175 for ( ; aMapIt.More(); aMapIt.Next() )
1177 const TCollection_AsciiString& aGroupName = aMapIt.Key();
1178 const NCollection_Sequence<int>& aGroupIndexes = aMapIt.Value();
1180 GEOM::GEOM_Object_var aGeomGroup = aGroupOp->CreateGroup( aMainShape, TopAbs_EDGE );
1181 if ( CORBA::is_nil( aGeomGroup ) || !aGroupOp->IsDone() )
1184 GEOM::ListOfLong_var aGeomIndexes = new GEOM::ListOfLong;
1185 aGeomIndexes->length( aGroupIndexes.Length() );
1187 for( int i = 1, n = aGroupIndexes.Length(); i <= n; i++ )
1188 aGeomIndexes[ i - 1 ] = aGroupIndexes.Value( i );
1190 aGroupOp->UnionIDs( aGeomGroup, aGeomIndexes );
1191 if ( aGroupOp->IsDone() )
1193 SALOMEDS::SObject_var aGroupSO =
1194 theGeomEngine->AddInStudy( theStudy, aGeomGroup, aGroupName.ToCString(), aMainShape );
1203 void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
1204 const bool theIsSetToUpdate )
1206 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1207 HYDROData_PriorityQueue::ClearRules( aRulesLab );
1209 // Indicate model of the need to update splitting
1210 if ( theIsSetToUpdate ) {
1215 void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theObject1,
1216 HYDROData_PriorityType thePriority,
1217 const Handle(HYDROData_Entity)& theObject2,
1218 HYDROData_Zone::MergeType theMergeType,
1219 HYDROData_CalculationCase::DataTag theDataTag )
1221 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1222 HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
1224 // Indicate model of the need to update splitting
1228 QString HYDROData_CalculationCase::DumpRules() const
1230 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1231 return HYDROData_PriorityQueue::DumpRules( aRulesLab );
1234 void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
1236 TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode );
1237 TDataStd_Integer::Set( aModeLab, ( int ) theMode );
1239 // Indicate model of the need to update splitting
1243 HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const
1245 Handle(TDataStd_Integer) aModeAttr;
1246 bool isOK = myLab.FindChild( DataTag_AssignmentMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
1248 return ( AssignmentMode ) aModeAttr->Get();
1253 void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseName,
1254 QStringList& theScript ) const
1256 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1257 HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
1260 HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const
1262 return myLastWarning;
1265 void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const QString& theData )
1267 myLastWarning.Type = theType;
1268 myLastWarning.Data = theData;
1271 void HYDROData_CalculationCase::UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
1272 const QString& theOldCaseName,
1273 const QString& theName )
1275 HYDROData_SequenceOfObjects::Iterator anIter( theRegions );
1276 for ( ; anIter.More(); anIter.Next() )
1278 Handle(HYDROData_Region) aRegion =
1279 Handle(HYDROData_Region)::DownCast( anIter.Value() );
1280 if ( aRegion.IsNull() )
1283 HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegion );
1285 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
1286 HYDROData_SequenceOfObjects::Iterator anIter( aZones );
1287 for ( ; anIter.More(); anIter.Next() )
1289 Handle(HYDROData_Zone) aRegZone =
1290 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
1291 if ( aRegZone.IsNull() )
1294 HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegZone );
1299 void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList,
1300 const QString& thePyScriptPath,
1301 MapOfTreatedObjects& theTreatedObjects,
1302 const HYDROData_SequenceOfObjects& theRegions ) const
1304 HYDROData_SequenceOfObjects::Iterator anIter;
1305 anIter.Init( theRegions );
1306 for ( ; anIter.More(); anIter.Next() )
1308 Handle(HYDROData_Region) aRegion =
1309 Handle(HYDROData_Region)::DownCast( anIter.Value() );
1310 if ( aRegion.IsNull() )
1313 theTreatedObjects.insert( aRegion->GetName(), aRegion );
1314 QStringList aRegDump = aRegion->DumpToPython( thePyScriptPath, theTreatedObjects );
1315 theResList << aRegDump;
1319 bool HYDROData_CalculationCase::GetRule( int theIndex,
1320 Handle(HYDROData_Entity)& theObject1,
1321 HYDROData_PriorityType& thePriority,
1322 Handle(HYDROData_Entity)& theObject2,
1323 HYDROData_Zone::MergeType& theMergeType,
1324 HYDROData_CalculationCase::DataTag& theDataTag) const
1326 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1327 return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
1328 theObject1, thePriority, theObject2, theMergeType );