X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_CalculationCase.cxx;h=58d15770f88c2b5172aaafee04b51771aede958e;hb=cde2ec476486fcd7c9b7b38ce814c648d73e7fd3;hp=3de94ed066ea925ba5ef8e09aadd7f5ede07b7a5;hpb=914d3c8044ea08613f24ce41a94ecf067e0e750f;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 3de94ed0..58d15770 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -25,7 +25,8 @@ #include "HYDROData_NaturalObject.h" #include "HYDROData_PolylineXY.h" #include "HYDROData_StricklerTable.h" -#include "HYDROData_SplittedShapesGroup.h" +#include "HYDROData_LandCoverMap.h" +#include "HYDROData_SplitShapesGroup.h" #include "HYDROData_Region.h" #include "HYDROData_Tool.h" #include "HYDROData_GeomTool.h" @@ -76,6 +77,12 @@ #define EXPORT_NAME "HYDRO_" + GetName() +#include +#include + +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity) @@ -96,14 +103,14 @@ void HYDROData_CalculationCase::SetName( const QString& theName ) // Update names of regions and its zones UpdateRegionsNames( GetRegions(), anOldCaseName, theName ); - HYDROData_SequenceOfObjects aGroups = GetSplittedGroups(); + HYDROData_SequenceOfObjects aGroups = GetSplitGroups(); HYDROData_SequenceOfObjects::Iterator anIter; anIter.Init( aGroups ); for ( ; anIter.More(); anIter.Next() ) { - Handle(HYDROData_SplittedShapesGroup) aGroup = - Handle(HYDROData_SplittedShapesGroup)::DownCast( anIter.Value() ); + Handle(HYDROData_SplitShapesGroup) aGroup = + Handle(HYDROData_SplitShapesGroup)::DownCast( anIter.Value() ); if ( aGroup.IsNull() ) continue; @@ -114,7 +121,8 @@ void HYDROData_CalculationCase::SetName( const QString& theName ) HYDROData_Entity::SetName( theName ); } -QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +QStringList HYDROData_CalculationCase::DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); aResList.prepend( "# Calculation case" ); @@ -131,7 +139,7 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre { Handle(HYDROData_Object) aRefGeomObj = Handle(HYDROData_Object)::DownCast( anIter.Value() ); - setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); } aResList << QString( "" ); @@ -159,7 +167,7 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre } Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline(); - setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" ); if( aMode==AUTOMATIC ) DumpRulesToPython( aCalculName, aResList ); @@ -172,7 +180,7 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre { // Now we restore the // - regions and zones order - DumpRegionsToPython( aResList, theTreatedObjects, GetRegions() ); + DumpRegionsToPython( aResList, thePyScriptPath, theTreatedObjects, GetRegions() ); } // Export calculation case @@ -261,7 +269,7 @@ void HYDROData_CalculationCase::Update() // At first we remove previously created objects RemoveRegions(); - RemoveSplittedGroups(); + RemoveSplitGroups(); Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); if ( aDocument.IsNull() ) @@ -324,6 +332,7 @@ void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Documen void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc, const HYDROData_SplitToZonesTool::SplitDataList& theZones ) { + DEBTRACE("HYDROData_CalculationCase::CreateRegionsAuto"); QMap aRegionsMap; //object name to region QMap aRegionNameToObjNameMap; QString aZonesPref = CALCULATION_ZONES_PREF; @@ -366,6 +375,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume Handle(HYDROData_Entity) aMergeEntity = aRegObj; Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity ); if ( !aMergeObject.IsNull() ) { + DEBTRACE("aMergeEntity " << aMergeEntity->GetName().toStdString()); aMergeEntity = aMergeObject->GetAltitudeObject(); } @@ -407,7 +417,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc, const HYDROData_SplitToZonesTool::SplitDataList& theEdges ) { - QMap aSplittedEdgesGroupsMap; + QMap aSplitEdgesGroupsMap; HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges ); while( anIter.hasNext() ) @@ -424,20 +434,20 @@ void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Docu QString aStr = aSplitData.ObjectNames.join(" "); cout << " CCase: Names = "<GetName().toStdString() << " Zone " << aZone->GetName().toStdString()); Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() ); if ( IsEqual( aRefRegion, theRegion ) ) aResAltitude = GetAltitudeForPoint( thePoint, aZone ); + else + { + DEBTRACE("GetAltitudeForPoint Region " << aRefRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString() << " ---------------------------"); + aResAltitude = GetAltitudeForPoint( thePoint, aZone ); + } } + else + { + DEBTRACE(" --- GetAltitudeForPoint No Zone ---"); + } return aResAltitude; } @@ -715,17 +747,24 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint, const Handle(HYDROData_Zone)& theZone ) const { + //DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString()); double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude(); if ( theZone.IsNull() ) + { + DEBTRACE("Zone nulle"); return aResAltitude; + } HYDROData_Zone::MergeType aZoneMergeType = theZone->GetMergeType(); + //DEBTRACE("aZoneMergeType " << aZoneMergeType); if ( !theZone->IsMergingNeed() ) { aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN; + //DEBTRACE("---"); } else if ( aZoneMergeType == HYDROData_Zone::Merge_UNKNOWN ) { + DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString() << " Merge_UNKNOWN"); return aResAltitude; } @@ -738,15 +777,20 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& { if ( aZoneInterpolator != NULL ) { + DEBTRACE("aZoneInterpolator != NULL"); aZoneInterpolator->SetAltitudeObject( aMergeAltitude ); aResAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint ); } else + { + DEBTRACE("aZoneInterpolator == NULL"); aResAltitude = aMergeAltitude->GetAltitudeForPoint( thePoint ); + } } } else { + //DEBTRACE("aZoneMergeType != HYDROData_Zone::Merge_Object"); HYDROData_SequenceOfObjects aZoneObjects = theZone->GetObjects(); HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects ); for ( ; anIter.More(); anIter.Next() ) @@ -763,11 +807,15 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& double aPointAltitude = 0.0; if ( aZoneInterpolator != NULL ) { + DEBTRACE("aZoneInterpolator != NULL"); aZoneInterpolator->SetAltitudeObject( anObjAltitude ); aPointAltitude = aZoneInterpolator->GetAltitudeForPoint( thePoint ); } else + { + //DEBTRACE("aZoneInterpolator == NULL"); aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint ); + } if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ) continue; @@ -803,6 +851,7 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( const NCollection_Sequence& thePoints, const Handle(HYDROData_Region)& theRegion ) const { + //DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString()); NCollection_Sequence aResSeq; for ( int i = 1, n = thePoints.Length(); i <= n; ++i ) @@ -835,8 +884,15 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const { - //TODO: #652 - return 0.0; + Handle( HYDROData_LandCoverMap ) aMap = GetLandCoverMap(); + Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable(); + if( aMap.IsNull() ) + return 0.0; + + QString aType; + aMap->FindByPoint( thePoint, aType ); + double aCoeff = aTable->Get( aType, 0.0 ); + return aCoeff; } Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const @@ -930,14 +986,14 @@ Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(H return aNewRegion; } -Handle(HYDROData_SplittedShapesGroup) HYDROData_CalculationCase::addNewSplittedGroup( const QString& theName ) +Handle(HYDROData_SplitShapesGroup) HYDROData_CalculationCase::addNewSplitGroup( const QString& theName ) { - TDF_Label aNewLab = myLab.FindChild( DataTag_SplittedGroups ).NewChild(); + TDF_Label aNewLab = myLab.FindChild( DataTag_SplitGroups ).NewChild(); - Handle(HYDROData_SplittedShapesGroup) aNewGroup = - Handle(HYDROData_SplittedShapesGroup)::DownCast( - HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLITTED_GROUP ) ); - AddReferenceObject( aNewGroup, DataTag_SplittedGroups ); + Handle(HYDROData_SplitShapesGroup) aNewGroup = + Handle(HYDROData_SplitShapesGroup)::DownCast( + HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLIT_GROUP ) ); + AddReferenceObject( aNewGroup, DataTag_SplitGroups ); aNewGroup->SetName( theName ); @@ -967,9 +1023,9 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs; // Get groups definitions - HYDROData_SequenceOfObjects aSplittedGroups = GetSplittedGroups(); + HYDROData_SequenceOfObjects aSplitGroups = GetSplitGroups(); - HYDROData_SequenceOfObjects::Iterator anIter( aSplittedGroups ); + HYDROData_SequenceOfObjects::Iterator anIter( aSplitGroups ); for ( ; anIter.More(); anIter.Next() ) { // Get shapes group @@ -1015,6 +1071,11 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, aRes = Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );; } + if( aRes && !GetLandCoverMap().IsNull() && !GetStricklerTable().IsNull() ) + { + QString aTelemacFileName = GetName() + ".telemac"; + aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable() ); + } return aRes; } @@ -1271,6 +1332,7 @@ void HYDROData_CalculationCase::UpdateRegionsNames( const HYDROData_SequenceOfOb } void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList, + const QString& thePyScriptPath, MapOfTreatedObjects& theTreatedObjects, const HYDROData_SequenceOfObjects& theRegions ) const { @@ -1284,7 +1346,7 @@ void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList, continue; theTreatedObjects.insert( aRegion->GetName(), aRegion ); - QStringList aRegDump = aRegion->DumpToPython( theTreatedObjects ); + QStringList aRegDump = aRegion->DumpToPython( thePyScriptPath, theTreatedObjects ); theResList << aRegDump; } } @@ -1300,5 +1362,3 @@ bool HYDROData_CalculationCase::GetRule( int theIndex, return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex, theObject1, thePriority, theObject2, theMergeType ); } - - Changed( Geom_No ); \ No newline at end of file