SetRightPoint( aPnt, false );
}
+HYDROData_Profile::ProfilePoint HYDROData_Profile::GetBottomPoint() const
+{
+ ProfilePoint aBottom;
+
+ // Get parametric points
+ HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints();
+ if ( aParametricPoints.Length() < 1 ) {
+ return aBottom;
+ }
+
+ // Calculate midvalue for U parameter
+ Standard_Real anUMidValue = aParametricPoints.First().X();
+ Standard_Real anUMinValue = anUMidValue;
+ Standard_Real anUMaxValue = anUMidValue;
+
+ for ( int i = 2, aNbPoints = aParametricPoints.Size(); i <= aNbPoints; i++ ) {
+ const HYDROData_IPolyline::Point& aParPoint = aParametricPoints.Value( i );
+ Standard_Real anU = aParPoint.X();
+
+ if ( anU < anUMinValue ) {
+ anUMinValue = anU;
+ } else if ( anU > anUMaxValue ) {
+ anUMaxValue = anU;
+ }
+ }
+
+ anUMidValue = ( anUMinValue + anUMaxValue ) / 2;
+
+ // Find index of the parametric point with minimal Z value
+ int aBottomIndex = 1;
+ HYDROData_IPolyline::Point aParBottom = aParametricPoints.First();
+
+ for ( int i = 2, aNbPoints = aParametricPoints.Size(); i <= aNbPoints; i++ ) {
+ const HYDROData_IPolyline::Point& aParPoint = aParametricPoints.Value( i );
+ if ( aParPoint.Y() < aParBottom.Y() ) {
+ aBottomIndex = i;
+ aParBottom = aParPoint;
+ } else if ( aParPoint.Y() == aParBottom.Y() ) {
+ // Check which point is neares to the U = 0.5
+ if ( fabs( aParPoint.X() - anUMidValue ) < fabs( aParBottom.X() - anUMidValue ) ) {
+ aBottomIndex = i;
+ aParBottom = aParPoint;
+ }
+ }
+ }
+
+ // Find the corresponding profile point
+ ProfilePoints aProfilePoints = GetProfilePoints( false );
+ if ( aBottomIndex >= 1 && aBottomIndex <= aProfilePoints.Length() ) {
+ aBottom = aProfilePoints.Value( aBottomIndex );
+ }
+
+ return aBottom;
+}