X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_CalculationCase.cxx;h=c59b01e33b10330daba54564ca5771021774b3e9;hb=13dcd7edcf93135429fce003da064297775ac11d;hp=8027835c4d46a1834b05e44e83a6b7366a9c8c41;hpb=a6ab61e5fa3141b7efac4b1b408f599666420c54;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 8027835c..c59b01e3 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -16,8 +16,11 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "HYDROData_CalculationCase.h" +#ifdef WIN32 + #pragma warning ( disable: 4251 ) +#endif +#include "HYDROData_CalculationCase.h" #include "HYDROData_ArtificialObject.h" #include "HYDROData_IAltitudeObject.h" #include "HYDROData_Document.h" @@ -67,8 +70,18 @@ #include #endif +#ifdef WIN32 + #pragma warning ( default: 4251 ) +#endif + #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) @@ -363,6 +376,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume const HYDROData_SplitToZonesTool::SplitDataList& theZones, const bool theLandCover ) { + DEBTRACE("HYDROData_CalculationCase::CreateRegionsAuto"); QMap aRegionsMap; //object name to region QMap aRegionNameToObjNameMap; QString aZonesPref = theLandCover ? CALCULATION_LANDCOVER_ZONES_PREF : CALCULATION_ZONES_PREF; @@ -406,6 +420,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume if ( !theLandCover ) { Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity ); if ( !aMergeObject.IsNull() ) { + DEBTRACE("aMergeEntity " << aMergeEntity->GetName().toStdString()); aMergeEntity = aMergeObject->GetAltitudeObject(); } } @@ -785,10 +800,20 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, false ); if ( !aZone.IsNull() ) { + //DEBTRACE("GetAltitudeForPoint Region " << theRegion->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; } @@ -796,17 +821,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; } @@ -819,15 +851,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() ) @@ -844,11 +881,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; @@ -884,6 +925,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 ) @@ -914,6 +956,38 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( return aResSeq; } +double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const +{ + double aCoeff = 0; + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( !aDocument.IsNull() ) + aCoeff = aDocument->GetDefaultStricklerCoefficient(); + + Handle(HYDROData_LandCover) aLandCover; + Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, Standard_True ); + if ( !aZone.IsNull() ) + { + HYDROData_SequenceOfObjects anObjList = aZone->GetObjects(); + if ( anObjList.Length() == 1 ) + aLandCover = Handle(HYDROData_LandCover)::DownCast( anObjList.First() ); + else + aLandCover = Handle(HYDROData_LandCover)::DownCast( aZone->GetMergeObject() ); + } + + if ( !aLandCover.IsNull() ) + { + QString aType = aLandCover->GetStricklerType(); + Handle(HYDROData_StricklerTable) aTable = GetStricklerTable(); + if ( !aTable.IsNull() ) + { + if ( aTable->GetTypes().contains( aType ) ) + aCoeff = aTable->Get( aType, aCoeff ); + } + } + + return aCoeff; +} + Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint, const bool theLandCover ) const { @@ -1027,14 +1101,15 @@ QString HYDROData_CalculationCase::Export( int theStudyId ) const GEOM::GEOM_Gen_var aGEOMEngine = HYDROData_GeomTool::GetGeomGen(); SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId ); - QString aGeomObjEntry; - bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry ); + QString aGeomObjEntry, anErrorMsg; + bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg ); return isOK ? aGeomObjEntry : QString(); } bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, - QString& theGeomObjEntry ) const + QString& theGeomObjEntry, + QString& theErrorMsg ) const { HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs; @@ -1059,6 +1134,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, } // Get faces + bool isAllNotSubmersible = true; TopTools_ListOfShape aFaces; HYDROData_SequenceOfObjects aCaseRegions = GetRegions( false ); HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions ); @@ -1068,12 +1144,25 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, Handle(HYDROData_Region)::DownCast( aRegionIter.Value() ); if( aRegion.IsNull() || !aRegion->IsSubmersible() ) continue; + + if ( isAllNotSubmersible ) + isAllNotSubmersible = false; TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs ); aFaces.Append( aRegionShape ); } - return Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry ); + bool aRes = false; + + if ( aCaseRegions.IsEmpty() ) { + theErrorMsg = QString("the list of regions is empty."); + } else if ( isAllNotSubmersible ) { + theErrorMsg = QString("there are no submersible regions."); + } else { + aRes = Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );; + } + + return aRes; } bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,