X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_ProfileUZ.cxx;h=bfe75e3b55092840f3f6701cdf2f9e74bb27cc5b;hb=f9d37ee66fa46871478d806faa54de237225d3c6;hp=09fc5234de188ee49bcd28eb8e02cc8cac57873c;hpb=ba70cb7d5a35a6d311acc1b061fb450afe04d0f8;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx old mode 100755 new mode 100644 index 09fc5234..bfe75e3b --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -1,3 +1,20 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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_ProfileUZ.h" @@ -15,6 +32,9 @@ #include +#include +#include + IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ProfileUZ, HYDROData_IPolyline) @@ -28,38 +48,8 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ() { } -QStringList HYDROData_ProfileUZ::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const -{ - QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); - - // Set polilyne data - const TCollection_AsciiString& aSectName = GetSectionName( 0 ); - const SectionType& aSectType = GetSectionType( 0 ); - bool aSectClosure = IsClosedSection( 0 ); - - aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aName ) - .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure ); - - HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( 0 ); - for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) - { - const Point& aSectPoint = aSectPointsList.Value( k ); - - aResList << QString( "%1.AddPoint( 0, QPointF( %2, %3 ) );" ).arg( aName ) - .arg( aSectPoint.X() ).arg( aSectPoint.Y() ); - } - - aResList << QString( "" ); - aResList << QString( "%1.Update();" ).arg( aName ); - aResList << QString( "" ); - - return aResList; -} - TopoDS_Shape HYDROData_ProfileUZ::GetShape() const { - // TODO return TopoDS_Shape(); } @@ -92,6 +82,7 @@ double HYDROData_ProfileUZ::GetDepthFromDistance( const PointsList& thePoints, aResDepth = ( aPrevPoint.Y() + aRatio * aCurPoint.Y() ) / ( 1 + aRatio ); break; } + else aResDepth = aCurPoint.Y(); // TODO: workaround for normalized flat altitudes aPrevPoint = aCurPoint; } @@ -268,7 +259,7 @@ void HYDROData_ProfileUZ::RemovePoint( const int /*theSectionIndex*/, } } -HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theSectionIndex*/ ) const +HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theSectionIndex*/, bool /*IsConvertToGlobal*/ ) const { PointsList aResList; @@ -288,4 +279,36 @@ HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theS return aResList; } +void HYDROData_ProfileUZ::CalculateAndAddPoints(const NCollection_Sequence& theXYZPoints, Handle_HYDROData_PolylineXY& thePolylineXY) +{ + // Fill 2D polyline + for ( int i = 1; i <= theXYZPoints.Size(); i++ ) { + const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i ); + thePolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) ); + } + + // Calculate profile UZ points + + // First point + const HYDROData_Profile::ProfilePoint& aFirstBottomPoint = theXYZPoints.First(); + AddPoint( 0, HYDROData_ProfileUZ::Point( 0, aFirstBottomPoint.Z() ) ); + + // Intermediate points + double aPolylineCommonDist = thePolylineXY->GetDistance( 0, thePolylineXY->NbPoints( 0 ) - 1 ); + + for ( int i = 2, aNbPoints = theXYZPoints.Size(); i < aNbPoints; i++ ) { + const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i ); + + double aDistance = thePolylineXY->GetDistance( 0, i - 1 ); + + Standard_Real anU = aDistance; // = ( aDistance / aPolylineCommonDist ) * aPolylineCommonDist; + AddPoint( 0, HYDROData_ProfileUZ::Point( anU, aBottomPoint.Z() ) ); + } + + // Last point + const HYDROData_Profile::ProfilePoint& aLastBottomPoint = theXYZPoints.Last(); + AddPoint( 0, HYDROData_ProfileUZ::Point( aPolylineCommonDist, aLastBottomPoint.Z() ) ); + +} +