X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_ProfileUZ.cxx;h=80fe9987309b306ecf9dc7ac997a2718e8577ec7;hb=424f8230c9003d00fb27499b2441c4b3a2a28292;hp=d8ccba4e236cad9d0652b775da8e489342ec95bc;hpb=d84fadb6fba0d9ef3926995eab878175cc24e291;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index d8ccba4e..80fe9987 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -4,6 +4,7 @@ #include "HYDROData_Tool.h" #include +#include #include @@ -30,6 +31,42 @@ TopoDS_Shape HYDROData_ProfileUZ::GetShape() return TopoDS_Shape(); } +double HYDROData_ProfileUZ::GetDepthFromDistance( const double& theDistance ) const +{ + double aResDepth = 0.0; + + HYDROData_IPolyline::PointsList aPoints = GetPoints(); + int aNbPoints = aPoints.Size(); + if ( aNbPoints < 2 ) + return aResDepth; + + double aCompDist = 0.0; + HYDROData_IPolyline::Point aPrevPoint = aPoints.First(); + for ( int i = 2; i <= aNbPoints; ++i ) + { + const Point& aCurPoint = aPoints.Value( i ); + + double aPntDist = gp_Pnt2d( aPrevPoint.X(), 0 ).Distance( gp_Pnt2d( aCurPoint.X(), 0 ) ); + + aCompDist += aPntDist; + + if ( theDistance < aCompDist ) + { + double aComPntDist = gp_Pnt2d( aPoints.First().X(), 0 ).Distance( gp_Pnt2d( aPrevPoint.X(), 0 ) ); + + double aFindDist = theDistance - aComPntDist; + double aRatio = aFindDist / ( aPntDist - aFindDist ); + + aResDepth = ( aPrevPoint.Y() + aRatio * aCurPoint.Y() ) / ( 1 + aRatio ); + break; + } + + aPrevPoint = aCurPoint; + } + + return aResDepth; +} + int HYDROData_ProfileUZ::NbSections() const { return 1;