Salome HOME
projects
/
modules
/
hydro.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'origin/master' into BR_LAND_COVER_MAP
[modules/hydro.git]
/
src
/
HYDROData
/
HYDROData_PriorityQueue.cxx
diff --git
a/src/HYDROData/HYDROData_PriorityQueue.cxx
b/src/HYDROData/HYDROData_PriorityQueue.cxx
index 59ffc56d24ecb319dd2a4180ffa603694fd96899..12d39ce61e005ebe64d848db4b84e81f70bded24 100644
(file)
--- a/
src/HYDROData/HYDROData_PriorityQueue.cxx
+++ b/
src/HYDROData/HYDROData_PriorityQueue.cxx
@@
-1,8
+1,4
@@
-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+// Copyright (C) 2014-2015 EDF-R&D
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
@@
-23,16
+19,19
@@
#include <HYDROData_PriorityQueue.h>
#include <HYDROData_CalculationCase.h>
#include <HYDROData_Iterator.h>
#include <HYDROData_PriorityQueue.h>
#include <HYDROData_CalculationCase.h>
#include <HYDROData_Iterator.h>
+#include <HYDROData_LandCover.h>
#include <TDataStd_ReferenceList.hxx>
#include <TDataStd_Integer.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDataStd_ReferenceList.hxx>
#include <TDataStd_Integer.hxx>
#include <TDF_ChildIterator.hxx>
-HYDROData_PriorityQueue::HYDROData_PriorityQueue( HYDROData_CalculationCase* theCalcCase )
+HYDROData_PriorityQueue::HYDROData_PriorityQueue( HYDROData_CalculationCase* theCalcCase,
+ Standard_Integer aTag )
{
{
- myGeomObjects = theCalcCase->GetGeometryObjects();
- for( int i=myGeomObjects.Lower(), n=myGeomObjects.Upper(); i<=n; i++ )
+ bool isLandCover = aTag == HYDROData_CalculationCase::DataTag_CustomLandCoverRules;
+ myObjects = isLandCover ? theCalcCase->GetLandCovers() : theCalcCase->GetGeometryObjects();
+ for( int i=myObjects.Lower(), n=myObjects.Upper(); i<=n; i++ )
{
{
- Handle(HYDROData_
Object) anObj = Handle(HYDROData_Object)::DownCast( myGeomObjects.Value( i )
);
+ Handle(HYDROData_
Entity) anObj = myObjects.Value( i
);
if( !anObj.IsNull() )
{
QString anObjName = anObj->GetName();
if( !anObj.IsNull() )
{
QString anObjName = anObj->GetName();
@@
-40,31
+39,31
@@
HYDROData_PriorityQueue::HYDROData_PriorityQueue( HYDROData_CalculationCase* the
}
}
}
}
- myRules = GetRules( theCalcCase->Label().FindChild(
HYDROData_CalculationCase::DataTag_CustomRules
) );
+ myRules = GetRules( theCalcCase->Label().FindChild(
aTag
) );
}
HYDROData_PriorityQueue::~HYDROData_PriorityQueue()
{
}
}
HYDROData_PriorityQueue::~HYDROData_PriorityQueue()
{
}
-Handle(HYDROData_
Object
) HYDROData_PriorityQueue::GetMostPriorityObject( const QStringList& theZoneObjects,
- HYDROData_Zone::Merge
Altitudes
Type& theMergeType ) const
+Handle(HYDROData_
Entity
) HYDROData_PriorityQueue::GetMostPriorityObject( const QStringList& theZoneObjects,
+ HYDROData_Zone::MergeType& theMergeType ) const
{
QStringList aSortedZoneObjects;
{
QStringList aSortedZoneObjects;
- for( int i=my
GeomObjects.Lower(), n=myGeom
Objects.Upper(); i<=n; i++ )
+ for( int i=my
Objects.Lower(), n=my
Objects.Upper(); i<=n; i++ )
{
{
- QString aName = my
Geom
Objects.Value( i )->GetName();
+ QString aName = myObjects.Value( i )->GetName();
if( theZoneObjects.contains( aName ) )
aSortedZoneObjects.append( aName );
}
if( theZoneObjects.contains( aName ) )
aSortedZoneObjects.append( aName );
}
- Handle(HYDROData_
Object
) aMostPriorityObj;
+ Handle(HYDROData_
Entity
) aMostPriorityObj;
theMergeType = HYDROData_Zone::Merge_UNKNOWN;
QStringList::const_iterator anIt = aSortedZoneObjects.begin(), aLast = aSortedZoneObjects.end();
for( ; anIt!=aLast; anIt++ )
{
theMergeType = HYDROData_Zone::Merge_UNKNOWN;
QStringList::const_iterator anIt = aSortedZoneObjects.begin(), aLast = aSortedZoneObjects.end();
for( ; anIt!=aLast; anIt++ )
{
- HYDROData_Zone::Merge
Altitudes
Type aLocalMerge = HYDROData_Zone::Merge_UNKNOWN;
- Handle(HYDROData_
Object
) anObj = myNames[*anIt];
+ HYDROData_Zone::MergeType aLocalMerge = HYDROData_Zone::Merge_UNKNOWN;
+ Handle(HYDROData_
Entity
) anObj = myNames[*anIt];
if( !anObj.IsNull() )
{
if( aMostPriorityObj.IsNull() )
if( !anObj.IsNull() )
{
if( aMostPriorityObj.IsNull() )
@@
-86,9
+85,9
@@
Handle(HYDROData_Object) HYDROData_PriorityQueue::GetMostPriorityObject( const Q
return aMostPriorityObj;
}
return aMostPriorityObj;
}
-bool HYDROData_PriorityQueue::IsMorePriority( const Handle(HYDROData_
Object
)& theObj1,
- const Handle(HYDROData_
Object
)& theObj2,
- HYDROData_Zone::Merge
Altitudes
Type& theMergeType ) const
+bool HYDROData_PriorityQueue::IsMorePriority( const Handle(HYDROData_
Entity
)& theObj1,
+ const Handle(HYDROData_
Entity
)& theObj2,
+ HYDROData_Zone::MergeType& theMergeType ) const
{
// 1. First we check custom rules
HYDROData_ListOfRules::const_iterator anIt = myRules.begin(), aLast = myRules.end();
{
// 1. First we check custom rules
HYDROData_ListOfRules::const_iterator anIt = myRules.begin(), aLast = myRules.end();
@@
-107,14
+106,14
@@
bool HYDROData_PriorityQueue::IsMorePriority( const Handle(HYDROData_Object)& th
}
// 2. If no custom rule found, the standard ordering list is applied
}
// 2. If no custom rule found, the standard ordering list is applied
- for( int i=my
GeomObjects.Lower(), n=myGeom
Objects.Upper(); i<=n; i++ )
+ for( int i=my
Objects.Lower(), n=my
Objects.Upper(); i<=n; i++ )
{
{
- if( my
Geom
Objects.Value( i )->Label() == theObj1->Label() )
+ if( myObjects.Value( i )->Label() == theObj1->Label() )
{
theMergeType = HYDROData_Zone::Merge_Object;
return true;
}
{
theMergeType = HYDROData_Zone::Merge_Object;
return true;
}
- if( my
Geom
Objects.Value( i )->Label() == theObj2->Label() )
+ if( myObjects.Value( i )->Label() == theObj2->Label() )
{
theMergeType = HYDROData_Zone::Merge_Object;
return false;
{
theMergeType = HYDROData_Zone::Merge_Object;
return false;
@@
-136,11
+135,11
@@
enum HYDROData_PriorityQueueTag
Merge_Tag,
};
Merge_Tag,
};
-void HYDROData_PriorityQueue::AddRule( TDF_Label&
theRulesLabel,
- const Handle(HYDROData_
Object)&
theObject1,
- HYDROData_PriorityType
thePriority,
- const Handle(HYDROData_
Object)&
theObject2,
- HYDROData_Zone::Merge
AltitudesType
theMergeType )
+void HYDROData_PriorityQueue::AddRule( TDF_Label& theRulesLabel,
+ const Handle(HYDROData_
Entity)&
theObject1,
+ HYDROData_PriorityType thePriority,
+ const Handle(HYDROData_
Entity)&
theObject2,
+ HYDROData_Zone::Merge
Type
theMergeType )
{
// Get the last rule index
Standard_Integer aRuleIndex = 0;
{
// Get the last rule index
Standard_Integer aRuleIndex = 0;
@@
-189,10
+188,10
@@
HYDROData_ListOfRules HYDROData_PriorityQueue::GetRules( const TDF_Label& theRul
if( isObj1OK && isPriorityOK && isObj2OK && isMergeOK )
{
HYDROData_CustomRule aRule;
if( isObj1OK && isPriorityOK && isObj2OK && isMergeOK )
{
HYDROData_CustomRule aRule;
- aRule.Object1 = H
andle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs1->First()
) );
+ aRule.Object1 = H
YDROData_Iterator::Object( aRefs1->First(
) );
aRule.Priority = ( HYDROData_PriorityType ) aPriorityAttr->Get();
aRule.Priority = ( HYDROData_PriorityType ) aPriorityAttr->Get();
- aRule.Object2 = H
andle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs2->First()
) );
- aRule.MergeType = ( HYDROData_Zone::Merge
Altitudes
Type ) aMergeAttr->Get();
+ aRule.Object2 = H
YDROData_Iterator::Object( aRefs2->First(
) );
+ aRule.MergeType = ( HYDROData_Zone::MergeType ) aMergeAttr->Get();
aRules.append( aRule );
}
}
aRules.append( aRule );
}
}
@@
-202,7
+201,9
@@
HYDROData_ListOfRules HYDROData_PriorityQueue::GetRules( const TDF_Label& theRul
QString HYDROData_PriorityQueue::DumpRules( const TDF_Label& theRulesLab )
{
QString HYDROData_PriorityQueue::DumpRules( const TDF_Label& theRulesLab )
{
- QString aDump = "Rules:\n";
+ bool isLandCover = theRulesLab.Tag() == HYDROData_CalculationCase::DataTag_CustomLandCoverRules;
+ QString aDump = isLandCover ? "Land Cover rules:\n" : "Rules:\n";
+
HYDROData_ListOfRules aRules = GetRules( theRulesLab );
HYDROData_ListOfRules::const_iterator anIt = aRules.begin(), aLast = aRules.end();
for( ; anIt!=aLast; anIt++ )
HYDROData_ListOfRules aRules = GetRules( theRulesLab );
HYDROData_ListOfRules::const_iterator anIt = aRules.begin(), aLast = aRules.end();
for( ; anIt!=aLast; anIt++ )
@@
-244,6
+245,12
@@
void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab,
QString aPriority = anIt->Priority == LESS ? "LESS" : "GREATER";
QString aMergeType;
QString aPriority = anIt->Priority == LESS ? "LESS" : "GREATER";
QString aMergeType;
+ HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules;
+ Handle(HYDROData_LandCover) aLandCover1 = Handle(HYDROData_LandCover)::DownCast( anIt->Object1 );
+ Handle(HYDROData_LandCover) aLandCover2 = Handle(HYDROData_LandCover)::DownCast( anIt->Object2 );
+ if ( !aLandCover1.IsNull() && !aLandCover2.IsNull() )
+ aDataTag = HYDROData_CalculationCase::DataTag_CustomLandCoverRules;
+
switch( anIt->MergeType )
{
case HYDROData_Zone::Merge_UNKNOWN:
switch( anIt->MergeType )
{
case HYDROData_Zone::Merge_UNKNOWN:
@@
-260,8
+267,8
@@
void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab,
break;
}
break;
}
- QString aRule = QString( "%0.AddRule( %1, %2, %3, %4 )" ).
- arg( theCalcCaseName ).arg( anObj1 ).arg( aPriority ).arg( anObj2 ).arg( aMergeType );
+ QString aRule = QString( "%0.AddRule( %1, %2, %3, %4
, %5
)" ).
+ arg( theCalcCaseName ).arg( anObj1 ).arg( aPriority ).arg( anObj2 ).arg( aMergeType )
.arg( aDataTag )
;
theScript << aRule;
}
theScript << aRule;
}
@@
-269,10
+276,10
@@
void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab,
bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab,
int theIndex,
bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab,
int theIndex,
- Handle(HYDROData_
Object)&
theObject1,
- HYDROData_PriorityType&
thePriority,
- Handle(HYDROData_
Object)&
theObject2,
- HYDROData_Zone::Merge
Altitudes
Type& theMergeType )
+ Handle(HYDROData_
Entity)&
theObject1,
+ HYDROData_PriorityType& thePriority,
+ Handle(HYDROData_
Entity)&
theObject2,
+ HYDROData_Zone::MergeType& theMergeType )
{
TDF_Label aRuleLabel = theRulesLab.FindChild( theIndex );
{
TDF_Label aRuleLabel = theRulesLab.FindChild( theIndex );
@@
-287,10
+294,10
@@
bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab,
bool isOK = isObj1OK && isPriorityOK && isObj2OK && isMergeOK;
if( isOK )
{
bool isOK = isObj1OK && isPriorityOK && isObj2OK && isMergeOK;
if( isOK )
{
- theObject1 = H
andle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs1->First()
) );
+ theObject1 = H
YDROData_Iterator::Object( aRefs1->First(
) );
thePriority = ( HYDROData_PriorityType ) aPriorityAttr->Get();
thePriority = ( HYDROData_PriorityType ) aPriorityAttr->Get();
- theObject2 = H
andle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs2->First()
) );
- theMergeType = ( HYDROData_Zone::Merge
Altitudes
Type ) aMergeAttr->Get();
+ theObject2 = H
YDROData_Iterator::Object( aRefs2->First(
) );
+ theMergeType = ( HYDROData_Zone::MergeType ) aMergeAttr->Get();
}
return isOK;
}
}
return isOK;
}