X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_ChannelAltitude.cxx;h=5467a236a944ab05535c689f998bb341d1876385;hb=7ab1a585bb3c17efb1cc89fa4c29b20dff44420b;hp=413685f83f3ddbc4a8874ec8de21e856ee2d10c5;hpb=25c483f304a19aace130948fd7f6771bb82bd09c;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_ChannelAltitude.cxx b/src/HYDROData/HYDROData_ChannelAltitude.cxx index 413685f8..5467a236 100644 --- a/src/HYDROData/HYDROData_ChannelAltitude.cxx +++ b/src/HYDROData/HYDROData_ChannelAltitude.cxx @@ -26,8 +26,9 @@ #include "HYDROData_PolylineXY.h" #include "HYDROData_ProfileUZ.h" #include "HYDROData_Profile.h" +#include -#define _DEVDEBUG_ +//#define _DEVDEBUG_ #include "HYDRO_trace.hxx" #include @@ -53,7 +54,6 @@ #include #include -IMPLEMENT_STANDARD_HANDLE(HYDROData_ChannelAltitude, HYDROData_IAltitudeObject) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ChannelAltitude, HYDROData_IAltitudeObject) HYDROData_ChannelAltitude::HYDROData_ChannelAltitude() @@ -65,7 +65,8 @@ HYDROData_ChannelAltitude::~HYDROData_ChannelAltitude() { } -double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) const +double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint, + int theMethod) const { DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << ")"); double aResAltitude = GetInvalidAltitude(); @@ -116,6 +117,10 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c // --- See GEOMImpl_ProjectionDriver.cxx + gp_XY LP, RP; + aProfile->GetLeftPoint(LP); + aProfile->GetRightPoint(RP); + TopoDS_Shape aShape = aGuideXY->GetShape(); gp_Pnt P1(thePoint.X(), thePoint.Y(), 0); TopoDS_Shape aPoint = BRepBuilderAPI_MakeVertex(P1).Shape(); @@ -255,7 +260,7 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c return aResAltitude; } double aDepth = HYDROData_ProfileUZ::GetDepthFromDistance( aProfilePoints, aParam ); - //DEBTRACE("profile altitude: " << aDepth); + DEBTRACE("profile altitude: " << aDepth); // Compute edge index. TopExp_Explorer anExp(aShape, TopAbs_EDGE); @@ -270,22 +275,34 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c // get the XY distance from point to guideline const gp_Pnt &aPntProj = aDistShSh.PointOnShape2(i); - //DEBTRACE("projection: (" << aPntProj.X() << ", " << aPntProj.Y() << ", " << aPntProj.Z() << ")"); + DEBTRACE("projection: (" << aPntProj.X() << ", " << aPntProj.Y() << ", " << aPntProj.Z() << ")"); gp_XY aProjXY = gp_XY(aPntProj.X(), aPntProj.Y()); aProjXY.Subtract(thePoint); double distance = aProjXY.Modulus(); - //DEBTRACE("distance to guideline " << distance); + + gp_Vec2d aProjDir = aProjXY; + gp_Vec2d aProfileDir(LP, RP); + double aSign = 1.0; + if( aProfileDir.Dot(aProjDir) < 0 ) + aSign = -1.0; + + distance *= aSign; + DEBTRACE("distance to guideline " << distance); + + if (GetInvertDirection()) + distance*=-1; // get delta altitude on section (supposed symmetric) from guideline distance (aParam) double delta = 0; int i1 = 0; + int i2 = 0; gp_XY pt1 = gp_XY(); gp_XY pt2 = gp_XY(); HYDROData_ProfileUZ::PointsList aSectionPoints = aProfile->GetParametricPoints(); for ( int i = 1, aNbPoints = aSectionPoints.Size(); i <= aNbPoints; ++i ) { const HYDROData_IPolyline::Point& aPolylinePoint = aSectionPoints.Value( i ); - //DEBTRACE(" profile point: " << aPolylinePoint.X() << " " << aPolylinePoint.Y()); + DEBTRACE(" i, size, profile point: " << i << " " << aSectionPoints.Size() << " " << aPolylinePoint.X() << " " << aPolylinePoint.Y()); if (aPolylinePoint.X() < distance) { i1 = i; @@ -293,17 +310,24 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c } if (aPolylinePoint.X() >= distance) { + i2 = i; pt2 = aPolylinePoint; break; } } - if ((i1 == 0) && (distance > 0)) + if ((i1 == 0) && (i2 == 0)) { DEBTRACE("Projection aborted : non centered profile"); return aResAltitude; } - if (i1 == aProfilePoints.Size()) // distance >= profile width + else if (i1 == 0) // distance < - profile width { + DEBTRACE("distance < - profile width"); + delta = pt2.Y(); + } + else if (i1 == aSectionPoints.Size()) // distance >= profile width + { + DEBTRACE("distance >= profile width"); delta = pt1.Y(); } else @@ -326,5 +350,27 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c } +void HYDROData_ChannelAltitude::SetInvertDirection(bool IsInverted) +{ + if ( GetInvertDirection() == IsInverted ) + return; + + TDataStd_Integer::Set( myLab.FindChild( DataTag_InvertDirection ), (Standard_Integer)IsInverted ); +} + +bool HYDROData_ChannelAltitude::GetInvertDirection() const +{ + bool aRes = false; + + TDF_Label aLabel = myLab.FindChild( DataTag_InvertDirection, false ); + if ( !aLabel.IsNull() ) + { + Handle(TDataStd_Integer) anIntVal; + if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) ) + aRes = (bool)anIntVal->Get(); + } + + return aRes; +}