From c8e83d6c803519b483f3b1c03a7704710e0874fd Mon Sep 17 00:00:00 2001 From: mzn Date: Fri, 19 Jun 2015 12:53:16 +0300 Subject: [PATCH] refs #570: Land Cover: the partition algorithm (further implementation) --- src/HYDROData/HYDROData_CalculationCase.cxx | 28 ++++--- src/HYDROData/HYDROData_CalculationCase.h | 4 +- src/HYDROData/HYDROData_PriorityQueue.cxx | 28 +++---- src/HYDROData/HYDROData_PriorityQueue.h | 16 ++-- src/HYDROData/HYDROData_Region.cxx | 14 ++-- src/HYDROData/HYDROData_Zone.cxx | 88 +++++++++++++------- src/HYDROData/HYDROData_Zone.h | 49 +++++------ src/HYDROGUI/HYDROGUI_CalculationDlg.cxx | 2 +- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 6 +- src/HYDROGUI/HYDROGUI_CalculationOp.h | 4 +- src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx | 2 +- src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx | 6 +- src/HYDROGUI/HYDROGUI_Zone.cxx | 62 ++++++++------ src/HYDROGUI/HYDROGUI_Zone.h | 14 ++-- src/HYDROPy/HYDROData_CalculationCase.sip | 4 +- src/HYDROPy/HYDROData_Zone.sip | 85 +++++++++++++++---- 16 files changed, 252 insertions(+), 160 deletions(-) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index e5fda65c..4fd97082 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -367,9 +367,8 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume while( anIter.hasNext() ) { const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next(); - HYDROData_Zone::MergeAltitudesType aMergeType; - Handle(HYDROData_Object) aRegObj = - Handle(HYDROData_Object)::DownCast( aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType ) ); + HYDROData_Zone::MergeType aMergeType; + Handle(HYDROData_Entity) aRegObj = aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType ); if( aRegObj.IsNull() ) continue; Handle(HYDROData_Region) aRegion = aRegionsMap[aRegObj->GetName()]; @@ -382,6 +381,14 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume qDebug( "Error in algorithm: unresolved conflicts" ); } + Handle(HYDROData_Entity) aMergeEntity = aRegObj; + if ( !theLandCover ) { + Handle(HYDROData_Object) aMergeObject = Handle(HYDROData_Object)::DownCast( aMergeEntity ); + if ( !aMergeObject.IsNull() ) { + aMergeEntity = aMergeObject->GetAltitudeObject(); + } + } + switch( aMergeType ) { case HYDROData_Zone::Merge_ZMIN: @@ -390,8 +397,8 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume break; case HYDROData_Zone::Merge_Object: aRegionZone->SetMergeType( aMergeType ); - aRegionZone->RemoveMergeAltitude(); - aRegionZone->SetMergeAltitude( aRegObj->GetAltitudeObject() ); + aRegionZone->RemoveMergeObject(); + aRegionZone->SetMergeObject( aMergeEntity ); break; } } @@ -771,7 +778,7 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& if ( theZone.IsNull() ) return aResAltitude; - HYDROData_Zone::MergeAltitudesType aZoneMergeType = theZone->GetMergeType(); + HYDROData_Zone::MergeType aZoneMergeType = theZone->GetMergeType(); if ( !theZone->IsMergingNeed() ) { aZoneMergeType = HYDROData_Zone::Merge_UNKNOWN; @@ -784,7 +791,8 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& HYDROData_IInterpolator* aZoneInterpolator = theZone->GetInterpolator(); if ( aZoneMergeType == HYDROData_Zone::Merge_Object ) { - Handle(HYDROData_IAltitudeObject) aMergeAltitude = theZone->GetMergeAltitude(); + Handle(HYDROData_IAltitudeObject) aMergeAltitude = + Handle(HYDROData_IAltitudeObject)::DownCast( theZone->GetMergeObject() ); if ( !aMergeAltitude.IsNull() ) { if ( aZoneInterpolator != NULL ) @@ -798,7 +806,7 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& } else { - HYDROData_SequenceOfObjects aZoneObjects = theZone->GetGeometryObjects(); + HYDROData_SequenceOfObjects aZoneObjects = theZone->GetObjects(); HYDROData_SequenceOfObjects::Iterator anIter( aZoneObjects ); for ( ; anIter.More(); anIter.Next() ) { @@ -1262,7 +1270,7 @@ void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag t void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theObject1, HYDROData_PriorityType thePriority, const Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType theMergeType, + HYDROData_Zone::MergeType theMergeType, HYDROData_CalculationCase::DataTag theDataTag ) { TDF_Label aRulesLab = myLab.FindChild( theDataTag ); @@ -1366,7 +1374,7 @@ bool HYDROData_CalculationCase::GetRule( int theIndex, Handle(HYDROData_Entity)& theObject1, HYDROData_PriorityType& thePriority, Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType& theMergeType, + HYDROData_Zone::MergeType& theMergeType, HYDROData_CalculationCase::DataTag& theDataTag) const { TDF_Label aRulesLab = myLab.FindChild( theDataTag ); diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index fa0edeb1..79e78705 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -374,13 +374,13 @@ public: HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1, HYDROData_PriorityType thePriority, const Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType theMergeType, + HYDROData_Zone::MergeType theMergeType, HYDROData_CalculationCase::DataTag theDataTag ); HYDRODATA_EXPORT bool GetRule( int theIndex, Handle(HYDROData_Entity)& theObject1, HYDROData_PriorityType& thePriority, Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType& theMergeType, + HYDROData_Zone::MergeType& theMergeType, HYDROData_CalculationCase::DataTag& theDataTag ) const; HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode ); diff --git a/src/HYDROData/HYDROData_PriorityQueue.cxx b/src/HYDROData/HYDROData_PriorityQueue.cxx index 6dbb5dae..43d39df3 100644 --- a/src/HYDROData/HYDROData_PriorityQueue.cxx +++ b/src/HYDROData/HYDROData_PriorityQueue.cxx @@ -46,7 +46,7 @@ HYDROData_PriorityQueue::~HYDROData_PriorityQueue() } Handle(HYDROData_Entity) HYDROData_PriorityQueue::GetMostPriorityObject( const QStringList& theZoneObjects, - HYDROData_Zone::MergeAltitudesType& theMergeType ) const + HYDROData_Zone::MergeType& theMergeType ) const { QStringList aSortedZoneObjects; for( int i=myGeomObjects.Lower(), n=myGeomObjects.Upper(); i<=n; i++ ) @@ -61,7 +61,7 @@ Handle(HYDROData_Entity) HYDROData_PriorityQueue::GetMostPriorityObject( const Q QStringList::const_iterator anIt = aSortedZoneObjects.begin(), aLast = aSortedZoneObjects.end(); for( ; anIt!=aLast; anIt++ ) { - HYDROData_Zone::MergeAltitudesType aLocalMerge = HYDROData_Zone::Merge_UNKNOWN; + HYDROData_Zone::MergeType aLocalMerge = HYDROData_Zone::Merge_UNKNOWN; Handle(HYDROData_Entity) anObj = myNames[*anIt]; if( !anObj.IsNull() ) { @@ -86,7 +86,7 @@ Handle(HYDROData_Entity) HYDROData_PriorityQueue::GetMostPriorityObject( const Q bool HYDROData_PriorityQueue::IsMorePriority( const Handle(HYDROData_Entity)& theObj1, const Handle(HYDROData_Entity)& theObj2, - HYDROData_Zone::MergeAltitudesType& theMergeType ) const + HYDROData_Zone::MergeType& theMergeType ) const { // 1. First we check custom rules HYDROData_ListOfRules::const_iterator anIt = myRules.begin(), aLast = myRules.end(); @@ -134,11 +134,11 @@ enum HYDROData_PriorityQueueTag Merge_Tag, }; -void HYDROData_PriorityQueue::AddRule( TDF_Label& theRulesLabel, - const Handle(HYDROData_Entity)& theObject1, - HYDROData_PriorityType thePriority, - const Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType theMergeType ) +void HYDROData_PriorityQueue::AddRule( TDF_Label& theRulesLabel, + const Handle(HYDROData_Entity)& theObject1, + HYDROData_PriorityType thePriority, + const Handle(HYDROData_Entity)& theObject2, + HYDROData_Zone::MergeType theMergeType ) { // Get the last rule index Standard_Integer aRuleIndex = 0; @@ -190,7 +190,7 @@ HYDROData_ListOfRules HYDROData_PriorityQueue::GetRules( const TDF_Label& theRul aRule.Object1 = HYDROData_Iterator::Object( aRefs1->First() ); aRule.Priority = ( HYDROData_PriorityType ) aPriorityAttr->Get(); aRule.Object2 = HYDROData_Iterator::Object( aRefs2->First() ); - aRule.MergeType = ( HYDROData_Zone::MergeAltitudesType ) aMergeAttr->Get(); + aRule.MergeType = ( HYDROData_Zone::MergeType ) aMergeAttr->Get(); aRules.append( aRule ); } } @@ -273,10 +273,10 @@ void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab, bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab, int theIndex, - Handle(HYDROData_Entity)& theObject1, - HYDROData_PriorityType& thePriority, - Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType& theMergeType ) + Handle(HYDROData_Entity)& theObject1, + HYDROData_PriorityType& thePriority, + Handle(HYDROData_Entity)& theObject2, + HYDROData_Zone::MergeType& theMergeType ) { TDF_Label aRuleLabel = theRulesLab.FindChild( theIndex ); @@ -294,7 +294,7 @@ bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab, theObject1 = HYDROData_Iterator::Object( aRefs1->First() ); thePriority = ( HYDROData_PriorityType ) aPriorityAttr->Get(); theObject2 = HYDROData_Iterator::Object( aRefs2->First() ); - theMergeType = ( HYDROData_Zone::MergeAltitudesType ) aMergeAttr->Get(); + theMergeType = ( HYDROData_Zone::MergeType ) aMergeAttr->Get(); } return isOK; } diff --git a/src/HYDROData/HYDROData_PriorityQueue.h b/src/HYDROData/HYDROData_PriorityQueue.h index 80d1b652..b9f64582 100644 --- a/src/HYDROData/HYDROData_PriorityQueue.h +++ b/src/HYDROData/HYDROData_PriorityQueue.h @@ -33,10 +33,10 @@ enum HYDROData_PriorityType struct HYDROData_CustomRule { - Handle(HYDROData_Entity) Object1; - HYDROData_PriorityType Priority; - Handle(HYDROData_Entity) Object2; - HYDROData_Zone::MergeAltitudesType MergeType; + Handle(HYDROData_Entity) Object1; + HYDROData_PriorityType Priority; + Handle(HYDROData_Entity) Object2; + HYDROData_Zone::MergeType MergeType; }; typedef QList HYDROData_ListOfRules; @@ -49,18 +49,18 @@ public: ~HYDROData_PriorityQueue(); Handle_HYDROData_Entity GetMostPriorityObject( const QStringList& theZoneObjects, - HYDROData_Zone::MergeAltitudesType& theMergeType ) const; + HYDROData_Zone::MergeType& theMergeType ) const; bool IsMorePriority( const Handle(HYDROData_Entity)& theObj1, const Handle(HYDROData_Entity)& theObj2, - HYDROData_Zone::MergeAltitudesType& theMergeType ) const; + HYDROData_Zone::MergeType& theMergeType ) const; static void ClearRules( TDF_Label& theRulesLabel ); static void AddRule( TDF_Label& theRulesLabel, const Handle(HYDROData_Entity)& theObject1, HYDROData_PriorityType thePriority, const Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType theMergeType ); + HYDROData_Zone::MergeType theMergeType ); static HYDROData_ListOfRules GetRules( const TDF_Label& theRulesLabel ); static QString DumpRules( const TDF_Label& theRulesLab ); static void DumpRulesToPython( const TDF_Label& theRulesLab, @@ -71,7 +71,7 @@ public: Handle(HYDROData_Entity)& theObject1, HYDROData_PriorityType& thePriority, Handle(HYDROData_Entity)& theObject2, - HYDROData_Zone::MergeAltitudesType& theMergeType ); + HYDROData_Zone::MergeType& theMergeType ); private: typedef QMap MapNameToObject; diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index 0cbb266d..194d80e6 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -179,7 +179,7 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone( const Handle(HYDROData_Docu if ( aRefObject.IsNull() ) continue; - aNewZone->AddGeometryObject( aRefObject ); + aNewZone->AddObject( aRefObject ); } return aNewZone; @@ -412,7 +412,7 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec // set zone merge type QString aMergeTypeStr; - HYDROData_Zone::MergeAltitudesType aMergeType = aZone->GetMergeType(); + HYDROData_Zone::MergeType aMergeType = aZone->GetMergeType(); if ( aMergeType == HYDROData_Zone::Merge_ZMIN ) { aMergeTypeStr = "HYDROData_Zone.Merge_ZMIN"; } else if ( aMergeType == HYDROData_Zone::Merge_ZMAX ) { @@ -425,11 +425,11 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec aResList << QString( "%1.SetMergeType( %2 )" ).arg( aZone->GetObjPyName() ).arg( aMergeTypeStr ); } if ( aMergeType == HYDROData_Zone::Merge_Object ) { - Handle(HYDROData_IAltitudeObject) aMergeAltitude = aZone->GetMergeAltitude(); - if ( !aMergeAltitude.IsNull() ) { - aMergeAltitude->findPythonReferenceObject( theTreatedObjects, aResList ); - aResList << QString( "%1.SetMergeAltitude( %2 )" ).arg( aZone->GetObjPyName() ) - .arg( aMergeAltitude->GetObjPyName() ); + Handle(HYDROData_Entity) aMergeObject = aZone->GetMergeObject(); + if ( !aMergeObject.IsNull() ) { + aMergeObject->findPythonReferenceObject( theTreatedObjects, aResList ); + aResList << QString( "%1.SetMergeObject( %2 )" ).arg( aZone->GetObjPyName() ) + .arg( aMergeObject->GetObjPyName() ); } } diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 53d40e52..c6e3da1a 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -22,6 +22,7 @@ #include "HYDROData_IAltitudeObject.h" #include "HYDROData_Document.h" #include "HYDROData_NaturalObject.h" +#include "HYDROData_LandCover.h" #include #include @@ -65,8 +66,8 @@ HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const { HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects(); - HYDROData_SequenceOfObjects aSeqOfGeomObjects = GetGeometryObjects(); - aResSeq.Append( aSeqOfGeomObjects ); + HYDROData_SequenceOfObjects aSeqOfObjects = GetObjects(); + aResSeq.Append( aSeqOfObjects ); return aResSeq; } @@ -92,14 +93,15 @@ TopoDS_Shape HYDROData_Zone::GetShape() const bool HYDROData_Zone::IsMergingNeed() const { + // Zones based on geometry objects (compare altitudes) Handle(HYDROData_IAltitudeObject) aRefAltitude; - HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); - HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects ); - for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() ) + HYDROData_SequenceOfObjects anObjects = GetObjects(); + HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects ); + for ( ; anObjsIter.More(); anObjsIter.Next() ) { Handle(HYDROData_Object) aRefGeomObj = - Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() ); + Handle(HYDROData_Object)::DownCast( anObjsIter.Value() ); if ( aRefGeomObj.IsNull() ) continue; @@ -117,6 +119,30 @@ bool HYDROData_Zone::IsMergingNeed() const return true; } + // Zones based on land cover objects (compare Strickler types) + QString aRefStricklerType; + + anObjsIter.Init( anObjects ); + for ( ; anObjsIter.More(); anObjsIter.Next() ) + { + Handle(HYDROData_LandCover) aRefLandCoverObj = + Handle(HYDROData_LandCover)::DownCast( anObjsIter.Value() ); + if ( aRefLandCoverObj.IsNull() ) + continue; + + QString aStricklerType = aRefLandCoverObj->GetStricklerType(); + + if ( aRefStricklerType.isNull() ) + { + aRefStricklerType = aStricklerType; + continue; + } + + if ( aRefStricklerType != aStricklerType ) + return true; + } + + return false; } @@ -130,77 +156,81 @@ HYDROData_IInterpolator* HYDROData_Zone::GetInterpolator() const return myInterpolator; } -void HYDROData_Zone::SetMergeType( const MergeAltitudesType& theType ) +void HYDROData_Zone::SetMergeType( const MergeType& theType ) { TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType ); } -HYDROData_Zone::MergeAltitudesType HYDROData_Zone::GetMergeType() const +HYDROData_Zone::MergeType HYDROData_Zone::GetMergeType() const { - MergeAltitudesType aMergeType = Merge_UNKNOWN; + MergeType aMergeType = Merge_UNKNOWN; TDF_Label aLabel = myLab.FindChild( DataTag_MergeType, false ); if ( !aLabel.IsNull() ) { Handle(TDataStd_Integer) anInt; if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anInt ) ) - aMergeType = (MergeAltitudesType)anInt->Get(); + aMergeType = (MergeType)anInt->Get(); } return aMergeType; } -void HYDROData_Zone::SetMergeAltitude( const Handle(HYDROData_IAltitudeObject)& theAltitude ) +void HYDROData_Zone::SetMergeObject( const Handle(HYDROData_Entity)& theObject ) { - SetReferenceObject( theAltitude, DataTag_MergeAltitude ); + SetReferenceObject( theObject, DataTag_MergeObject ); } -Handle(HYDROData_IAltitudeObject) HYDROData_Zone::GetMergeAltitude() const +Handle(HYDROData_Entity) HYDROData_Zone::GetMergeObject() const { - return Handle(HYDROData_IAltitudeObject)::DownCast( - GetReferenceObject( DataTag_MergeAltitude ) ); + return Handle(HYDROData_Entity)::DownCast( + GetReferenceObject( DataTag_MergeObject ) ); } -void HYDROData_Zone::RemoveMergeAltitude() +void HYDROData_Zone::RemoveMergeObject() { - ClearReferenceObjects( DataTag_MergeAltitude ); + ClearReferenceObjects( DataTag_MergeObject ); } -bool HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) +bool HYDROData_Zone::AddObject( const Handle(HYDROData_Entity)& theObject ) { if ( theObject.IsNull() ) return false; if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) && - !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) ) + !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) && + !theObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) ) return false; // Wrong type of object - if ( HasReference( theObject, DataTag_GeometryObject ) ) + if ( HasReference( theObject, DataTag_Object ) ) return false; // Object is already in reference list - AddReferenceObject( theObject, DataTag_GeometryObject ); + AddReferenceObject( theObject, DataTag_Object ); return true; } -HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const +HYDROData_SequenceOfObjects HYDROData_Zone::GetObjects() const { - return GetReferenceObjects( DataTag_GeometryObject ); + return GetReferenceObjects( DataTag_Object ); } -void HYDROData_Zone::RemoveGeometryObjects() +void HYDROData_Zone::RemoveObjects() { - ClearReferenceObjects( DataTag_GeometryObject ); + ClearReferenceObjects( DataTag_Object ); } bool HYDROData_Zone::IsSubmersible() const { - HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); - HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects ); - for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() ) + HYDROData_SequenceOfObjects anObjects = GetObjects(); + HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects ); + for ( ; anObjsIter.More(); anObjsIter.Next() ) { Handle(HYDROData_Object) aRefGeomObj = - Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() ); + Handle(HYDROData_Object)::DownCast( anObjsIter.Value() ); + if ( aRefGeomObj.IsNull() ) + continue; + if( !aRefGeomObj->IsSubmersible() ) return false; //if one of geometry objects is not submersible the zone is considered as not submersible } diff --git a/src/HYDROData/HYDROData_Zone.h b/src/HYDROData/HYDROData_Zone.h index b8a8c0d2..3f95324c 100644 --- a/src/HYDROData/HYDROData_Zone.h +++ b/src/HYDROData/HYDROData_Zone.h @@ -22,8 +22,7 @@ #include "HYDROData_Entity.h" #include "HYDROData_IInterpolator.h" -class Handle(HYDROData_Object); -class Handle(HYDROData_IAltitudeObject); +class Handle(HYDROData_LandCover); class TopoDS_Shape; DEFINE_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity) @@ -37,13 +36,13 @@ class HYDROData_Zone : public HYDROData_Entity public: - // Enumeration of mergin types for conflict altitudes - enum MergeAltitudesType + // Enumeration of mergin types for conflict altitudes/types + enum MergeType { Merge_UNKNOWN, // Undefined Merge_ZMIN, // The minimum values Merge_ZMAX, // The maximum values - Merge_Object // Only one altitude will be taken into account + Merge_Object // Only one altitude/land cover will be taken into account }; protected: @@ -54,9 +53,9 @@ protected: { DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve DataTag_Shape, ///< reference shape - DataTag_GeometryObject, ///< reference geometry objects - DataTag_MergeType, ///< mergin type of conflict bathymetries - DataTag_MergeAltitude, ///< reference altitude for conflict merge + DataTag_Object, ///< reference objects + DataTag_MergeType, ///< mergin type of conflict bathymetries/types + DataTag_MergeObject, ///< reference altitude/land cover for conflict merge }; public: @@ -120,51 +119,49 @@ public: * * Returns the interpolator of zone object. */ HYDRODATA_EXPORT virtual HYDROData_IInterpolator* GetInterpolator() const; - - + /** * Sets the merging type for conflict altitudes. * By default it is set to Merge_UNKNOWN. */ - HYDRODATA_EXPORT virtual void SetMergeType( const MergeAltitudesType& theType ); + HYDRODATA_EXPORT virtual void SetMergeType( const MergeType& theType ); /** - * Returns the merging type for conflict altitudes. + * Returns the merging type for conflict altitudes/types. */ - HYDRODATA_EXPORT virtual MergeAltitudesType GetMergeType() const; + HYDRODATA_EXPORT virtual MergeType GetMergeType() const; /** - * Sets the reference altitude to resolve the conflict. + * Sets the reference object to resolve the conflict. * This object is used only in case of "Merge_Object" merge type. */ - HYDRODATA_EXPORT virtual void SetMergeAltitude( const Handle(HYDROData_IAltitudeObject)& theAltitude ); + HYDRODATA_EXPORT virtual void SetMergeObject( const Handle(HYDROData_Entity)& theObject ); /** - * Returns the reference altitude to resolve the conflict. + * Returns the reference object to resolve the conflict. */ - HYDRODATA_EXPORT virtual Handle(HYDROData_IAltitudeObject) GetMergeAltitude() const; + HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetMergeObject() const; /** - * Removes the reference altitude for resolving the conflict. + * Removes the reference object for resolving the conflict. */ - HYDRODATA_EXPORT virtual void RemoveMergeAltitude(); + HYDRODATA_EXPORT virtual void RemoveMergeObject(); - /** - * Add new one geometry object for zone. + * Add new one object for zone. */ - HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject ); + HYDRODATA_EXPORT virtual bool AddObject( const Handle(HYDROData_Entity)& theObject ); /** - * Returns all geometry objects of zone. + * Returns all objects of zone. */ - HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const; + HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetObjects() const; /** - * Removes all geometry objects from zone. + * Removes all objects from zone. */ - HYDRODATA_EXPORT virtual void RemoveGeometryObjects(); + HYDRODATA_EXPORT virtual void RemoveObjects(); HYDRODATA_EXPORT bool IsSubmersible() const; diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 83249f3c..1b5fb33b 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -626,7 +626,7 @@ void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject ) myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN ); myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN ); myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX ); - QStringList aList = aZone->getAltitudes(); + QStringList aList = aZone->getObjects(); for ( int i = 0; i < aList.length(); i++ ) { myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object ); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 94ea5dbb..a63a4354 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -518,7 +518,7 @@ void HYDROGUI_CalculationOp::onCreateLandCoverRegion( const QList( inputPanel() ); @@ -527,7 +527,7 @@ void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theAltit HYDROGUI_Zone* aZone = aPanel->getCurrentZone(); if ( aZone ) { - aZone->setMergeType( theMergeType, theAltitudeName ); + aZone->setMergeType( theMergeType, theMergeObjectName ); HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() ); if ( aShape ) { @@ -1207,7 +1207,7 @@ void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDat HYDROData_ListOfRules aRules; Handle(HYDROData_Entity) anObject1, anObject2; HYDROData_PriorityType aPriority; - HYDROData_Zone::MergeAltitudesType aMergeType; + HYDROData_Zone::MergeType aMergeType; HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules; for ( int anIndex = 0; ; anIndex++ ) { diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 2e0c0fae..6629e1c1 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -96,9 +96,9 @@ protected slots: void onRemoveLandCovers(); /** - * Set the given bathymetry merge type to the current zone. + * Set the given bathymetry/type merge type to the current zone. */ - void onSetMergeType( int theMergeType, QString& theBathymetryName ); + void onSetMergeType( int theMergeType, QString& theMergeObjectName ); /** * Selected zones are moved to the existing region. */ diff --git a/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx b/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx index 6e2e46cd..c284d792 100644 --- a/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx +++ b/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx @@ -151,7 +151,7 @@ bool HYDROGUI_PriorityTableModel::setData( const QModelIndex & theIndex, const Q } else if ( aColumn == 1 ) { myRules[aRow].Priority = (HYDROData_PriorityType)theValue.toInt(); } else if ( aColumn == 3 ) { - myRules[aRow].MergeType = (HYDROData_Zone::MergeAltitudesType)theValue.toInt();; + myRules[aRow].MergeType = (HYDROData_Zone::MergeType)theValue.toInt();; } } diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx index 5d152ea5..6554e5ef 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx +++ b/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx @@ -186,9 +186,9 @@ void HYDROGUI_VTKPrsShape::buildShape() else { // Generate the filling color for zone - QStringList aGeomObjectsNames; + QStringList anObjectsNames; - HYDROData_SequenceOfObjects aRefObjects = aZone->GetGeometryObjects(); + HYDROData_SequenceOfObjects aRefObjects = aZone->GetObjects(); HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects ); for ( ; anIter.More(); anIter.Next() ) { @@ -201,7 +201,7 @@ void HYDROGUI_VTKPrsShape::buildShape() if ( aRefObjectName.isEmpty() ) continue; - aGeomObjectsNames.append( aRefObjectName ); + anObjectsNames.append( aRefObjectName ); } //setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) ); diff --git a/src/HYDROGUI/HYDROGUI_Zone.cxx b/src/HYDROGUI/HYDROGUI_Zone.cxx index 9b6b304b..8561008c 100644 --- a/src/HYDROGUI/HYDROGUI_Zone.cxx +++ b/src/HYDROGUI/HYDROGUI_Zone.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -45,8 +46,8 @@ QString HYDROGUI_Zone::text( const int theColumnId ) const aRes = getRefObjectNames(); break; case AltitudeObjId: - // Get altitude object name - aRes = getAltitudeName(); + // Get altitude/land cover object name + aRes = getObjectName(); break; default: aRes = LightApp_DataObject::text( theColumnId ); @@ -61,7 +62,7 @@ QString HYDROGUI_Zone::getRefObjectNames() const Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() ); if ( !aZone.IsNull() ) { - HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects(); + HYDROData_SequenceOfObjects aSeq = aZone->GetObjects(); HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); for ( ; anIter.More(); anIter.Next() ) { @@ -81,13 +82,13 @@ QString HYDROGUI_Zone::getRefObjectNames() const return aRes; } -QString HYDROGUI_Zone::getAltitudeName() const +QString HYDROGUI_Zone::getObjectName() const { QString aRes; Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() ); if ( !aZone.IsNull() ) { - HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects(); + HYDROData_SequenceOfObjects aSeq = aZone->GetObjects(); bool isMergingNeed = aZone->IsMergingNeed(); if ( ( isMergingNeed && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN ) || ( aSeq.Length() == 1 ) || ( !isMergingNeed ) ) @@ -140,11 +141,11 @@ QString HYDROGUI_Zone::getAltitudeName() const case HYDROData_Zone::Merge_ZMAX: // The maximum values aRes = QObject::tr( "MERGE_ZMAX" ); break; - case HYDROData_Zone::Merge_Object: // Only one altitude will be taken into account + case HYDROData_Zone::Merge_Object: // Only one altitude/land cover will be taken into account { - Handle(HYDROData_IAltitudeObject) anAltitude = aZone->GetMergeAltitude(); - if ( !anAltitude.IsNull() ) - aRes = anAltitude->GetName(); + Handle(HYDROData_Entity) aMergeObj = aZone->GetMergeObject(); + if ( !aMergeObj.IsNull() ) + aRes = aMergeObj->GetName(); break; } default: @@ -202,15 +203,15 @@ QColor HYDROGUI_Zone::color( const ColorRole theColorRole, const int theColumnId return aRes; } -QStringList HYDROGUI_Zone::getAltitudes() const +QStringList HYDROGUI_Zone::getObjects() const { QStringList aRes; Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() ); if ( !aZone.IsNull() ) { - HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects(); - // Collect all used altitudes names when merging is necessary - // or just get the name of altitude of a single geometry object + HYDROData_SequenceOfObjects aSeq = aZone->GetObjects(); + // Collect all used altitudes/land cover names when merging is necessary + // or just get the name of altitude/land cover of a single object HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); for ( ; anIter.More(); anIter.Next() ) { @@ -221,15 +222,17 @@ QStringList HYDROGUI_Zone::getAltitudes() const Handle(HYDROData_IAltitudeObject) anAltitudeObj = aRefGeomObj->GetAltitudeObject(); if ( !anAltitudeObj.IsNull() && !aRes.contains( anAltitudeObj->GetName() ) ) aRes.append( anAltitudeObj->GetName() ); + } else { + aRes.append( anIter.Value()->GetName() ); } } } return aRes; } -HYDROData_Zone::MergeAltitudesType HYDROGUI_Zone::getMergeType() const +HYDROData_Zone::MergeType HYDROGUI_Zone::getMergeType() const { - HYDROData_Zone::MergeAltitudesType aRes = HYDROData_Zone::Merge_UNKNOWN; + HYDROData_Zone::MergeType aRes = HYDROData_Zone::Merge_UNKNOWN; Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() ); if ( !aZone.IsNull() ) { @@ -238,32 +241,37 @@ HYDROData_Zone::MergeAltitudesType HYDROGUI_Zone::getMergeType() const return aRes; } -void HYDROGUI_Zone::setMergeType( int theMergeType, QString theAltitudeName ) +void HYDROGUI_Zone::setMergeType( int theMergeType, QString theMergeObjectName ) { Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() ); if ( !aZone.IsNull() ) { - HYDROData_Zone::MergeAltitudesType aMergeType = - ( HYDROData_Zone::MergeAltitudesType )theMergeType; + HYDROData_Zone::MergeType aMergeType = + ( HYDROData_Zone::MergeType )theMergeType; aZone->SetMergeType( aMergeType ); if ( aMergeType == HYDROData_Zone::Merge_Object ) { - // Find an altitude object by the given name and set it as the zone's merge altitude - HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects(); + // Find an altitude/land cover object by the given name and set it as the zone's merge altitude/land cover + HYDROData_SequenceOfObjects aSeq = aZone->GetObjects(); HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); for ( ; anIter.More(); anIter.Next() ) { + Handle(HYDROData_Entity) aMergeObject; + Handle(HYDROData_Object) aRefGeomObj = Handle(HYDROData_Object)::DownCast( anIter.Value() ); if ( !aRefGeomObj.IsNull() ) { - // Get altitude object name - Handle(HYDROData_IAltitudeObject) anAltitudeObj = aRefGeomObj->GetAltitudeObject(); - if ( !anAltitudeObj.IsNull() && theAltitudeName == anAltitudeObj->GetName() ) - { - aZone->SetMergeAltitude( anAltitudeObj ); - break; - } + // Get altitude object + aMergeObject = aRefGeomObj->GetAltitudeObject(); + } else { + aMergeObject = Handle(HYDROData_LandCover)::DownCast( anIter.Value() ); + } + + if ( !aMergeObject.IsNull() && theMergeObjectName == aMergeObject->GetName() ) + { + aZone->SetMergeObject( aMergeObject ); + break; } } } diff --git a/src/HYDROGUI/HYDROGUI_Zone.h b/src/HYDROGUI/HYDROGUI_Zone.h index aaf7a2de..a4293f4c 100644 --- a/src/HYDROGUI/HYDROGUI_Zone.h +++ b/src/HYDROGUI/HYDROGUI_Zone.h @@ -72,23 +72,23 @@ public: bool isMergingNeed() const; /** - * Returns the list of altidude object names. + * Returns the list of source object names. */ - QStringList getAltitudes() const; + QStringList getObjects() const; /** * Returns the merging type for conflict altidudes. */ - HYDROData_Zone::MergeAltitudesType getMergeType() const; + HYDROData_Zone::MergeType getMergeType() const; /** - * Set the merging type for conflict altidudes. - * If the type is Merge_Object then use the second parameter to set the merge bathymetry. + * Set the merging type for conflict altidudes/types. + * If the type is Merge_Object then use the second parameter to set the merge bathymetry/land cover. */ - void setMergeType( int theMergeType, QString theAltitudeName = QString() ); + void setMergeType( int theMergeType, QString theMergeObjectName = QString() ); private: QString getRefObjectNames() const; - QString getAltitudeName() const; + QString getObjectName() const; }; #endif diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip index afa46a34..df0279af 100644 --- a/src/HYDROPy/HYDROData_CalculationCase.sip +++ b/src/HYDROPy/HYDROData_CalculationCase.sip @@ -512,9 +512,9 @@ public: void AddRule( HYDROData_Entity theObject1, HYDROData_PriorityType thePriority, HYDROData_Entity theObject2, - HYDROData_Zone::MergeAltitudesType theMergeType, + HYDROData_Zone::MergeType theMergeType, HYDROData_CalculationCase::DataTag theDataTag ) - [void ( const Handle_HYDROData_Entity&, HYDROData_PriorityType, const Handle_HYDROData_Entity&, HYDROData_Zone::MergeAltitudesType, HYDROData_CalculationCase::DataTag )]; + [void ( const Handle_HYDROData_Entity&, HYDROData_PriorityType, const Handle_HYDROData_Entity&, HYDROData_Zone::MergeType, HYDROData_CalculationCase::DataTag )]; %MethodCode Handle(HYDROData_Entity) anObject1 = Handle(HYDROData_Entity)::DownCast( createHandle( a0 ) ); diff --git a/src/HYDROPy/HYDROData_Zone.sip b/src/HYDROPy/HYDROData_Zone.sip index 6a1aba28..31e1dd2c 100644 --- a/src/HYDROPy/HYDROData_Zone.sip +++ b/src/HYDROPy/HYDROData_Zone.sip @@ -43,7 +43,7 @@ class HYDROData_Zone : public HYDROData_Entity public: // Enumeration of mergin types for conflict altitudes - enum MergeAltitudesType + enum MergeType { Merge_ZMIN, // The minimum values Merge_ZMAX, // The maximum values @@ -56,12 +56,12 @@ public: * Sets the merging type for conflict altitudes. * By default it is set to Merge_ZMIN. */ - void SetMergeType( const MergeAltitudesType& theType ); + void SetMergeType( const MergeType& theType ); /** * Returns the merging type for conflict altitudes. */ - MergeAltitudesType GetMergeType() const; + MergeType GetMergeType() const; /** @@ -76,8 +76,8 @@ public: if ( !aRefAltitude.IsNull() ) { Py_BEGIN_ALLOW_THREADS - sipSelfWasArg ? sipCpp->HYDROData_Zone::SetMergeAltitude( aRefAltitude ) : - sipCpp->SetMergeAltitude( aRefAltitude ); + sipSelfWasArg ? sipCpp->HYDROData_Zone::SetMergeObject( aRefAltitude ) : + sipCpp->SetMergeObject( aRefAltitude ); Py_END_ALLOW_THREADS } @@ -92,8 +92,9 @@ public: Handle(HYDROData_IAltitudeObject) aRefAltitude; Py_BEGIN_ALLOW_THREADS - aRefAltitude = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetMergeAltitude() : - sipCpp->GetMergeAltitude(); + Handle(HYDROData_Entity) aRefObject = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetMergeObject() : + sipCpp->GetMergeObject(); + aRefAltitude = Handle(HYDROData_IAltitudeObject)::DownCast( aRefObject ); Py_END_ALLOW_THREADS sipRes = (HYDROData_IAltitudeObject*)createPointer( aRefAltitude ); @@ -104,35 +105,83 @@ public: * Removes the reference altitude for resolving the conflict. */ void RemoveMergeAltitude(); + %MethodCode + + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_Zone::RemoveMergeObject() : + sipCpp->RemoveMergeObject(); + Py_END_ALLOW_THREADS + + %End + + /** + * Sets the reference object to resolve the conflict. + * This object is used only in case of "Merge_Object" merge type. + */ + void SetMergeObject( HYDROData_Entity theObject ) [void (const Handle_HYDROData_Entity&)]; + %MethodCode + + Handle(HYDROData_Entity) aRefObject = + Handle(HYDROData_Entity)::DownCast( createHandle( a0 ) ); + if ( !aRefObject.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_Zone::SetMergeObject( aRefObject ) : + sipCpp->SetMergeObject( aRefObject ); + Py_END_ALLOW_THREADS + } + %End + + /** + * Returns the reference object to resolve the conflict. + */ + HYDROData_Entity GetMergeObject() const [Handle_HYDROData_Entity ()]; + %MethodCode + + Handle(HYDROData_Entity) aRefObject; + + Py_BEGIN_ALLOW_THREADS + aRefObject = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetMergeObject() : + sipCpp->GetMergeObject(); + Py_END_ALLOW_THREADS + + sipRes = (HYDROData_Entity*)createPointer( aRefObject ); + + %End + + /** + * Removes the reference object for resolving the conflict. + */ + void RemoveMergeObject(); /** - * dd new one geometry object for zone. + * Add new one object for zone. */ - void AddGeometryObject( HYDROData_Object theRegion ) [void (const Handle_HYDROData_Object&)]; + void AddObject( HYDROData_Entity theObject ) [void (const Handle_HYDROData_Entity&)]; %MethodCode - Handle(HYDROData_Object) aGeomObj = - Handle(HYDROData_Object)::DownCast( createHandle( a0 ) ); - if ( !aGeomObj.IsNull() ) + Handle(HYDROData_Entity) anObj = + Handle(HYDROData_Entity)::DownCast( createHandle( a0 ) ); + if ( !anObj.IsNull() ) { Py_BEGIN_ALLOW_THREADS - sipSelfWasArg ? sipCpp->HYDROData_Zone::AddGeometryObject( aGeomObj ) : - sipCpp->AddGeometryObject( aGeomObj ); + sipSelfWasArg ? sipCpp->HYDROData_Zone::AddObject( anObj ) : + sipCpp->AddObject( anObj ); Py_END_ALLOW_THREADS } %End /** - * Returns all geometry objects of zone. + * Returns all objects of zone. */ - HYDROData_SequenceOfObjects GetGeometryObjects() const; + HYDROData_SequenceOfObjects GetObjects() const; /** - * Removes all geometry objects from zone. + * Removes all objects from zone. */ - void RemoveGeometryObjects(); + void RemoveObjects(); /** -- 2.39.2