From: asl Date: Fri, 9 Dec 2016 11:16:12 +0000 (+0300) Subject: implementation of the strickler types (integer codes) for points X-Git-Tag: v1.6~2^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=15aed67b5f26dad1f17035be35bcd570e947158c;p=modules%2Fhydro.git implementation of the strickler types (integer codes) for points --- diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 53270245..8dee02d6 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -932,6 +932,18 @@ std::vector HYDROData_CalculationCase::GetStricklerCoefficientForPoints( return theCoeffs; } +std::vector HYDROData_CalculationCase::GetStricklerTypeForPoints( const std::vector& thePoints ) const +{ + Handle( HYDROData_LandCoverMap ) aLCM = GetLandCoverMap(); + Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable(); + std::vector types; + if( aLCM.IsNull() || aTable.IsNull() ) + return types; + + aLCM->ClassifyPoints(thePoints, aTable, types ); + return types; +} + Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const { Handle(HYDROData_Region) aResRegion; diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index b88a108e..458d6e8a 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -346,6 +346,8 @@ public: double DefValue, bool UseMax ) const; + HYDRODATA_EXPORT std::vector GetStricklerTypeForPoints( const std::vector& thePoints ) const; + /** * Returns altitudes for given points on given region. * \param thePoints the points to examine diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 1ecf2586..3d166025 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -1273,14 +1273,38 @@ void HYDROData_LandCoverMap::UpdateLocalCS( double theDx, double theDy ) SetShape( aLocatedShape ); } -void HYDROData_LandCoverMap::ClassifyPoints( const std::vector& thePoints, std::vector >& theTypes ) const +void HYDROData_LandCoverMap::ClassifyPoints( const std::vector& thePoints, + std::vector >& theTypes ) const { HYDROData_LCM_FaceClassifier FC(this); FC.Classify(thePoints, theTypes, NULL); } +void HYDROData_LandCoverMap::ClassifyPoints( const std::vector& thePoints, + const Handle(HYDROData_StricklerTable)& theTable, + std::vector& theTypes ) const +{ + std::vector > types; + HYDROData_LCM_FaceClassifier FC(this); + FC.Classify(thePoints, types, NULL); + + size_t n = types.size(); + theTypes.resize( n ); + for( size_t i=0; i& sub_types = types[i]; + int aType = 0; + if( !sub_types.empty() ) + { + const QString& aSType = *sub_types.begin(); + aType = theTable->GetAttrValue( aSType ).toInt(); + } + theTypes[i] = aType; + } +} + void HYDROData_LandCoverMap::ClassifyPoints( const std::vector& thePoints, - Handle(HYDROData_StricklerTable) theTable, + const Handle(HYDROData_StricklerTable)& theTable, std::vector& theCoeffs, double DefValue, bool UseMax ) const { std::vector > Types; diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index f6e681b0..1e05c6f3 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -151,11 +151,16 @@ public: HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); - HYDRODATA_EXPORT void ClassifyPoints( const std::vector& thePoints, std::vector >& theTypes ) const; + HYDRODATA_EXPORT void ClassifyPoints( const std::vector& thePoints, + std::vector >& theTypes ) const; + + HYDRODATA_EXPORT void ClassifyPoints( const std::vector& thePoints, + const Handle(HYDROData_StricklerTable)& theTable, + std::vector& theTypes ) const; HYDRODATA_EXPORT void ClassifyPoints( const std::vector& thePoints, - Handle(HYDROData_StricklerTable) theTable, - std::vector& theCoeffs, double DefValue, bool UseMax ) const; + const Handle(HYDROData_StricklerTable)& theTable, + std::vector& theCoeffs, double DefValue, bool UseMax ) const; protected: void SetShape( const TopoDS_Shape& ); diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip index 1bbc51e6..5f7d254d 100644 --- a/src/HYDROPy/HYDROData_CalculationCase.sip +++ b/src/HYDROPy/HYDROData_CalculationCase.sip @@ -479,6 +479,26 @@ public: %End + std::vector GetStricklerTypeForPoints( const NCollection_Sequence& theCoordsX, + const NCollection_Sequence& theCoordsY ) const + [std::vector( const NCollection_Sequence& )]; + %MethodCode + std::vector aPnts; + int aLen = qMin( a0->Length(), a1->Length() ); + for ( int i = 1; i <= aLen; ++i ) + { + gp_XY aPnt( a0->Value( i ), a1->Value( i ) ); + aPnts.push_back( aPnt ); + } + std::vector aRes; + Py_BEGIN_ALLOW_THREADS + aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetStricklerTypeForPoints( aPnts ) : + sipCpp->GetStricklerTypeForPoints( aPnts ); + Py_END_ALLOW_THREADS + sipRes = new std::vector( aRes ); + %End + + /** * Returns altitudes for given points on given zone. * \param thePoints the points to examine diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index c9934653..66547b5e 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -645,6 +645,12 @@ void test_HYDROData_DTM::test_classifier_1() CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0123, values[1], EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0221, values[2], EPS ); + std::vector types = aCase->GetStricklerTypeForPoints( points ); + CPPUNIT_ASSERT_EQUAL( 3, (int)types.size() ); + CPPUNIT_ASSERT_EQUAL( 123, types[0] ); + CPPUNIT_ASSERT_EQUAL( 123, types[1] ); + CPPUNIT_ASSERT_EQUAL( 221, types[2] ); + aDoc->Close(); }