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( "HYDRO_%1 = salome.IDToObject( str( %2 ) )" ).arg( GetName() ).arg( anEntryVar );
200 aResList << QString( "print \"Geom shape:\", HYDRO_%1" ).arg( GetName() );
201 aResList << QString( "print \"Geom shape name:\", HYDRO_%1.GetName()" ).arg( GetName() );
204 //DumpSampleMeshing( aResList, aStudyName, aGeomShapeName, aCalculName+"_mesh" );
206 aResList << QString( "" );
210 void HYDROData_CalculationCase::DumpSampleMeshing( QStringList& theResList,
211 const QString& theStudyName,
212 const QString& theGeomShapeName,
213 const QString& theMeshName ) const
216 theResList << "# Meshing";
217 theResList << "import SMESH, SALOMEDS";
218 theResList << "from salome.smesh import smeshBuilder";
219 theResList << "from salome.geom import geomBuilder";
221 theResList << QString( "smesh = smeshBuilder.New( %1 )" ).arg( theStudyName );
222 theResList << QString( "%1 = smesh.Mesh( %2 )" ).arg( theMeshName ).arg( theGeomShapeName );
223 theResList << QString( "MEFISTO_2D = %1.Triangle( algo=smeshBuilder.MEFISTO )" ).arg( theMeshName );
224 theResList << "Max_Element_Area_1 = MEFISTO_2D.MaxElementArea( 10 )";
225 theResList << QString( "Regular_1D = %1.Segment()" ).arg( theMeshName );
226 theResList << "Max_Size_1 = Regular_1D.MaxSize(10)";
227 theResList << QString( "isDone = %1.Compute()" ).arg( theMeshName );
230 theResList << "# Set names of Mesh objects";
231 theResList << "smesh.SetName( MEFISTO_2D.GetAlgorithm(), 'MEFISTO_2D' )";
232 theResList << "smesh.SetName( Regular_1D.GetAlgorithm(), 'Regular_1D' )";
233 theResList << "smesh.SetName( Max_Size_1, 'Max Size_1' )";
234 theResList << "smesh.SetName( Max_Element_Area_1, 'Max. Element Area_1' )";
235 theResList << QString( "smesh.SetName( %1.GetMesh(), '%1' )" ).arg( theMeshName );
238 theResList << "# Greate SMESH groups";
239 theResList << QString( "geompy = geomBuilder.New( %1 )" ).arg( theStudyName );
240 theResList << QString( "geom_groups = geompy.GetGroups( %1 )" ).arg( theGeomShapeName );
241 theResList << QString( "for group in geom_groups:" );
242 theResList << QString( " smesh_group = %1.GroupOnGeom(group, group.GetName(), SMESH.EDGE)" )
244 theResList << QString( " smesh.SetName(smesh_group, group.GetName())" );
245 theResList << QString( " print \"SMESH group '%s': %s\" % (smesh_group.GetName(), smesh_group)" );
248 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() const
250 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
252 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
253 if ( !aBoundaryPolyline.IsNull() )
254 aResSeq.Append( aBoundaryPolyline );
256 HYDROData_SequenceOfObjects aSeqOfGeomObjs = GetGeometryObjects();
257 aResSeq.Append( aSeqOfGeomObjs );
260 HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
261 aResSeq.Append( aSeqOfRegions );
266 void HYDROData_CalculationCase::Update()
268 HYDROData_Entity::Update();
271 // At first we remove previously created objects
275 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
276 if ( aDocument.IsNull() )
280 HYDROData_SplitToZonesTool::SplitDataList aZonesList, anEdgesList;
282 Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
283 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
284 if ( !aGeomObjects.IsEmpty() ) {
285 HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
287 HYDROData_SplitToZonesTool::SplitDataList aSplitObjects =
288 HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline );
289 if ( !aSplitObjects.isEmpty() ) {
290 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitObjects );
291 while( anIter.hasNext() ) {
292 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
293 if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
294 aZonesList.append( aSplitData );
295 else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
296 anEdgesList.append( aSplitData );
301 switch( GetAssignmentMode() )
304 CreateRegionsDef( aDocument, aZonesList );
307 CreateRegionsAuto( aDocument, aZonesList );
311 CreateEdgeGroupsDef( aDocument, anEdgesList );
314 void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
315 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
317 // Create result regions for case, by default one zone for one region
318 QString aRegsPref = CALCULATION_REGIONS_PREF;
319 QString aZonesPref = CALCULATION_ZONES_PREF;
321 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
322 while( anIter.hasNext() )
324 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
326 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref );
328 // Add the zone for region
329 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
333 void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
334 const HYDROData_SplitToZonesTool::SplitDataList& theZones )
336 DEBTRACE("HYDROData_CalculationCase::CreateRegionsAuto");
337 QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
338 QMap<QString, QString> aRegionNameToObjNameMap;
339 QString aZonesPref = CALCULATION_ZONES_PREF;
340 HYDROData_PriorityQueue aPr( this, DataTag_CustomRules );
342 // 1. First we create a default region for each object included into the calculation case
343 HYDROData_SequenceOfObjects anObjects = GetGeometryObjects();
344 for( int i = anObjects.Lower(), n = anObjects.Upper(); i<=n; i++ )
346 Handle(HYDROData_Entity) anObj = anObjects.Value( i );
349 QString anObjName = anObj->GetName();
350 QString aRegName = anObjName + "_reg";
351 Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false );
352 aRegionsMap.insert( anObjName, aRegion );
353 aRegionNameToObjNameMap.insert( aRegName, anObjName );
356 // 2. Now for each zone it is necessary to determine the most priority object
357 // and assign to zone to corresponding region
358 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones );
359 while( anIter.hasNext() )
361 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
362 HYDROData_Zone::MergeType aMergeType;
363 Handle(HYDROData_Entity) aRegObj = aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType );
364 if( aRegObj.IsNull() )
366 Handle(HYDROData_Region) aRegion = aRegionsMap[aRegObj->GetName()];
367 if( aRegion.IsNull() )
369 Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
371 if( aSplitData.ObjectNames.count() > 1 && aMergeType==HYDROData_Zone::Merge_UNKNOWN )
373 qDebug( "Error in algorithm: unresolved conflicts" );
376 Handle(HYDROData_Entity) aMergeEntity = aRegObj;
377 Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity );
378 if ( !aMergeObject.IsNull() ) {
379 DEBTRACE("aMergeEntity " << aMergeEntity->GetName().toStdString());
380 aMergeEntity = aMergeObject->GetAltitudeObject();
385 case HYDROData_Zone::Merge_ZMIN:
386 case HYDROData_Zone::Merge_ZMAX:
387 aRegionZone->SetMergeType( aMergeType );
389 case HYDROData_Zone::Merge_Object:
390 aRegionZone->SetMergeType( aMergeType );
391 aRegionZone->RemoveMergeObject();
392 aRegionZone->SetMergeObject( aMergeEntity );
397 QStringList anObjectsWithEmptyRegions;
398 QMap<QString, Handle(HYDROData_Region)>::const_iterator
399 anIt = aRegionsMap.begin(), aLast = aRegionsMap.end();
400 for( ; anIt!=aLast; anIt++ )
402 Handle(HYDROData_Region) aRegion = anIt.value();
403 if( aRegion->GetZones().IsEmpty() )
405 QString aRegName = aRegion->GetName();
406 QString anObjName = aRegionNameToObjNameMap[aRegName];
407 anObjectsWithEmptyRegions.append( anObjName );
411 if( !anObjectsWithEmptyRegions.empty() )
413 QString aData = anObjectsWithEmptyRegions.join( ", " );
414 SetWarning( WARN_EMPTY_REGIONS, aData );
418 void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
419 const HYDROData_SplitToZonesTool::SplitDataList& theEdges )
421 QMap<QString,Handle(HYDROData_SplitShapesGroup)> aSplitEdgesGroupsMap;
423 HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges );
424 while( anIter.hasNext() )
426 const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
427 // Create new edges group
428 if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
431 QString anObjName = aSplitData.ObjectNames.first();
432 if ( anObjName.isEmpty() )
434 #ifdef DEB_CALCULATION
435 QString aStr = aSplitData.ObjectNames.join(" ");
436 cout << " CCase: Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size() <<endl;
438 Handle(HYDROData_SplitShapesGroup) aSplitGroup;
439 if ( !aSplitEdgesGroupsMap.contains( anObjName ) )
441 aSplitGroup = addNewSplitGroup( CALCULATION_GROUPS_PREF + anObjName );
442 aSplitEdgesGroupsMap.insert( anObjName, aSplitGroup );
446 aSplitGroup = aSplitEdgesGroupsMap[ anObjName ];
448 if ( aSplitGroup.IsNull() )
451 aSplitGroup->AddShape( aSplitData.Shape );
455 bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
457 if ( !HYDROData_Tool::IsGeometryObject( theObject ) )
458 return false; // Wrong type of object
460 if ( HasReference( theObject, DataTag_GeometryObject ) )
461 return false; // Object is already in reference list
463 AddReferenceObject( theObject, DataTag_GeometryObject );
465 // Indicate model of the need to update splitting
471 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryObjects() const
473 return GetReferenceObjects( DataTag_GeometryObject );
476 void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject )
478 if ( theObject.IsNull() )
481 RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
483 // Indicate model of the need to update splitting
487 void HYDROData_CalculationCase::RemoveGeometryObjects()
489 ClearReferenceObjects( DataTag_GeometryObject );
491 // Indicate model of the need to update splitting
495 bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
497 if ( theGroup.IsNull() )
500 if ( HasReference( theGroup, DataTag_GeometryGroup ) )
501 return false; // Object is already in reference list
503 AddReferenceObject( theGroup, DataTag_GeometryGroup );
505 // Indicate model of the need to update splitting
506 Changed( Geom_Groups );
511 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryGroups() const
513 return GetReferenceObjects( DataTag_GeometryGroup );
516 void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
518 if ( theGroup.IsNull() )
521 RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
523 // Indicate model of the need to update splitting
524 Changed( Geom_Groups );
527 void HYDROData_CalculationCase::RemoveGeometryGroups()
529 ClearReferenceObjects( DataTag_GeometryGroup );
531 // Indicate model of the need to update splitting
532 Changed( Geom_Groups );
535 void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
537 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
539 SetReferenceObject( thePolyline, DataTag_Polyline );
541 // Indicate model of the need to update zones splitting
542 if( !IsEqual( aPrevPolyline, thePolyline ) )
546 Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
548 return Handle(HYDROData_PolylineXY)::DownCast(
549 GetReferenceObject( DataTag_Polyline ) );
552 void HYDROData_CalculationCase::RemoveBoundaryPolyline()
554 Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline();
556 ClearReferenceObjects( DataTag_Polyline );
558 // Indicate model of the need to update zones splitting
562 void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
564 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
566 SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
568 // Indicate model of the need to update land covers partition
569 if( !IsEqual( aPrevStricklerTable, theStricklerTable ) )
573 Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
575 return Handle(HYDROData_StricklerTable)::DownCast(
576 GetReferenceObject( DataTag_StricklerTable ) );
579 void HYDROData_CalculationCase::RemoveStricklerTable()
581 Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
583 ClearReferenceObjects( DataTag_StricklerTable );
585 // Indicate model of the need to update land covers partition
589 Handle(HYDROData_LandCoverMap) HYDROData_CalculationCase::GetLandCoverMap() const
591 Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast(
592 GetReferenceObject( DataTag_LandCoverMap ) );
596 void HYDROData_CalculationCase::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
598 SetReferenceObject( theMap, DataTag_LandCoverMap );
601 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
606 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
607 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
608 if ( aNewRegion.IsNull() )
611 aNewRegion->AddZone( theZone );
616 bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion )
618 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
620 if ( theRegion.IsNull() )
623 HYDROData_CalculationCase::DataTag aDataTag = DataTag_Region;
625 if ( HasReference( theRegion, aDataTag ) )
626 return false; // Object is already in reference list
628 // Move the region from other calculation
629 Handle(HYDROData_CalculationCase) aFatherCalc =
630 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
631 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
633 Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
634 theRegion->CopyTo( aNewRegion, true );
636 aFatherCalc->RemoveRegion( theRegion );
638 theRegion->SetLabel( aNewRegion->Label() );
642 AddReferenceObject( theRegion, aDataTag );
648 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const
650 return GetReferenceObjects( DataTag_Region );
653 void HYDROData_CalculationCase::UpdateRegionsOrder()
655 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
656 if ( aDocument.IsNull() )
659 HYDROData_SequenceOfObjects aRegions = GetRegions();
660 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
661 for ( ; anIter.More(); anIter.Next() )
663 Handle(HYDROData_Region) aRegion =
664 Handle(HYDROData_Region)::DownCast( anIter.Value() );
665 if ( aRegion.IsNull() )
668 aRegion->SetName( "" );
671 QString aRegsPref = CALCULATION_REGIONS_PREF;
673 anIter.Init( aRegions );
674 for ( ; anIter.More(); anIter.Next() )
676 Handle(HYDROData_Region) aRegion =
677 Handle(HYDROData_Region)::DownCast( anIter.Value() );
678 if ( aRegion.IsNull() )
681 QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
682 aRegion->SetName( aRegionName );
686 void HYDROData_CalculationCase::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
688 if ( theRegion.IsNull() )
691 HYDROData_CalculationCase::DataTag aDataTag = DataTag_Region;
692 RemoveReferenceObject( theRegion->Label(), aDataTag );
694 // Remove region from data model
695 Handle(HYDROData_CalculationCase) aFatherCalc =
696 Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
697 if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab )
701 void HYDROData_CalculationCase::RemoveRegions()
703 myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes();
706 HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetSplitGroups() const
708 return GetReferenceObjects( DataTag_SplitGroups );
711 void HYDROData_CalculationCase::RemoveSplitGroups()
713 myLab.FindChild( DataTag_SplitGroups ).ForgetAllAttributes();
716 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) const
718 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
719 return GetAltitudeForPoint( thePoint, aZone );
722 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
723 const Handle(HYDROData_Region)& theRegion,
726 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
728 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
729 if ( !aZone.IsNull() )
731 //DEBTRACE("GetAltitudeForPoint Region " << theRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString());
732 Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
733 if ( IsEqual( aRefRegion, theRegion ) )
734 aResAltitude = GetAltitudeForPoint( thePoint, aZone, theMethod );
737 DEBTRACE("GetAltitudeForPoint Region " << aRefRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString() << " ---------------------------");
738 aResAltitude = GetAltitudeForPoint( thePoint, aZone, theMethod );
743 DEBTRACE(" --- GetAltitudeForPoint No Zone ---");
749 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint,
750 const Handle(HYDROData_Zone)& theZone,
753 //DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString());
754 double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
755 if ( theZone.IsNull() )
757 DEBTRACE("Zone nulle");
761 HYDROData_Zone::MergeType aZoneMergeType = theZone->GetMergeType();
762 //DEBTRACE("aZoneMergeType " << aZoneMergeType);
763 if ( !theZone->IsMergingNeed() )
765 aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN;
768 else if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
770 DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString() << " Merge_UNKNOWN");
774 HYDROData_IInterpolator* aZoneInterpolator = theZone->GetInterpolator();
775 if ( aZoneMergeType == HYDROData_Zone::Merge_Object )
777 Handle(HYDROData_IAltitudeObject) aMergeAltitude =
778 Handle(HYDROData_IAltitudeObject)::DownCast( theZone->GetMergeObject() );
779 if ( !aMergeAltitude.IsNull() )
781 if ( aZoneInterpolator != NULL )
783 DEBTRACE("aZoneInterpolator != NULL");
784 aZoneInterpolator->SetAltitudeObject( aMergeAltitude );
785 aResAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
789 DEBTRACE("aZoneInterpolator == NULL");
790 aResAltitude = aMergeAltitude->GetAltitudeForPoint( thePoint );
796 //DEBTRACE("aZoneMergeType != HYDROData_Zone::Merge_Object");
797 HYDROData_SequenceOfObjects aZoneObjects = theZone->GetObjects();
798 HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects );
799 for ( ; anIter.More(); anIter.Next() )
801 Handle(HYDROData_Object) aZoneObj =
802 Handle(HYDROData_Object)::DownCast( anIter.Value() );
803 if ( aZoneObj.IsNull() )
806 Handle(HYDROData_IAltitudeObject) anObjAltitude = aZoneObj->GetAltitudeObject();
807 if ( anObjAltitude.IsNull() )
810 double aPointAltitude = 0.0;
811 if ( aZoneInterpolator != NULL )
813 DEBTRACE("aZoneInterpolator != NULL");
814 aZoneInterpolator->SetAltitudeObject( anObjAltitude );
815 aPointAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint );
819 //DEBTRACE("aZoneInterpolator == NULL");
820 aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint, theMethod );
823 if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) )
826 if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN )
828 aResAltitude = aPointAltitude;
831 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMIN )
833 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
834 aResAltitude > aPointAltitude )
836 aResAltitude = aPointAltitude;
839 else if ( aZoneMergeType == HYDROData_Zone::Merge_ZMAX )
841 if ( ValuesEquals( aResAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ||
842 aResAltitude < aPointAltitude )
844 aResAltitude = aPointAltitude;
853 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
854 const NCollection_Sequence<gp_XY>& thePoints,
855 const Handle(HYDROData_Region)& theRegion,
858 DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString());
859 NCollection_Sequence<double> aResSeq;
861 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
863 const gp_XY& thePnt = thePoints.Value( i );
865 double anAltitude = GetAltitudeForPoint( thePnt, theRegion, theMethod );
866 aResSeq.Append( anAltitude );
872 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
873 const NCollection_Sequence<gp_XY>& thePoints,
874 const Handle(HYDROData_Zone)& theZone,
877 NCollection_Sequence<double> aResSeq;
879 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
881 const gp_XY& thePnt = thePoints.Value( i );
883 double anAltitude = GetAltitudeForPoint( thePnt, theZone, theMethod );
884 aResSeq.Append( anAltitude );
890 double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const
892 Handle( HYDROData_LandCoverMap ) aMap = GetLandCoverMap();
893 Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable();
898 aMap->FindByPoint( thePoint, aType );
899 double aCoeff = aTable->Get( aType, 0.0 );
903 Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
905 Handle(HYDROData_Region) aResRegion;
907 Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
908 if ( !aZone.IsNull() )
909 aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
914 Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
916 Handle(HYDROData_Zone) aResZone;
918 HYDROData_SequenceOfObjects aRegions = GetRegions();
920 HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
921 for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() )
923 Handle(HYDROData_Region) aRegion =
924 Handle(HYDROData_Region)::DownCast( anIter.Value() );
925 if ( aRegion.IsNull() )
928 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
929 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
930 for ( ; aZonesIter.More() && aResZone.IsNull(); aZonesIter.Next() )
932 Handle(HYDROData_Zone) aRegZone =
933 Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
934 if ( aRegZone.IsNull() )
937 PointClassification aPointRelation = GetPointClassification( thePoint, aRegZone );
938 if ( aPointRelation != POINT_OUT )
939 aResZone = aRegZone; // We found the desired zone
946 HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPointClassification(
947 const gp_XY& thePoint,
948 const Handle(HYDROData_Zone)& theZone ) const
950 PointClassification aRes = POINT_OUT;
951 if ( theZone.IsNull() )
954 TopoDS_Face aZoneFace = TopoDS::Face( theZone->GetShape() );
955 if ( aZoneFace.IsNull() )
958 TopoDS_Compound aCmp;
960 aBB.MakeCompound(aCmp);
961 aBB.Add(aCmp, aZoneFace);
962 gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
963 BRepBuilderAPI_MakeVertex aMk(aPnt);
964 aBB.Add(aCmp, aMk.Vertex());
965 BRepTools::Write(aCmp, "FCL2d.brep");
967 TopAbs_State State = HYDROData_Tool::ComputePointState(thePoint, aZoneFace);
968 if (State == TopAbs_OUT)
970 else if(State == TopAbs_IN)
972 else if(State == TopAbs_ON)
977 Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(HYDROData_Document)& theDoc,
978 const QString& thePrefixOrName,
981 TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
982 int aTag = aNewLab.Tag();
984 Handle(HYDROData_Region) aNewRegion =
985 Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
986 AddRegion( aNewRegion );
988 QString aRegionName = isPrefix ? HYDROData_Tool::GenerateObjectName( theDoc, thePrefixOrName ) : thePrefixOrName;
989 aNewRegion->SetName( aRegionName, true );
994 Handle(HYDROData_SplitShapesGroup) HYDROData_CalculationCase::addNewSplitGroup( const QString& theName )
996 TDF_Label aNewLab = myLab.FindChild( DataTag_SplitGroups ).NewChild();
998 Handle(HYDROData_SplitShapesGroup) aNewGroup =
999 Handle(HYDROData_SplitShapesGroup)::DownCast(
1000 HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLIT_GROUP ) );
1001 AddReferenceObject( aNewGroup, DataTag_SplitGroups );
1003 aNewGroup->SetName( theName );
1008 QString HYDROData_CalculationCase::Export( int theStudyId ) const
1013 GEOM::GEOM_Gen_var aGEOMEngine = HYDROData_GeomTool::GetGeomGen();
1014 SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId );
1016 QString aGeomObjEntry, anErrorMsg;
1017 bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg );
1018 return isOK ? aGeomObjEntry : QString();
1023 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
1024 SALOMEDS::Study_ptr theStudy,
1025 QString& theGeomObjEntry,
1026 QString& theErrorMsg ) const
1028 HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
1030 // Get groups definitions
1031 HYDROData_SequenceOfObjects aSplitGroups = GetSplitGroups();
1033 HYDROData_SequenceOfObjects::Iterator anIter( aSplitGroups );
1034 for ( ; anIter.More(); anIter.Next() )
1037 Handle(HYDROData_ShapesGroup) aGroup =
1038 Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
1039 if ( aGroup.IsNull() )
1042 HYDROData_ShapesGroup::GroupDefinition aGroupDef;
1044 aGroupDef.Name = aGroup->GetName().toLatin1().constData();
1045 aGroup->GetShapes( aGroupDef.Shapes );
1047 aSeqOfGroupsDefs.Append( aGroupDef );
1051 bool isAllNotSubmersible = true;
1052 TopTools_ListOfShape aFaces;
1053 HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
1054 HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
1055 for ( ; aRegionIter.More(); aRegionIter.Next() )
1057 Handle(HYDROData_Region) aRegion =
1058 Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
1059 if( aRegion.IsNull() || !aRegion->IsSubmersible() )
1062 if ( isAllNotSubmersible )
1063 isAllNotSubmersible = false;
1065 TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
1066 aFaces.Append( aRegionShape );
1071 if ( aCaseRegions.IsEmpty() ) {
1072 theErrorMsg = QString("the list of regions is empty.");
1073 } else if ( isAllNotSubmersible ) {
1074 theErrorMsg = QString("there are no submersible regions.");
1076 aRes = Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );;
1079 if( aRes && !GetLandCoverMap().IsNull() && !GetStricklerTable().IsNull() )
1081 QString aTelemacFileName = GetName() + ".telemac";
1082 aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable() );
1087 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
1088 SALOMEDS::Study_ptr theStudy,
1089 const TopTools_ListOfShape& theFaces,
1090 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
1091 QString& theGeomObjEntry ) const
1094 BRepBuilderAPI_Sewing aSewing( Precision::Confusion() * 10.0 );
1095 aSewing.SetNonManifoldMode( Standard_False );
1096 #ifdef DEB_CALCULATION
1097 TCollection_AsciiString aNam("Sh_");
1100 TopTools_ListIteratorOfListOfShape aFaceIter( theFaces );
1101 for ( ; aFaceIter.More(); aFaceIter.Next() )
1103 TopoDS_Shape aShape = aFaceIter.Value();
1104 if ( aShape.IsNull() )
1107 if ( aShape.ShapeType() == TopAbs_FACE )
1109 aSewing.Add( aShape );
1110 #ifdef DEB_CALCULATION
1111 TCollection_AsciiString aName = aNam + ++i + ".brep";
1112 BRepTools::Write(aShape ,aName.ToCString());
1117 #ifdef DEB_CALCULATION
1120 TopExp_Explorer anExp( aShape, TopAbs_FACE );
1121 for (; anExp.More(); anExp.Next() ) {
1122 aSewing.Add( anExp.Current() );
1123 #ifdef DEB_CALCULATION
1125 TCollection_AsciiString aName = aNam + i + "_" + ++j + ".brep";
1126 BRepTools::Write(anExp.Current() ,aName.ToCString());
1133 TopoDS_Shape aSewedShape = aSewing.SewedShape();
1135 // If the sewed shape is empty - return false
1136 if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() )
1139 #ifdef DEB_CALCULATION
1140 BRepTools::Write(aSewedShape ,"Sew.brep");
1142 // Publish the sewed shape
1143 QString aName = EXPORT_NAME;
1144 GEOM::GEOM_Object_ptr aMainShape =
1145 HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry );
1147 if ( aMainShape->_is_nil() )
1150 if ( theGroupsDefs.IsEmpty() )
1154 TopTools_IndexedMapOfShape aMapOfSubShapes;
1155 TopExp::MapShapes( aSewedShape, aMapOfSubShapes );
1157 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> > aGroupsData;
1159 for ( int aGrId = 1, nbGroups = theGroupsDefs.Length(); aGrId <= nbGroups; ++aGrId )
1161 const HYDROData_ShapesGroup::GroupDefinition& aGroupDef = theGroupsDefs.Value( aGrId );
1163 NCollection_Sequence<int> aGroupIndexes;
1164 for( int i = 1, n = aGroupDef.Shapes.Length(); i <= n; i++ )
1166 const TopoDS_Shape& aShape = aGroupDef.Shapes.Value( i );
1167 #ifdef DEB_CALCULATION
1168 cout << "\nOld shape(" << i << ") = " << aShape.TShape() <<endl;
1171 TopoDS_Shape aModifiedShape = aShape;
1172 if ( aSewing.IsModified( aShape ) )
1173 aModifiedShape = aSewing.Modified( aShape );
1174 else if ( aSewing.IsModifiedSubShape( aShape ) )
1175 aModifiedShape = aSewing.ModifiedSubShape( aShape );
1177 #ifdef DEB_CALCULATION
1178 const TopLoc_Location& aL1 = aShape.Location();
1179 const TopLoc_Location& aL2 = aModifiedShape.Location();
1180 cout << "\nNew shape(" << i << ") = " << aModifiedShape.TShape() << " Location is Equal = " << aL1.IsEqual(aL2)<<endl;
1183 int anIndex = aMapOfSubShapes.FindIndex(aModifiedShape);
1184 if ( anIndex > 0 ) {
1185 aGroupIndexes.Append( anIndex );
1187 #ifdef DEB_CALCULATION
1188 TCollection_AsciiString aNam("Lost_");
1189 if(!aMapOfSubShapes.Contains(aModifiedShape)) {
1190 for ( int anIndex = 1; anIndex <= aMapOfSubShapes.Extent(); anIndex++ )
1192 const TopoDS_Shape& aS = aMapOfSubShapes.FindKey( anIndex );
1193 if ( aModifiedShape.IsPartner( aS ) )
1195 cout <<"\nIndex in Map = " << anIndex << "TShape = " << aS.TShape() <<endl;
1196 TCollection_AsciiString aName = aNam + i + "_" + anIndex + ".brep";
1197 BRepTools::Write(aS ,aName.ToCString());
1205 if ( !aGroupIndexes.IsEmpty() )
1206 aGroupsData.Bind( aGroupDef.Name, aGroupIndexes );
1209 if ( !aGroupsData.IsEmpty() )
1211 GEOM::GEOM_IGroupOperations_var aGroupOp =
1212 theGeomEngine->GetIGroupOperations( theStudy->StudyId() );
1214 NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> >::Iterator aMapIt( aGroupsData );
1215 for ( ; aMapIt.More(); aMapIt.Next() )
1217 const TCollection_AsciiString& aGroupName = aMapIt.Key();
1218 const NCollection_Sequence<int>& aGroupIndexes = aMapIt.Value();
1220 GEOM::GEOM_Object_var aGeomGroup = aGroupOp->CreateGroup( aMainShape, TopAbs_EDGE );
1221 if ( CORBA::is_nil( aGeomGroup ) || !aGroupOp->IsDone() )
1224 GEOM::ListOfLong_var aGeomIndexes = new GEOM::ListOfLong;
1225 aGeomIndexes->length( aGroupIndexes.Length() );
1227 for( int i = 1, n = aGroupIndexes.Length(); i <= n; i++ )
1228 aGeomIndexes[ i - 1 ] = aGroupIndexes.Value( i );
1230 aGroupOp->UnionIDs( aGeomGroup, aGeomIndexes );
1231 if ( aGroupOp->IsDone() )
1233 SALOMEDS::SObject_var aGroupSO =
1234 theGeomEngine->AddInStudy( theStudy, aGeomGroup, aGroupName.ToCString(), aMainShape );
1243 void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
1244 const bool theIsSetToUpdate )
1246 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1247 HYDROData_PriorityQueue::ClearRules( aRulesLab );
1249 // Indicate model of the need to update splitting
1250 if ( theIsSetToUpdate ) {
1255 void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theObject1,
1256 HYDROData_PriorityType thePriority,
1257 const Handle(HYDROData_Entity)& theObject2,
1258 HYDROData_Zone::MergeType theMergeType,
1259 HYDROData_CalculationCase::DataTag theDataTag )
1261 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1262 HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
1264 // Indicate model of the need to update splitting
1268 QString HYDROData_CalculationCase::DumpRules() const
1270 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1271 return HYDROData_PriorityQueue::DumpRules( aRulesLab );
1274 void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
1276 TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode );
1277 TDataStd_Integer::Set( aModeLab, ( int ) theMode );
1279 // Indicate model of the need to update splitting
1283 HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const
1285 Handle(TDataStd_Integer) aModeAttr;
1286 bool isOK = myLab.FindChild( DataTag_AssignmentMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
1288 return ( AssignmentMode ) aModeAttr->Get();
1293 void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseName,
1294 QStringList& theScript ) const
1296 TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
1297 HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
1300 HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const
1302 return myLastWarning;
1305 void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const QString& theData )
1307 myLastWarning.Type = theType;
1308 myLastWarning.Data = theData;
1311 void HYDROData_CalculationCase::UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
1312 const QString& theOldCaseName,
1313 const QString& theName )
1315 HYDROData_SequenceOfObjects::Iterator anIter( theRegions );
1316 for ( ; anIter.More(); anIter.Next() )
1318 Handle(HYDROData_Region) aRegion =
1319 Handle(HYDROData_Region)::DownCast( anIter.Value() );
1320 if ( aRegion.IsNull() )
1323 HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegion );
1325 HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
1326 HYDROData_SequenceOfObjects::Iterator anIter( aZones );
1327 for ( ; anIter.More(); anIter.Next() )
1329 Handle(HYDROData_Zone) aRegZone =
1330 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
1331 if ( aRegZone.IsNull() )
1334 HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegZone );
1339 void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList,
1340 const QString& thePyScriptPath,
1341 MapOfTreatedObjects& theTreatedObjects,
1342 const HYDROData_SequenceOfObjects& theRegions ) const
1344 HYDROData_SequenceOfObjects::Iterator anIter;
1345 anIter.Init(theRegions);
1346 for (int ireg = 1; anIter.More(); anIter.Next(), ireg++)
1348 Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast(anIter.Value());
1349 if (aRegion.IsNull())
1351 QString defRegName = this->GetName();
1352 QString regSuffix = QString("_Reg_%1").arg(ireg);
1353 defRegName += regSuffix;
1354 theTreatedObjects.insert(aRegion->GetName(), aRegion);
1355 QStringList aRegDump = aRegion->DumpToPython(thePyScriptPath, theTreatedObjects, defRegName);
1356 theResList << aRegDump;
1358 for (anIter.Init(theRegions); anIter.More(); anIter.Next())
1360 Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast(anIter.Value());
1361 if (aRegion.IsNull())
1363 QStringList aRegDump;
1364 aRegion->SetNameInDumpPython(aRegDump);
1365 theResList << aRegDump;
1369 bool HYDROData_CalculationCase::GetRule( int theIndex,
1370 Handle(HYDROData_Entity)& theObject1,
1371 HYDROData_PriorityType& thePriority,
1372 Handle(HYDROData_Entity)& theObject2,
1373 HYDROData_Zone::MergeType& theMergeType,
1374 HYDROData_CalculationCase::DataTag& theDataTag) const
1376 TDF_Label aRulesLab = myLab.FindChild( theDataTag );
1377 return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
1378 theObject1, thePriority, theObject2, theMergeType );