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 #include <SALOME_NamingService.hxx>
81 #include <SALOME_LifeCycleCORBA.hxx>
84 #include "HYDRO_trace.hxx"
86 IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
87 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
89 HYDROData_CalculationCase::HYDROData_CalculationCase()
90 : HYDROData_Entity( Geom_2d_and_groups )
94 HYDROData_CalculationCase::~HYDROData_CalculationCase()
98 void HYDROData_CalculationCase::SetName( const QString& theName )
100 QString anOldCaseName = GetName();
101 if ( anOldCaseName != theName )
103 // Update names of regions and its zones
104 UpdateRegionsNames( GetRegions(), anOldCaseName, theName );
106 HYDROData_SequenceOfObjects aGroups = GetSplitGroups();
108 HYDROData_SequenceOfObjects::Iterator anIter;
109 anIter.Init( aGroups );
110 for ( ; anIter.More(); anIter.Next() )
112 Handle(HYDROData_SplitShapesGroup) aGroup =
113 Handle(HYDROData_SplitShapesGroup)::DownCast( anIter.Value() );
114 if ( aGroup.IsNull() )
117 HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aGroup );
121 HYDROData_Entity::SetName( theName );
124 QStringList HYDROData_CalculationCase::DumpToPython( const QString& thePyScriptPath,
125 MapOfTreatedObjects& theTreatedObjects ) const
127 QStringList aResList = dumpObjectCreation( theTreatedObjects );
128 aResList.prepend( "# Calculation case" );
130 QString aCalculName = GetObjPyName();
132 AssignmentMode aMode = GetAssignmentMode();
133 QString aModeStr = aMode==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC";
134 aResList << QString( "%0.SetAssignmentMode( %1 )" ).arg( aCalculName ).arg( aModeStr );
136 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
137 HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
138 for ( ; anIter.More(); anIter.Next() )
140 Handle(HYDROData_Object) aRefGeomObj =
141 Handle(HYDROData_Object)::DownCast( anIter.Value() );
142 setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
144 aResList << QString( "" );
146 QString aGroupName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "case_geom_group" );
148 HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
149 anIter.Init( aGeomGroups );
150 for ( ; anIter.More(); anIter.Next() )
152 Handle(HYDROData_ShapesGroup) aGeomGroup =
153 Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
154 if ( aGeomGroup.IsNull() )
157 Handle(HYDROData_Object) aFatherGeom =
158 Handle(HYDROData_Object)::DownCast( aGeomGroup->GetFatherObject() );
159 if ( aFatherGeom.IsNull() )
162 int aGroupId = aFatherGeom->GetGroupId( aGeomGroup );
163 aResList << QString( "%1 = %2.GetGroup( %3 );" )
164 .arg( aGroupName ).arg( aFatherGeom->GetObjPyName() ).arg( aGroupId );
166 aResList << QString( "%1.AddGeometryGroup( %2 );" ).arg( aCalculName ).arg( aGroupName );
169 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
170 setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
172 if( aMode==AUTOMATIC )
173 DumpRulesToPython( aCalculName, aResList );
175 aResList << QString( "" );
176 aResList << "# Start the algorithm of the partition and assignment";
177 aResList << QString( "%1.Update();" ).arg( aCalculName );
181 // Now we restore the
182 // - regions and zones order
183 DumpRegionsToPython( aResList, thePyScriptPath, theTreatedObjects, GetRegions() );
186 // Export calculation case
187 aResList << QString( "" );
188 aResList << "# Export of the calculation case";
189 QString aStudyName = "theStudy";
190 QString anEntryVar = aCalculName + "_entry";
191 aResList << QString( "%1 = %2.Export( %3._get_StudyId() )" ).arg( anEntryVar ).arg( aCalculName ).arg( aStudyName );
193 // Get geometry object and print debug information
195 aResList << "# Get geometry shape and print debug information";
196 aResList << "import GEOM";
197 aResList << QString( "print \"Entry:\", %1" ).arg( anEntryVar );
198 QString aGeomShapeName = aCalculName + "_geom";
199 aResList << QString( "%1 = salome.IDToObject( str( %2 ) )" ).arg( aGeomShapeName ).arg( anEntryVar );
200 aResList << QString( "print \"Geom shape:\", %1" ).arg( aGeomShapeName );
201 aResList << QString( "print \"Geom shape name:\", %1.GetName()" ).arg( aGeomShapeName );
203 DumpSampleMeshing( aResList, aStudyName, aGeomShapeName, aCalculName+"_mesh" );
205 aResList << QString( "" );
209 void HYDROData_CalculationCase::DumpSampleMeshing( QStringList& theResList,
210 const QString& theStudyName,
211 const QString& theGeomShapeName,
212 const QString& theMeshName ) const
215 theResList << "# Meshing";
216 theResList << "import SMESH, SALOMEDS";
217 theResList << "from salome.smesh import smeshBuilder";
218 theResList << "from salome.geom import geomBuilder";
220 theResList << QString( "smesh = smeshBuilder.New( %1 )" ).arg( theStudyName );
221 theResList << QString( "%1 = smesh.Mesh( %2 )" ).arg( theMeshName ).arg( theGeomShapeName );
222 theResList << QString( "MEFISTO_2D = %1.Triangle( algo=smeshBuilder.MEFISTO )" ).arg( theMeshName );
223 theResList << "Max_Element_Area_1 = MEFISTO_2D.MaxElementArea( 10 )";
224 theResList << QString( "Regular_1D = %1.Segment()" ).arg( theMeshName );
225 theResList << "Max_Size_1 = Regular_1D.MaxSize(10)";
226 theResList << QString( "isDone = %1.Compute()" ).arg( theMeshName );
229 theResList << "# Set names of Mesh objects";
230 theResList << "smesh.SetName( MEFISTO_2D.GetAlgorithm(), 'MEFISTO_2D' )";
231 theResList << "smesh.SetName( Regular_1D.GetAlgorithm(), 'Regular_1D' )";
232 theResList << "smesh.SetName( Max_Size_1, 'Max Size_1' )";
233 theResList << "smesh.SetName( Max_Element_Area_1, 'Max. Element Area_1' )";
234 theResList << QString( "smesh.SetName( %1.GetMesh(), '%1' )" ).arg( theMeshName );
237 theResList << "# Greate SMESH groups";
238 theResList << QString( "geompy = geomBuilder.New( %1 )" ).arg( theStudyName );
239 theResList << QString( "geom_groups = geompy.GetGroups( %1 )" ).arg( theGeomShapeName );
240 theResList << QString( "for group in geom_groups:" );
241 theResList << QString( " smesh_group = %1.GroupOnGeom(group, group.GetName(), SMESH.EDGE)" )
243 theResList << QString( " smesh.SetName(smesh_group, group.GetName())" );
244 theResList << QString( " print \"SMESH group '%s': %s\" % (smesh_group.GetName(), smesh_group)" );
247 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() const
249 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
251 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
252 if ( !aBoundaryPolyline.IsNull() )
253 aResSeq.Append( aBoundaryPolyline );
255 HYDROData_SequenceOfObjects aSeqOfGeomObjs = GetGeometryObjects();
256 aResSeq.Append( aSeqOfGeomObjs );
259 HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
260 aResSeq.Append( aSeqOfRegions );
265 void HYDROData_CalculationCase::Update()
267 HYDROData_Entity::Update();
270 // At first we remove previously created objects
274 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
275 if ( aDocument.IsNull() )
279 HYDROData_SplitToZonesTool::SplitDataList aZonesList, anEdgesList;
281 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
282 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
283 if ( !aGeomObjects.IsEmpty() ) {
284 HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
286 HYDROData_SplitToZonesTool::SplitDataList aSplitObjects =
287 HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline );
288 if ( !aSplitObjects.isEmpty() ) {
289 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitObjects );
290 while( anIter.hasNext() ) {
291 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
292 if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
293 aZonesList.append( aSplitData );
294 else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
295 anEdgesList.append( aSplitData );
300 switch( GetAssignmentMode() )
303 CreateRegionsDef( aDocument, aZonesList );
306 CreateRegionsAuto( aDocument, aZonesList );
310 CreateEdgeGroupsDef( aDocument, anEdgesList );
313 void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
314 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
316 // Create result regions for case, by default one zone for one region
317 QString aRegsPref = CALCULATION_REGIONS_PREF;
318 QString aZonesPref = CALCULATION_ZONES_PREF;
320 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
321 while( anIter.hasNext() )
323 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
325 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref );
327 // Add the zone for region
328 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
332 void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
333 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
335 DEBTRACE("HYDROData_CalculationCase::CreateRegionsAuto");
336 QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
337 QMap<QString, QString> aRegionNameToObjNameMap;
338 QString aZonesPref = CALCULATION_ZONES_PREF;
339 HYDROData_PriorityQueue aPr( this, DataTag_CustomRules );
341 // 1. First we create a default region for each object included into the calculation case
342 HYDROData_SequenceOfObjects anObjects = GetGeometryObjects();
343 for( int i = anObjects.Lower(), n = anObjects.Upper(); i<=n; i++ )
345 Handle(HYDROData_Entity) anObj = anObjects.Value( i );
348 QString anObjName = anObj->GetName();
349 QString aRegName = anObjName + "_reg";
350 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false );
351 aRegionsMap.insert( anObjName, aRegion );
352 aRegionNameToObjNameMap.insert( aRegName, anObjName );
355 // 2. Now for each zone it is necessary to determine the most priority object
356 // and assign to zone to corresponding region
357 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
358 while( anIter.hasNext() )
360 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
361 HYDROData_Zone::MergeType aMergeType;
362 Handle(HYDROData_Entity) aRegObj = aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType );
363 if( aRegObj.IsNull() )
365 Handle(HYDROData_Region) aRegion = aRegionsMap[aRegObj->GetName()];
366 if( aRegion.IsNull() )
368 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
370 if( aSplitData.ObjectNames.count() > 1 && aMergeType==HYDROData_Zone::Merge_UNKNOWN )
372 qDebug( "Error in algorithm: unresolved conflicts" );
375 Handle(HYDROData_Entity) aMergeEntity = aRegObj;
376 Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity );
377 if ( !aMergeObject.IsNull() ) {
378 DEBTRACE("aMergeEntity " << aMergeEntity->GetName().toStdString());
379 aMergeEntity = aMergeObject->GetAltitudeObject();
384 case HYDROData_Zone::Merge_ZMIN:
385 case HYDROData_Zone::Merge_ZMAX:
386 aRegionZone->SetMergeType( aMergeType );
388 case HYDROData_Zone::Merge_Object:
389 aRegionZone->SetMergeType( aMergeType );
390 aRegionZone->RemoveMergeObject();
391 aRegionZone->SetMergeObject( aMergeEntity );
396 QStringList anObjectsWithEmptyRegions;
397 QMap<QString, Handle(HYDROData_Region)>::const_iterator
398 anIt = aRegionsMap.begin(), aLast = aRegionsMap.end();
399 for( ; anIt!=aLast; anIt++ )
401 Handle(HYDROData_Region) aRegion = anIt.value();
402 if( aRegion->GetZones().IsEmpty() )
404 QString aRegName = aRegion->GetName();
405 QString anObjName = aRegionNameToObjNameMap[aRegName];
406 anObjectsWithEmptyRegions.append( anObjName );
410 if( !anObjectsWithEmptyRegions.empty() )
412 QString aData = anObjectsWithEmptyRegions.join( ", " );
413 SetWarning( WARN_EMPTY_REGIONS, aData );
417 void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
418 const HYDROData_SplitToZonesTool::SplitDataList& theEdges )
420 QMap<QString,Handle(HYDROData_SplitShapesGroup)> aSplitEdgesGroupsMap;
422 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges );
423 while( anIter.hasNext() )
425 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
426 // Create new edges group
427 if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
430 QString anObjName = aSplitData.ObjectNames.first();
431 if ( anObjName.isEmpty() )
433 #ifdef DEB_CALCULATION
434 QString aStr = aSplitData.ObjectNames.join(" ");
435 cout << " CCase: Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size() <<endl;
437 Handle(HYDROData_SplitShapesGroup) aSplitGroup;
438 if ( !aSplitEdgesGroupsMap.contains( anObjName ) )
440 aSplitGroup = addNewSplitGroup( CALCULATION_GROUPS_PREF + anObjName );
441 aSplitEdgesGroupsMap.insert( anObjName, aSplitGroup );
445 aSplitGroup = aSplitEdgesGroupsMap[ anObjName ];
447 if ( aSplitGroup.IsNull() )
450 aSplitGroup->AddShape( aSplitData.Shape );
454 bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
456 if ( !HYDROData_Tool::IsGeometryObject( theObject ) )
457 return false; // Wrong type of object
459 if ( HasReference( theObject, DataTag_GeometryObject ) )
460 return false; // Object is already in reference list
462 AddReferenceObject( theObject, DataTag_GeometryObject );
464 // Indicate model of the need to update splitting
470 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryObjects() const
472 return GetReferenceObjects( DataTag_GeometryObject );
475 void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject )
477 if ( theObject.IsNull() )
480 RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
482 // Indicate model of the need to update splitting
486 void HYDROData_CalculationCase::RemoveGeometryObjects()
488 ClearReferenceObjects( DataTag_GeometryObject );
490 // Indicate model of the need to update splitting
494 bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
496 if ( theGroup.IsNull() )
499 if ( HasReference( theGroup, DataTag_GeometryGroup ) )
500 return false; // Object is already in reference list
502 AddReferenceObject( theGroup, DataTag_GeometryGroup );
504 // Indicate model of the need to update splitting
505 Changed( Geom_Groups );
510 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryGroups() const
512 return GetReferenceObjects( DataTag_GeometryGroup );
515 void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
517 if ( theGroup.IsNull() )
520 RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
522 // Indicate model of the need to update splitting
523 Changed( Geom_Groups );
526 void HYDROData_CalculationCase::RemoveGeometryGroups()
528 ClearReferenceObjects( DataTag_GeometryGroup );
530 // Indicate model of the need to update splitting
531 Changed( Geom_Groups );
534 void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
536 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
538 SetReferenceObject( thePolyline, DataTag_Polyline );
540 // Indicate model of the need to update zones splitting
541 if( !IsEqual( aPrevPolyline, thePolyline ) )
545 Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
547 return Handle(HYDROData_PolylineXY)::DownCast(
548 GetReferenceObject( DataTag_Polyline ) );
551 void HYDROData_CalculationCase::RemoveBoundaryPolyline()
553 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
555 ClearReferenceObjects( DataTag_Polyline );
557 // Indicate model of the need to update zones splitting
561 void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
563 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
565 SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
567 // Indicate model of the need to update land covers partition
568 if( !IsEqual( aPrevStricklerTable, theStricklerTable ) )
572 Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
574 return Handle(HYDROData_StricklerTable)::DownCast(
575 GetReferenceObject( DataTag_StricklerTable ) );
578 void HYDROData_CalculationCase::RemoveStricklerTable()
580 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
582 ClearReferenceObjects( DataTag_StricklerTable );
584 // Indicate model of the need to update land covers partition
588 Handle(HYDROData_LandCoverMap) HYDROData_CalculationCase::GetLandCoverMap() const
590 Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast(
591 GetReferenceObject( DataTag_LandCoverMap ) );
595 void HYDROData_CalculationCase::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
597 SetReferenceObject( theMap, DataTag_LandCoverMap );
600 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
605 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
606 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
607 if ( aNewRegion.IsNull() )
610 aNewRegion->AddZone( theZone );
615 bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion )
617 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
619 if ( theRegion.IsNull() )
622 HYDROData_CalculationCase::DataTag aDataTag = DataTag_Region;
624 if ( HasReference( theRegion, aDataTag ) )
625 return false; // Object is already in reference list
627 // Move the region from other calculation
628 Handle(HYDROData_CalculationCase) aFatherCalc =
629 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
630 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
632 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
633 theRegion->CopyTo( aNewRegion, true );
635 aFatherCalc->RemoveRegion( theRegion );
637 theRegion->SetLabel( aNewRegion->Label() );
641 AddReferenceObject( theRegion, aDataTag );
647 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const
649 return GetReferenceObjects( DataTag_Region );
652 void HYDROData_CalculationCase::UpdateRegionsOrder()
654 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
655 if ( aDocument.IsNull() )
658 HYDROData_SequenceOfObjects aRegions = GetRegions();
659 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
660 for ( ; anIter.More(); anIter.Next() )
662 Handle(HYDROData_Region) aRegion =
663 Handle(HYDROData_Region)::DownCast( anIter.Value() );
664 if ( aRegion.IsNull() )
667 aRegion->SetName( "" );
670 QString aRegsPref = CALCULATION_REGIONS_PREF;
672 anIter.Init( aRegions );
673 for ( ; anIter.More(); anIter.Next() )
675 Handle(HYDROData_Region) aRegion =
676 Handle(HYDROData_Region)::DownCast( anIter.Value() );
677 if ( aRegion.IsNull() )
680 QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
681 aRegion->SetName( aRegionName );
685 void HYDROData_CalculationCase::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
687 if ( theRegion.IsNull() )
690 HYDROData_CalculationCase::DataTag aDataTag = DataTag_Region;
691 RemoveReferenceObject( theRegion->Label(), aDataTag );
693 // Remove region from data model
694 Handle(HYDROData_CalculationCase) aFatherCalc =
695 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
696 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab )
700 void HYDROData_CalculationCase::RemoveRegions()
702 myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes();
705 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetSplitGroups() const
707 return GetReferenceObjects( DataTag_SplitGroups );
710 void HYDROData_CalculationCase::RemoveSplitGroups()
712 myLab.FindChild( DataTag_SplitGroups ).ForgetAllAttributes();
715 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) const
717 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
718 return GetAltitudeForPoint( thePoint, aZone );
721 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
722 const Handle(HYDROData_Region)& theRegion ) const
724 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
726 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
727 if ( !aZone.IsNull() )
729 //DEBTRACE("GetAltitudeForPoint Region " << theRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString());
730 Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
731 if ( IsEqual( aRefRegion, theRegion ) )
732 aResAltitude = GetAltitudeForPoint( thePoint, aZone );
735 DEBTRACE("GetAltitudeForPoint Region " << aRefRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString() << " ---------------------------");
736 aResAltitude = GetAltitudeForPoint( thePoint, aZone );
741 DEBTRACE(" --- GetAltitudeForPoint No Zone ---");
747 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
748 const Handle(HYDROData_Zone)& theZone ) const
750 //DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString());
751 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
752 if ( theZone.IsNull() )
754 DEBTRACE("Zone nulle");
758 HYDROData_Zone::MergeType aZoneMergeType = theZone->GetMergeType();
759 //DEBTRACE("aZoneMergeType " << aZoneMergeType);
760 if ( !theZone->IsMergingNeed() )
762 aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN;
765 else if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
767 DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString() << " Merge_UNKNOWN");
771 HYDROData_IInterpolator* aZoneInterpolator = theZone->GetInterpolator();
772 if ( aZoneMergeType == HYDROData_Zone::Merge_Object )
774 Handle(HYDROData_IAltitudeObject) aMergeAltitude =
775 Handle(HYDROData_IAltitudeObject)::DownCast( theZone->GetMergeObject() );
776 if ( !aMergeAltitude.IsNull() )
778 if ( aZoneInterpolator != NULL )
780 DEBTRACE("aZoneInterpolator != NULL");
781 aZoneInterpolator->SetAltitudeObject( aMergeAltitude );
782 aResAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
786 DEBTRACE("aZoneInterpolator == NULL");
787 aResAltitude = aMergeAltitude->GetAltitudeForPoint( thePoint );
793 //DEBTRACE("aZoneMergeType != HYDROData_Zone::Merge_Object");
794 HYDROData_SequenceOfObjects aZoneObjects = theZone->GetObjects();
795 HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects );
796 for ( ; anIter.More(); anIter.Next() )
798 Handle(HYDROData_Object) aZoneObj =
799 Handle(HYDROData_Object)::DownCast( anIter.Value() );
800 if ( aZoneObj.IsNull() )
803 Handle(HYDROData_IAltitudeObject) anObjAltitude = aZoneObj->GetAltitudeObject();
804 if ( anObjAltitude.IsNull() )
807 double aPointAltitude = 0.0;
808 if ( aZoneInterpolator != NULL )
810 DEBTRACE("aZoneInterpolator != NULL");
811 aZoneInterpolator->SetAltitudeObject( anObjAltitude );
812 aPointAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
816 //DEBTRACE("aZoneInterpolator == NULL");
817 aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint );
820 if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) )
823 if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
825 aResAltitude = aPointAltitude;
828 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMIN )
830 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
831 aResAltitude > aPointAltitude )
833 aResAltitude = aPointAltitude;
836 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMAX )
838 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
839 aResAltitude < aPointAltitude )
841 aResAltitude = aPointAltitude;
850 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
851 const NCollection_Sequence<gp_XY>& thePoints,
852 const Handle(HYDROData_Region)& theRegion ) const
854 //DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString());
855 NCollection_Sequence<double> aResSeq;
857 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
859 const gp_XY& thePnt = thePoints.Value( i );
861 double anAltitude = GetAltitudeForPoint( thePnt, theRegion );
862 aResSeq.Append( anAltitude );
868 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
869 const NCollection_Sequence<gp_XY>& thePoints,
870 const Handle(HYDROData_Zone)& theZone ) const
872 NCollection_Sequence<double> aResSeq;
874 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
876 const gp_XY& thePnt = thePoints.Value( i );
878 double anAltitude = GetAltitudeForPoint( thePnt, theZone );
879 aResSeq.Append( anAltitude );
885 double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const
887 Handle( HYDROData_LandCoverMap ) aMap = GetLandCoverMap();
888 Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable();
893 aMap->FindByPoint( thePoint, aType );
894 double aCoeff = aTable->Get( aType, 0.0 );
898 Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
900 Handle(HYDROData_Region) aResRegion;
902 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
903 if ( !aZone.IsNull() )
904 aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
909 Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
911 Handle(HYDROData_Zone) aResZone;
913 HYDROData_SequenceOfObjects aRegions = GetRegions();
915 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
916 for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() )
918 Handle(HYDROData_Region) aRegion =
919 Handle(HYDROData_Region)::DownCast( anIter.Value() );
920 if ( aRegion.IsNull() )
923 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
924 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
925 for ( ; aZonesIter.More() && aResZone.IsNull(); aZonesIter.Next() )
927 Handle(HYDROData_Zone) aRegZone =
928 Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
929 if ( aRegZone.IsNull() )
932 PointClassification aPointRelation = GetPointClassification( thePoint, aRegZone );
933 if ( aPointRelation != POINT_OUT )
934 aResZone = aRegZone; // We found the desired zone
941 HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPointClassification(
942 const gp_XY& thePoint,
943 const Handle(HYDROData_Zone)& theZone ) const
945 PointClassification aRes = POINT_OUT;
946 if ( theZone.IsNull() )
949 TopoDS_Face aZoneFace = TopoDS::Face( theZone->GetShape() );
950 if ( aZoneFace.IsNull() )
953 TopoDS_Compound aCmp;
955 aBB.MakeCompound(aCmp);
956 aBB.Add(aCmp, aZoneFace);
957 gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
958 BRepBuilderAPI_MakeVertex aMk(aPnt);
959 aBB.Add(aCmp, aMk.Vertex());
960 BRepTools::Write(aCmp, "FCL2d.brep");
962 TopAbs_State State = HYDROData_Tool::ComputePointState(thePoint, aZoneFace);
963 if (State == TopAbs_OUT)
965 else if(State == TopAbs_IN)
967 else if(State == TopAbs_ON)
972 Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(HYDROData_Document)& theDoc,
973 const QString& thePrefixOrName,
976 TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
977 int aTag = aNewLab.Tag();
979 Handle(HYDROData_Region) aNewRegion =
980 Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
981 AddRegion( aNewRegion );
983 QString aRegionName = isPrefix ? HYDROData_Tool::GenerateObjectName( theDoc, thePrefixOrName ) : thePrefixOrName;
984 aNewRegion->SetName( aRegionName );
989 Handle(HYDROData_SplitShapesGroup) HYDROData_CalculationCase::addNewSplitGroup( const QString& theName )
991 TDF_Label aNewLab = myLab.FindChild( DataTag_SplitGroups ).NewChild();
993 Handle(HYDROData_SplitShapesGroup) aNewGroup =
994 Handle(HYDROData_SplitShapesGroup)::DownCast(
995 HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLIT_GROUP ) );
996 AddReferenceObject( aNewGroup, DataTag_SplitGroups );
998 aNewGroup->SetName( theName );
1003 QString HYDROData_CalculationCase::Export( int theStudyId ) const
1008 GEOM::GEOM_Gen_var aGEOMEngine = HYDROData_GeomTool::GetGeomGen();
1009 SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId );
1011 QString aGeomObjEntry, anErrorMsg;
1012 bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg );
1013 return isOK ? aGeomObjEntry : QString();
1018 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
1019 SALOMEDS::Study_ptr theStudy,
1020 QString& theGeomObjEntry,
1021 QString& theErrorMsg ) const
1023 HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
1025 // Get groups definitions
1026 HYDROData_SequenceOfObjects aSplitGroups = GetSplitGroups();
1028 HYDROData_SequenceOfObjects::Iterator anIter( aSplitGroups );
1029 for ( ; anIter.More(); anIter.Next() )
1032 Handle(HYDROData_ShapesGroup) aGroup =
1033 Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
1034 if ( aGroup.IsNull() )
1037 HYDROData_ShapesGroup::GroupDefinition aGroupDef;
1039 aGroupDef.Name = aGroup->GetName().toLatin1().constData();
1040 aGroup->GetShapes( aGroupDef.Shapes );
1042 aSeqOfGroupsDefs.Append( aGroupDef );
1046 bool isAllNotSubmersible = true;
1047 TopTools_ListOfShape aFaces;
1048 HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
1049 HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
1050 for ( ; aRegionIter.More(); aRegionIter.Next() )
1052 Handle(HYDROData_Region) aRegion =
1053 Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
1054 if( aRegion.IsNull() || !aRegion->IsSubmersible() )
1057 if ( isAllNotSubmersible )
1058 isAllNotSubmersible = false;
1060 TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
1061 aFaces.Append( aRegionShape );
1066 if ( aCaseRegions.IsEmpty() ) {
1067 theErrorMsg = QString("the list of regions is empty.");
1068 } else if ( isAllNotSubmersible ) {
1069 theErrorMsg = QString("there are no submersible regions.");
1071 aRes = Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );;
1077 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
1078 SALOMEDS::Study_ptr theStudy,
1079 const TopTools_ListOfShape& theFaces,
1080 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
1081 QString& theGeomObjEntry ) const
1084 BRepBuilderAPI_Sewing aSewing( Precision::Confusion() * 10.0 );
1085 aSewing.SetNonManifoldMode( Standard_False );
1086 #ifdef DEB_CALCULATION
1087 TCollection_AsciiString aNam("Sh_");
1090 TopTools_ListIteratorOfListOfShape aFaceIter( theFaces );
1091 for ( ; aFaceIter.More(); aFaceIter.Next() )
1093 TopoDS_Shape aShape = aFaceIter.Value();
1094 if ( aShape.IsNull() )
1097 if ( aShape.ShapeType() == TopAbs_FACE )
1099 aSewing.Add( aShape );
1100 #ifdef DEB_CALCULATION
1101 TCollection_AsciiString aName = aNam + ++i + ".brep";
1102 BRepTools::Write(aShape ,aName.ToCString());
1107 #ifdef DEB_CALCULATION
1110 TopExp_Explorer anExp( aShape, TopAbs_FACE );
1111 for (; anExp.More(); anExp.Next() ) {
1112 aSewing.Add( anExp.Current() );
1113 #ifdef DEB_CALCULATION
1115 TCollection_AsciiString aName = aNam + i + "_" + ++j + ".brep";
1116 BRepTools::Write(anExp.Current() ,aName.ToCString());
1123 TopoDS_Shape aSewedShape = aSewing.SewedShape();
1125 // If the sewed shape is empty - return false
1126 if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() )
1129 #ifdef DEB_CALCULATION
1130 BRepTools::Write(aSewedShape ,"Sew.brep");
1132 // Publish the sewed shape
1133 QString aName = EXPORT_NAME;
1134 GEOM::GEOM_Object_ptr aMainShape =
1135 HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry );
1137 if ( aMainShape->_is_nil() )
1140 if ( theGroupsDefs.IsEmpty() )
1144 TopTools_IndexedMapOfShape aMapOfSubShapes;
1145 TopExp::MapShapes( aSewedShape, aMapOfSubShapes );
1147 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> > aGroupsData;
1149 for ( int aGrId = 1, nbGroups = theGroupsDefs.Length(); aGrId <= nbGroups; ++aGrId )
1151 const HYDROData_ShapesGroup::GroupDefinition& aGroupDef = theGroupsDefs.Value( aGrId );
1153 NCollection_Sequence<int> aGroupIndexes;
1154 for( int i = 1, n = aGroupDef.Shapes.Length(); i <= n; i++ )
1156 const TopoDS_Shape& aShape = aGroupDef.Shapes.Value( i );
1157 #ifdef DEB_CALCULATION
1158 cout << "\nOld shape(" << i << ") = " << aShape.TShape() <<endl;
1161 TopoDS_Shape aModifiedShape = aShape;
1162 if ( aSewing.IsModified( aShape ) )
1163 aModifiedShape = aSewing.Modified( aShape );
1164 else if ( aSewing.IsModifiedSubShape( aShape ) )
1165 aModifiedShape = aSewing.ModifiedSubShape( aShape );
1167 #ifdef DEB_CALCULATION
1168 const TopLoc_Location& aL1 = aShape.Location();
1169 const TopLoc_Location& aL2 = aModifiedShape.Location();
1170 cout << "\nNew shape(" << i << ") = " << aModifiedShape.TShape() << " Location is Equal = " << aL1.IsEqual(aL2)<<endl;
1173 int anIndex = aMapOfSubShapes.FindIndex(aModifiedShape);
1174 if ( anIndex > 0 ) {
1175 aGroupIndexes.Append( anIndex );
1177 #ifdef DEB_CALCULATION
1178 TCollection_AsciiString aNam("Lost_");
1179 if(!aMapOfSubShapes.Contains(aModifiedShape)) {
1180 for ( int anIndex = 1; anIndex <= aMapOfSubShapes.Extent(); anIndex++ )
1182 const TopoDS_Shape& aS = aMapOfSubShapes.FindKey( anIndex );
1183 if ( aModifiedShape.IsPartner( aS ) )
1185 cout <<"\nIndex in Map = " << anIndex << "TShape = " << aS.TShape() <<endl;
1186 TCollection_AsciiString aName = aNam + i + "_" + anIndex + ".brep";
1187 BRepTools::Write(aS ,aName.ToCString());
1195 if ( !aGroupIndexes.IsEmpty() )
1196 aGroupsData.Bind( aGroupDef.Name, aGroupIndexes );
1199 if ( !aGroupsData.IsEmpty() )
1201 GEOM::GEOM_IGroupOperations_var aGroupOp =
1202 theGeomEngine->GetIGroupOperations( theStudy->StudyId() );
1204 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> >::Iterator aMapIt( aGroupsData );
1205 for ( ; aMapIt.More(); aMapIt.Next() )
1207 const TCollection_AsciiString& aGroupName = aMapIt.Key();
1208 const NCollection_Sequence<int>& aGroupIndexes = aMapIt.Value();
1210 GEOM::GEOM_Object_var aGeomGroup = aGroupOp->CreateGroup( aMainShape, TopAbs_EDGE );
1211 if ( CORBA::is_nil( aGeomGroup ) || !aGroupOp->IsDone() )
1214 GEOM::ListOfLong_var aGeomIndexes = new GEOM::ListOfLong;
1215 aGeomIndexes->length( aGroupIndexes.Length() );
1217 for( int i = 1, n = aGroupIndexes.Length(); i <= n; i++ )
1218 aGeomIndexes[ i - 1 ] = aGroupIndexes.Value( i );
1220 aGroupOp->UnionIDs( aGeomGroup, aGeomIndexes );
1221 if ( aGroupOp->IsDone() )
1223 SALOMEDS::SObject_var aGroupSO =
1224 theGeomEngine->AddInStudy( theStudy, aGeomGroup, aGroupName.ToCString(), aMainShape );
1233 void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
1234 const bool theIsSetToUpdate )
1236 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1237 HYDROData_PriorityQueue::ClearRules( aRulesLab );
1239 // Indicate model of the need to update splitting
1240 if ( theIsSetToUpdate ) {
1245 void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theObject1,
1246 HYDROData_PriorityType thePriority,
1247 const Handle(HYDROData_Entity)& theObject2,
1248 HYDROData_Zone::MergeType theMergeType,
1249 HYDROData_CalculationCase::DataTag theDataTag )
1251 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1252 HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
1254 // Indicate model of the need to update splitting
1258 QString HYDROData_CalculationCase::DumpRules() const
1260 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1261 return HYDROData_PriorityQueue::DumpRules( aRulesLab );
1264 void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
1266 TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode );
1267 TDataStd_Integer::Set( aModeLab, ( int ) theMode );
1269 // Indicate model of the need to update splitting
1273 HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const
1275 Handle(TDataStd_Integer) aModeAttr;
1276 bool isOK = myLab.FindChild( DataTag_AssignmentMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
1278 return ( AssignmentMode ) aModeAttr->Get();
1283 void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseName,
1284 QStringList& theScript ) const
1286 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1287 HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
1290 HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const
1292 return myLastWarning;
1295 void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const QString& theData )
1297 myLastWarning.Type = theType;
1298 myLastWarning.Data = theData;
1301 void HYDROData_CalculationCase::UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
1302 const QString& theOldCaseName,
1303 const QString& theName )
1305 HYDROData_SequenceOfObjects::Iterator anIter( theRegions );
1306 for ( ; anIter.More(); anIter.Next() )
1308 Handle(HYDROData_Region) aRegion =
1309 Handle(HYDROData_Region)::DownCast( anIter.Value() );
1310 if ( aRegion.IsNull() )
1313 HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegion );
1315 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
1316 HYDROData_SequenceOfObjects::Iterator anIter( aZones );
1317 for ( ; anIter.More(); anIter.Next() )
1319 Handle(HYDROData_Zone) aRegZone =
1320 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
1321 if ( aRegZone.IsNull() )
1324 HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegZone );
1329 void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList,
1330 const QString& thePyScriptPath,
1331 MapOfTreatedObjects& theTreatedObjects,
1332 const HYDROData_SequenceOfObjects& theRegions ) const
1334 HYDROData_SequenceOfObjects::Iterator anIter;
1335 anIter.Init( theRegions );
1336 for ( ; anIter.More(); anIter.Next() )
1338 Handle(HYDROData_Region) aRegion =
1339 Handle(HYDROData_Region)::DownCast( anIter.Value() );
1340 if ( aRegion.IsNull() )
1343 theTreatedObjects.insert( aRegion->GetName(), aRegion );
1344 QStringList aRegDump = aRegion->DumpToPython( thePyScriptPath, theTreatedObjects );
1345 theResList << aRegDump;
1349 bool HYDROData_CalculationCase::GetRule( int theIndex,
1350 Handle(HYDROData_Entity)& theObject1,
1351 HYDROData_PriorityType& thePriority,
1352 Handle(HYDROData_Entity)& theObject2,
1353 HYDROData_Zone::MergeType& theMergeType,
1354 HYDROData_CalculationCase::DataTag& theDataTag) const
1356 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1357 return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
1358 theObject1, thePriority, theObject2, theMergeType );