X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_CalculationCase.cxx;h=633e063a11bd09049454f202a3ff9c69738b5e2f;hb=f9d37ee66fa46871478d806faa54de237225d3c6;hp=c2430aff628070636b3b5e24677f046da7ed3381;hpb=18bf2fdae8933e8a31ca58f36b6dceb7a4a8cf42;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index c2430aff..633e063a 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -17,7 +17,6 @@ // #include "HYDROData_CalculationCase.h" - #include "HYDROData_ArtificialObject.h" #include "HYDROData_IAltitudeObject.h" #include "HYDROData_Document.h" @@ -26,13 +25,23 @@ #include "HYDROData_NaturalObject.h" #include "HYDROData_PolylineXY.h" #include "HYDROData_StricklerTable.h" -#include "HYDROData_LandCover.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" +#ifdef WIN32 + #pragma warning ( disable: 4251 ) +#endif + +#ifndef LIGHT_MODE #include +#endif + +#ifdef WIN32 + #pragma warning ( default: 4251 ) +#endif #include @@ -60,7 +69,6 @@ #endif #define CALCULATION_REGIONS_PREF GetName() + "_Reg" #define CALCULATION_ZONES_PREF GetName() + "_Zone" -#define CALCULATION_LANDCOVER_ZONES_PREF GetName() + "_LandCoverZone" #define CALCULATION_GROUPS_PREF GetName() + "_" //#define DEB_CLASS2D 1 #ifdef DEB_CLASS2D @@ -69,8 +77,10 @@ #define EXPORT_NAME "HYDRO_" + GetName() +#ifndef LIGHT_MODE #include #include +#endif #define _DEVDEBUG_ #include "HYDRO_trace.hxx" @@ -79,7 +89,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity) HYDROData_CalculationCase::HYDROData_CalculationCase() -: HYDROData_Entity() +: HYDROData_Entity( Geom_2d_and_groups ) { } @@ -93,18 +103,16 @@ void HYDROData_CalculationCase::SetName( const QString& theName ) if ( anOldCaseName != theName ) { // Update names of regions and its zones - UpdateRegionsNames( GetRegions( false ), anOldCaseName, theName ); - // Update names of land cover regions and its zones - UpdateRegionsNames( GetRegions( true ), anOldCaseName, theName ); + 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; @@ -115,7 +123,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" ); @@ -126,17 +135,13 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre QString aModeStr = aMode==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC"; aResList << QString( "%0.SetAssignmentMode( %1 )" ).arg( aCalculName ).arg( aModeStr ); - AssignmentMode aModeLC = GetAssignmentLandCoverMode(); - QString aModeLCStr = aModeLC==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC"; - aResList << QString( "%0.SetAssignmentLandCoverMode( %1 )" ).arg( aCalculName ).arg( aModeLCStr ); - HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects ); for ( ; anIter.More(); anIter.Next() ) { Handle(HYDROData_Object) aRefGeomObj = Handle(HYDROData_Object)::DownCast( anIter.Value() ); - setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); } aResList << QString( "" ); @@ -157,36 +162,33 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre continue; int aGroupId = aFatherGeom->GetGroupId( aGeomGroup ); - aResList << QString( "%1 = %2.GetGroup( %3 );" ) + aResList << QString( "%1 = %2.GetGroup( %3 )" ) .arg( aGroupName ).arg( aFatherGeom->GetObjPyName() ).arg( aGroupId ); - aResList << QString( "%1.AddGeometryGroup( %2 );" ).arg( aCalculName ).arg( aGroupName ); + aResList << QString( "%1.AddGeometryGroup( %2 )" ).arg( aCalculName ).arg( aGroupName ); } Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline(); - setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" ); + + Handle(HYDROData_StricklerTable) aStricklerTable = GetStricklerTable(); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aStricklerTable, "SetStricklerTable" ); + + Handle(HYDROData_LandCoverMap) aLandCoverMap = GetLandCoverMap(); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aLandCoverMap, "SetLandCoverMap" ); if( aMode==AUTOMATIC ) DumpRulesToPython( aCalculName, aResList ); - if( aModeLC==AUTOMATIC ) - DumpLandCoverRulesToPython( aCalculName, aResList ); aResList << QString( "" ); aResList << "# Start the algorithm of the partition and assignment"; - aResList << QString( "%1.Update();" ).arg( aCalculName ); + aResList << QString( "%1.Update()" ).arg( aCalculName ); if( aMode==MANUAL ) { // Now we restore the // - regions and zones order - DumpRegionsToPython( aResList, theTreatedObjects, GetRegions( false ) ); - } - - if( aModeLC==MANUAL ) - { - // Now we restore the - // - land cover regions and zones order - DumpRegionsToPython( aResList, theTreatedObjects, GetRegions( true ) ); + DumpRegionsToPython( aResList, thePyScriptPath, theTreatedObjects, GetRegions() ); } // Export calculation case @@ -202,11 +204,12 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre aResList << "import GEOM"; aResList << QString( "print \"Entry:\", %1" ).arg( anEntryVar ); QString aGeomShapeName = aCalculName + "_geom"; - aResList << QString( "%1 = salome.IDToObject( str( %2 ) )" ).arg( aGeomShapeName ).arg( anEntryVar ); - aResList << QString( "print \"Geom shape:\", %1" ).arg( aGeomShapeName ); - aResList << QString( "print \"Geom shape name:\", %1.GetName()" ).arg( aGeomShapeName ); + aResList << QString( "HYDRO_%1 = salome.IDToObject( str( %2 ) )" ).arg( GetName() ).arg( anEntryVar ); + aResList << QString( "print \"Geom shape:\", HYDRO_%1" ).arg( GetName() ); + aResList << QString( "print \"Geom shape name:\", HYDRO_%1.GetName()" ).arg( GetName() ); + - DumpSampleMeshing( aResList, aStudyName, aGeomShapeName, aCalculName+"_mesh" ); + //DumpSampleMeshing( aResList, aStudyName, aGeomShapeName, aCalculName+"_mesh" ); aResList << QString( "" ); return aResList; @@ -258,14 +261,13 @@ HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() if ( !aBoundaryPolyline.IsNull() ) aResSeq.Append( aBoundaryPolyline ); + HYDROData_SequenceOfObjects aSeqOfGeomObjs = GetGeometryObjects(); + aResSeq.Append( aSeqOfGeomObjs ); + // Regions - HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions( false ); + HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions(); aResSeq.Append( aSeqOfRegions ); - // Land cover regions - HYDROData_SequenceOfObjects aSeqOfLandCoverRegions = GetRegions( true ); - aResSeq.Append( aSeqOfLandCoverRegions ); - return aResSeq; } @@ -275,9 +277,8 @@ void HYDROData_CalculationCase::Update() SetWarning(); // At first we remove previously created objects - RemoveRegions( false ); - RemoveRegions( true ); - RemoveSplittedGroups(); + RemoveRegions(); + RemoveSplitGroups(); Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); if ( aDocument.IsNull() ) @@ -287,12 +288,15 @@ void HYDROData_CalculationCase::Update() HYDROData_SplitToZonesTool::SplitDataList aZonesList, anEdgesList; Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline(); + + HYDROData_SequenceOfObjects InterPolys = GetInterPolyObjects(); + HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); if ( !aGeomObjects.IsEmpty() ) { HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups(); HYDROData_SplitToZonesTool::SplitDataList aSplitObjects = - HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline ); + HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline, InterPolys ); if ( !aSplitObjects.isEmpty() ) { HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitObjects ); while( anIter.hasNext() ) { @@ -305,40 +309,13 @@ void HYDROData_CalculationCase::Update() } } - // Split to land cover zones - HYDROData_SplitToZonesTool::SplitDataList aLandCoverZonesList; - - HYDROData_SequenceOfObjects aLandCovers = GetLandCovers(); - if ( !aLandCovers.IsEmpty() ) { - HYDROData_SplitToZonesTool::SplitDataList aSplitLandCoverObjects = - HYDROData_SplitToZonesTool::Split( aLandCovers ); - if ( !aSplitLandCoverObjects.isEmpty() ) { - HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitLandCoverObjects ); - while( anIter.hasNext() ) { - const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next(); - if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone ) - aLandCoverZonesList.append( aSplitData ); - } - } - } - switch( GetAssignmentMode() ) { case MANUAL: - CreateRegionsDef( aDocument, aZonesList, false ); + CreateRegionsDef( aDocument, aZonesList ); break; case AUTOMATIC: - CreateRegionsAuto( aDocument, aZonesList, false ); - break; - } - - switch( GetAssignmentLandCoverMode() ) - { - case MANUAL: - CreateRegionsDef( aDocument, aLandCoverZonesList, true ); - break; - case AUTOMATIC: - CreateRegionsAuto( aDocument, aLandCoverZonesList, true ); + CreateRegionsAuto( aDocument, aZonesList ); break; } @@ -346,19 +323,18 @@ void HYDROData_CalculationCase::Update() } void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc, - const HYDROData_SplitToZonesTool::SplitDataList& theZones, - const bool theLandCover ) + const HYDROData_SplitToZonesTool::SplitDataList& theZones ) { // Create result regions for case, by default one zone for one region QString aRegsPref = CALCULATION_REGIONS_PREF; - QString aZonesPref = theLandCover ? CALCULATION_LANDCOVER_ZONES_PREF : CALCULATION_ZONES_PREF; + QString aZonesPref = CALCULATION_ZONES_PREF; HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theZones ); while( anIter.hasNext() ) { const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next(); // Create new region - Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref, theLandCover ); + Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref ); // Add the zone for region Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames ); @@ -366,16 +342,16 @@ void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Documen } void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc, - const HYDROData_SplitToZonesTool::SplitDataList& theZones, - const bool theLandCover ) + const HYDROData_SplitToZonesTool::SplitDataList& theZones ) { + DEBTRACE("HYDROData_CalculationCase::CreateRegionsAuto"); QMap aRegionsMap; //object name to region QMap aRegionNameToObjNameMap; - QString aZonesPref = theLandCover ? CALCULATION_LANDCOVER_ZONES_PREF : CALCULATION_ZONES_PREF; - HYDROData_PriorityQueue aPr( this, theLandCover ? DataTag_CustomLandCoverRules : DataTag_CustomRules ); + QString aZonesPref = CALCULATION_ZONES_PREF; + HYDROData_PriorityQueue aPr( this, DataTag_CustomRules ); // 1. First we create a default region for each object included into the calculation case - HYDROData_SequenceOfObjects anObjects = theLandCover ? GetLandCovers() : GetGeometryObjects(); + HYDROData_SequenceOfObjects anObjects = GetGeometryObjects(); for( int i = anObjects.Lower(), n = anObjects.Upper(); i<=n; i++ ) { Handle(HYDROData_Entity) anObj = anObjects.Value( i ); @@ -383,7 +359,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume continue; QString anObjName = anObj->GetName(); QString aRegName = anObjName + "_reg"; - Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, theLandCover, false ); + Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false ); aRegionsMap.insert( anObjName, aRegion ); aRegionNameToObjNameMap.insert( aRegName, anObjName ); } @@ -409,11 +385,10 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume } Handle(HYDROData_Entity) aMergeEntity = aRegObj; - if ( !theLandCover ) { - Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity ); - if ( !aMergeObject.IsNull() ) { - aMergeEntity = aMergeObject->GetAltitudeObject(); - } + Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity ); + if ( !aMergeObject.IsNull() ) { + DEBTRACE("aMergeEntity " << aMergeEntity->GetName().toStdString()); + aMergeEntity = aMergeObject->GetAltitudeObject(); } switch( aMergeType ) @@ -454,7 +429,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() ) @@ -471,20 +446,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 ); + aResAltitude = GetAltitudeForPoint( thePoint, aZone, theMethod ); else { DEBTRACE("GetAltitudeForPoint Region " << aRefRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString() << " ---------------------------"); - aResAltitude = GetAltitudeForPoint( thePoint, aZone ); + aResAltitude = GetAltitudeForPoint( thePoint, aZone, theMethod ); } } else @@ -810,20 +758,27 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& } double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint, - const Handle(HYDROData_Zone)& theZone ) const + const Handle(HYDROData_Zone)& theZone, + int theMethod) 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; } @@ -836,15 +791,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() ) @@ -861,11 +821,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 - aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint ); + { + //DEBTRACE("aZoneInterpolator == NULL"); + aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint, theMethod ); + } if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) ) continue; @@ -899,16 +863,17 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( const NCollection_Sequence& thePoints, - const Handle(HYDROData_Region)& theRegion ) const + const Handle(HYDROData_Region)& theRegion, + int theMethod) const { - //DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString()); + DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString()); NCollection_Sequence aResSeq; for ( int i = 1, n = thePoints.Length(); i <= n; ++i ) { const gp_XY& thePnt = thePoints.Value( i ); - double anAltitude = GetAltitudeForPoint( thePnt, theRegion ); + double anAltitude = GetAltitudeForPoint( thePnt, theRegion, theMethod ); aResSeq.Append( anAltitude ); } @@ -917,7 +882,8 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( const NCollection_Sequence& thePoints, - const Handle(HYDROData_Zone)& theZone ) const + const Handle(HYDROData_Zone)& theZone, + int theMethod) const { NCollection_Sequence aResSeq; @@ -925,31 +891,56 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( { const gp_XY& thePnt = thePoints.Value( i ); - double anAltitude = GetAltitudeForPoint( thePnt, theZone ); + double anAltitude = GetAltitudeForPoint( thePnt, theZone, theMethod ); aResSeq.Append( anAltitude ); } return aResSeq; } -Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint, - const bool theLandCover ) const +double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const +{ + 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; +} + +std::vector HYDROData_CalculationCase::GetStricklerCoefficientForPoints(const std::vector& thePoints, + double DefValue, bool UseMax ) const +{ + Handle( HYDROData_LandCoverMap ) aLCM = GetLandCoverMap(); + Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable(); + std::vector theCoeffs; + if( aLCM.IsNull() || aTable.IsNull() ) + return theCoeffs; + + aLCM->ClassifyPoints(thePoints, aTable, theCoeffs, DefValue, UseMax ); + + return theCoeffs; +} + +Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const { Handle(HYDROData_Region) aResRegion; - Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, theLandCover ); + Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint ); if ( !aZone.IsNull() ) aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() ); return aResRegion; } -Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint, - const bool theLandCover ) const +Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const { Handle(HYDROData_Zone) aResZone; - HYDROData_SequenceOfObjects aRegions = GetRegions( theLandCover ); + HYDROData_SequenceOfObjects aRegions = GetRegions(); HYDROData_SequenceOfObjects::Iterator anIter( aRegions ); for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() ) @@ -1010,30 +1001,29 @@ HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPoi Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(HYDROData_Document)& theDoc, const QString& thePrefixOrName, - const bool theLandCover, bool isPrefix ) { - TDF_Label aNewLab = myLab.FindChild( theLandCover ? DataTag_ChildLandCoverRegion : DataTag_ChildRegion ).NewChild(); + TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild(); int aTag = aNewLab.Tag(); Handle(HYDROData_Region) aNewRegion = Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) ); - AddRegion( aNewRegion, theLandCover ); + AddRegion( aNewRegion ); QString aRegionName = isPrefix ? HYDROData_Tool::GenerateObjectName( theDoc, thePrefixOrName ) : thePrefixOrName; - aNewRegion->SetName( aRegionName ); + aNewRegion->SetName( aRegionName, true ); 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 ); @@ -1042,14 +1032,19 @@ Handle(HYDROData_SplittedShapesGroup) HYDROData_CalculationCase::addNewSplittedG QString HYDROData_CalculationCase::Export( int theStudyId ) const { +#ifdef LIGHT_MODE + return ""; +#else GEOM::GEOM_Gen_var aGEOMEngine = HYDROData_GeomTool::GetGeomGen(); SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId ); QString aGeomObjEntry, anErrorMsg; bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg ); return isOK ? aGeomObjEntry : QString(); +#endif } +#ifndef LIGHT_MODE bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, QString& theGeomObjEntry, @@ -1058,9 +1053,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 @@ -1079,9 +1074,9 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, // Get faces bool isAllNotSubmersible = true; - TopTools_ListOfShape aFaces; - HYDROData_SequenceOfObjects aCaseRegions = GetRegions( false ); + HYDROData_SequenceOfObjects aCaseRegions = GetRegions(); HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions ); + NCollection_IndexedDataMap aFacesToNames; for ( ; aRegionIter.More(); aRegionIter.Next() ) { Handle(HYDROData_Region) aRegion = @@ -1093,7 +1088,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, isAllNotSubmersible = false; TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs ); - aFaces.Append( aRegionShape ); + aFacesToNames.Add( aRegionShape, aRegion->GetName() ); } bool aRes = false; @@ -1103,15 +1098,20 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, } else if ( isAllNotSubmersible ) { theErrorMsg = QString("there are no submersible regions."); } else { - aRes = Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );; + aRes = Export( theGeomEngine, theStudy, aFacesToNames, aSeqOfGroupsDefs, theGeomObjEntry );; } + if( aRes && !GetLandCoverMap().IsNull() && !GetStricklerTable().IsNull() ) + { + QString aTelemacFileName = GetName() + ".telemac"; + aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable() ); + } return aRes; } bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, - const TopTools_ListOfShape& theFaces, + const NCollection_IndexedDataMap& aFacesToName, const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs, QString& theGeomObjEntry ) const { @@ -1122,10 +1122,9 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var TCollection_AsciiString aNam("Sh_"); int i=1; #endif - TopTools_ListIteratorOfListOfShape aFaceIter( theFaces ); - for ( ; aFaceIter.More(); aFaceIter.Next() ) + for ( int i = 1; i <= aFacesToName.Extent(); i++ ) { - TopoDS_Shape aShape = aFaceIter.Value(); + const TopoDS_Shape& aShape = aFacesToName.FindKey(i); if ( aShape.IsNull() ) continue; @@ -1157,6 +1156,19 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var aSewing.Perform(); TopoDS_Shape aSewedShape = aSewing.SewedShape(); + NCollection_IndexedDataMap aFacesToNameModif; + + for ( int i = 1; i <= aFacesToName.Extent(); i++ ) + { + const TopoDS_Shape& CurShape = aFacesToName.FindKey(i); + const QString& Qstr = aFacesToName.FindFromIndex(i); + if (aSewing.IsModified(CurShape)) + aFacesToNameModif.Add(aSewing.Modified(CurShape), Qstr); + else + aFacesToNameModif.Add(CurShape, Qstr); + } + + // If the sewed shape is empty - return false if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() ) return false; @@ -1167,7 +1179,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var // Publish the sewed shape QString aName = EXPORT_NAME; GEOM::GEOM_Object_ptr aMainShape = - HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry ); + HYDROData_GeomTool::ExplodeShapeInGEOMandPublish( theGeomEngine, theStudy, aSewedShape, aFacesToNameModif, aName, theGeomObjEntry ); if ( aMainShape->_is_nil() ) return false; @@ -1263,6 +1275,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var return true; } +#endif void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag, const bool theIsSetToUpdate ) @@ -1272,7 +1285,7 @@ void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag t // Indicate model of the need to update splitting if ( theIsSetToUpdate ) { - SetToUpdate( true ); + Changed( Geom_2d ); } } @@ -1286,7 +1299,7 @@ void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theO HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } QString HYDROData_CalculationCase::DumpRules() const @@ -1295,19 +1308,13 @@ QString HYDROData_CalculationCase::DumpRules() const return HYDROData_PriorityQueue::DumpRules( aRulesLab ); } -QString HYDROData_CalculationCase::DumpLandCoverRules() const -{ - TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules ); - return HYDROData_PriorityQueue::DumpRules( aRulesLab ); -} - void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode ) { TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode ); TDataStd_Integer::Set( aModeLab, ( int ) theMode ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const @@ -1327,13 +1334,6 @@ void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseNam HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript ); } -void HYDROData_CalculationCase::DumpLandCoverRulesToPython( const QString& theCalcCaseName, - QStringList& theScript ) const -{ - TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules ); - HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript ); -} - HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const { return myLastWarning; @@ -1374,22 +1374,33 @@ void HYDROData_CalculationCase::UpdateRegionsNames( const HYDROData_SequenceOfOb } void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList, + const QString& thePyScriptPath, MapOfTreatedObjects& theTreatedObjects, const HYDROData_SequenceOfObjects& theRegions ) const { HYDROData_SequenceOfObjects::Iterator anIter; - anIter.Init( theRegions ); - for ( ; anIter.More(); anIter.Next() ) - { - Handle(HYDROData_Region) aRegion = - Handle(HYDROData_Region)::DownCast( anIter.Value() ); - if ( aRegion.IsNull() ) - continue; - - theTreatedObjects.insert( aRegion->GetName(), aRegion ); - QStringList aRegDump = aRegion->DumpToPython( theTreatedObjects ); - theResList << aRegDump; - } + anIter.Init(theRegions); + for (int ireg = 1; anIter.More(); anIter.Next(), ireg++) + { + Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast(anIter.Value()); + if (aRegion.IsNull()) + continue; + QString defRegName = this->GetName(); + QString regSuffix = QString("_Reg_%1").arg(ireg); + defRegName += regSuffix; + theTreatedObjects.insert(aRegion->GetName(), aRegion); + QStringList aRegDump = aRegion->DumpToPython(thePyScriptPath, theTreatedObjects, defRegName); + theResList << aRegDump; + } + for (anIter.Init(theRegions); anIter.More(); anIter.Next()) + { + Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast(anIter.Value()); + if (aRegion.IsNull()) + continue; + QStringList aRegDump; + aRegion->SetNameInDumpPython(aRegDump); + theResList << aRegDump; + } } bool HYDROData_CalculationCase::GetRule( int theIndex, @@ -1404,21 +1415,31 @@ bool HYDROData_CalculationCase::GetRule( int theIndex, theObject1, thePriority, theObject2, theMergeType ); } -void HYDROData_CalculationCase::SetAssignmentLandCoverMode( AssignmentMode theMode ) +bool HYDROData_CalculationCase::AddInterPoly( const Handle(HYDROData_PolylineXY)& theInterPolyline ) { - TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentLandCoverMode ); - TDataStd_Integer::Set( aModeLab, ( int ) theMode ); + HYDROData_CalculationCase::DataTag aDataTag = DataTag_InterPoly; - // Indicate model of the need to update land covers partition - SetToUpdate( true ); + if ( HasReference( theInterPolyline, aDataTag ) ) + return false; + + AddReferenceObject( theInterPolyline, aDataTag ); + + return true; } -HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentLandCoverMode() const +HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetInterPolyObjects() const { - Handle(TDataStd_Integer) aModeAttr; - bool isOK = myLab.FindChild( DataTag_AssignmentLandCoverMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr ); - if( isOK ) - return ( AssignmentMode ) aModeAttr->Get(); - else - return MANUAL; + return GetReferenceObjects( DataTag_InterPoly ); +} + +void HYDROData_CalculationCase::RemoveInterPolyObject( const Handle(HYDROData_PolylineXY)& theInterPolyline ) +{ + if ( theInterPolyline.IsNull() ) + return; + + RemoveReferenceObject( theInterPolyline->Label(), DataTag_InterPoly ); + } + + +