From: adv Date: Fri, 31 Jan 2014 06:42:44 +0000 (+0000) Subject: Get altitude from region implementation. X-Git-Tag: BR_hydro_v_1_0~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ea116c29ba9e987172ad9befad3c607ef6bfe968;p=modules%2Fhydro.git Get altitude from region implementation. --- diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index e10fb451..509c2c5f 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -527,6 +527,22 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) c return GetAltitudeForPoint( thePoint, aZone ); } +double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint, + const Handle(HYDROData_Region)& theRegion ) const +{ + double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude(); + + Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint ); + if ( !aZone.IsNull() ) + { + Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() ); + if ( IsEqual( aRefRegion, theRegion ) ) + aResAltitude = GetAltitudeForPoint( thePoint, aZone ); + } + + return aResAltitude; +} + double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint, const Handle(HYDROData_Zone)& theZone ) const { @@ -613,6 +629,23 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& return aResAltitude; } +NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( + const NCollection_Sequence& thePoints, + const Handle(HYDROData_Region)& theRegion ) const +{ + 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 ); + aResSeq.Append( anAltitude ); + } + + return aResSeq; +} + NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( const NCollection_Sequence& thePoints, const Handle(HYDROData_Zone)& theZone ) const @@ -630,6 +663,17 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( return aResSeq; } +Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const +{ + Handle(HYDROData_Region) aResRegion; + + 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 { Handle(HYDROData_Zone) aResZone; diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 435a98c1..3629a7dd 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -214,6 +214,15 @@ public: */ HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const; + /** + * Returns altitude for given point on given region. + * \param thePoint the point to examine + * \param theRegion reference region to check + * \return result altitude value + */ + HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint, + const Handle(HYDROData_Region)& theRegion ) const; + /** * Returns altitude for given point on given zone. * \param thePoint the point to examine @@ -223,6 +232,16 @@ public: HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint, const Handle(HYDROData_Zone)& theZone ) const; + /** + * Returns altitudes for given points on given region. + * \param thePoints the points to examine + * \param theRegion reference region to check + * \return result altitude value + */ + HYDRODATA_EXPORT virtual NCollection_Sequence GetAltitudesForPoints( + const NCollection_Sequence& thePoints, + const Handle(HYDROData_Region)& theRegion ) const; + /** * Returns altitudes for given points on given zone. * \param thePoints the points to examine @@ -233,6 +252,13 @@ public: const NCollection_Sequence& thePoints, const Handle(HYDROData_Zone)& theZone ) const; + /** + * Returns region to which the point is belongs. + * \param thePoint the point to examine + * \return result region + */ + HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const; + /** * Returns zone to which the point is belongs. * \param thePoint the point to examine diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip index 9557333f..48a257f9 100644 --- a/src/HYDROPy/HYDROData_CalculationCase.sip +++ b/src/HYDROPy/HYDROData_CalculationCase.sip @@ -300,6 +300,27 @@ public: Py_END_ALLOW_THREADS %End + /** + * Returns altitude for given point on given region. + * \param thePoint the point to examine + * \param theRegion reference region to check + * \return result altitude value + */ + double GetAltitudeForPoint( const double theCoordX, + const double theCoordY, + HYDROData_Region theRegion ) const + [double ( const gp_XY&, const Handle_HYDROData_Region& )]; + %MethodCode + gp_XY aPnt( a0, a1 ); + Handle(HYDROData_Region) aRefRegion = + Handle(HYDROData_Region)::DownCast( createHandle( a2 ) ); + + Py_BEGIN_ALLOW_THREADS + sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudeForPoint( aPnt, aRefRegion ) : + sipCpp->GetAltitudeForPoint( aPnt, aRefRegion ); + Py_END_ALLOW_THREADS + %End + /** * Returns altitude for given point on given zone. * \param thePoint the point to examine @@ -321,6 +342,39 @@ public: Py_END_ALLOW_THREADS %End + /** + * Returns altitudes for given points on given region. + * \param thePoints the points to examine + * \param theZone reference region to check + * \return result altitude value + */ + NCollection_Sequence GetAltitudesForPoints( const NCollection_Sequence& theCoordsX, + const NCollection_Sequence& theCoordsY, + HYDROData_Region theRegion ) const + [NCollection_Sequence ( const NCollection_Sequence&, const Handle_HYDROData_Region& )]; + %MethodCode + + NCollection_Sequence 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.Append( aPnt ); + } + + Handle(HYDROData_Region) aRefRegion = + Handle(HYDROData_Region)::DownCast( createHandle( a2 ) ); + + NCollection_Sequence aRes; + Py_BEGIN_ALLOW_THREADS + aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefRegion ) : + sipCpp->GetAltitudesForPoints( aPnts, aRefRegion ); + Py_END_ALLOW_THREADS + + sipRes = new NCollection_Sequence( aRes ); + %End + /** * Returns altitudes for given points on given zone. * \param thePoints the points to examine @@ -354,6 +408,27 @@ public: sipRes = new NCollection_Sequence( aRes ); %End + /** + * Returns region to which the point is belongs. + * \param thePoint the point to examine + * \return result region + */ + HYDROData_Region GetRegionFromPoint( const double theCoordX, + const double theCoordY ) const + [Handle_HYDROData_Region ( const gp_XY& )]; + %MethodCode + Handle(HYDROData_Region) aRes; + + gp_XY aPnt( a0, a1 ); + + Py_BEGIN_ALLOW_THREADS + aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetRegionFromPoint( aPnt ) : + sipCpp->GetRegionFromPoint( aPnt ); + Py_END_ALLOW_THREADS + + sipRes = (HYDROData_Region*)createPointer( aRes ); + %End + /** * Returns zone to which the point is belongs. * \param thePoint the point to examine