X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Profile.cxx;h=3a628a74c4b8e321e955cc780f3bca15a1e05bc6;hb=f7c005b67e48ec7bac99c566fb4f34215ec1a4b1;hp=494461f2d15ec65cf4ea33924507ca4dc3dab89c;hpb=95fae05fbf436c6efd6dcebe37dc8315e9f3147b;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 494461f2..3a628a74 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -1,3 +1,24 @@ +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "HYDROData_Profile.h" @@ -642,4 +663,58 @@ void HYDROData_Profile::UpdateLocalCS( double theDx, double theDy ) 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; +}