From 5c45a299fb45a108740d6175f7e83c5f63f4c004 Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 16 Dec 2013 08:08:41 +0000 Subject: [PATCH] bug #237: fatal error on profile --- src/HYDROData/HYDROData_Bathymetry.cxx | 21 ++++++++++++++++----- src/HYDROData/HYDROData_Polyline3D.cxx | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 43d484c7..60e2d9bf 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -16,6 +16,8 @@ #include #include +#include + #define _TIMER #ifdef _TIMER #include @@ -187,7 +189,8 @@ void interpolateAltitudeForPoints( const gp_XY& th double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const { - double aResAltitude = GetInvalidAltitude(); + double anInvalidAltitude = GetInvalidAltitude(); + double aResAltitude = anInvalidAltitude; AltitudePoints anAltitudePoints = GetAltitudePoints(); if ( anAltitudePoints.isEmpty() ) @@ -199,10 +202,10 @@ double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const // [ 0 (top-left) ] [ 1 (top-right) ] // thePoint // [ 2 (bot-left) ] [ 3 (bot-right) ] - AltitudePoint aBounds[ 4 ] = { AltitudePoint( -DBL_MAX, -DBL_MAX, GetInvalidAltitude() ), - AltitudePoint( DBL_MAX, -DBL_MAX, GetInvalidAltitude() ), - AltitudePoint( -DBL_MAX, DBL_MAX, GetInvalidAltitude() ), - AltitudePoint( DBL_MAX, DBL_MAX, GetInvalidAltitude() ) }; + AltitudePoint aBounds[ 4 ] = { AltitudePoint( -DBL_MAX, -DBL_MAX, anInvalidAltitude ), + AltitudePoint( DBL_MAX, -DBL_MAX, anInvalidAltitude ), + AltitudePoint( -DBL_MAX, DBL_MAX, anInvalidAltitude ), + AltitudePoint( DBL_MAX, DBL_MAX, anInvalidAltitude ) }; AltitudePoints::const_iterator aListItBeg = anAltitudePoints.constBegin(); AltitudePoints::const_iterator aListItEnd = anAltitudePoints.constEnd(); @@ -288,6 +291,14 @@ double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const aBoundingRect << QPointF( aPoint.X(), aPoint.Y() ); } + const double LIMIT = 1E300; + if( fabs( aBounds[ 0 ].X() ) > LIMIT || fabs( aBounds[ 0 ].Y() ) > LIMIT || + fabs( aBounds[ 1 ].X() ) > LIMIT || fabs( aBounds[ 1 ].Y() ) > LIMIT || + fabs( aBounds[ 2 ].X() ) > LIMIT || fabs( aBounds[ 2 ].Y() ) > LIMIT || + fabs( aBounds[ 3 ].X() ) > LIMIT || fabs( aBounds[ 3 ].Y() ) > LIMIT ) + return anInvalidAltitude; + + // Check if requested point is inside of our bounding rectangle if ( !aBoundingRect.boundingRect().contains( thePoint.X(), thePoint.Y() ) ) return aResAltitude; diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index 0507b2e8..2bdd60a5 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -318,6 +318,8 @@ HYDROData_IPolyline::PointsList generateProfileUZPoints( double aPointDistance = thePolyline->GetDistance( 0, i - 1 ); double aPointDepth = theBathymetry->GetAltitudeForPoint( aSectPoint ); + if( aPointDepth==theBathymetry->GetInvalidAltitude() ) + aPointDepth = 0.0; HYDROData_IPolyline::Point anAltitudePoint( aPointDistance, aPointDepth ); aPointsList.Append( anAltitudePoint ); -- 2.39.2