X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_ProfileUZ.cxx;h=1189970cb45bfe753c1ae92687a2a2eec03186eb;hb=27b1abdc88719c5bce7a8d2f49612cd155e80d21;hp=36ce31c6a528c9b03c6534072d23fa43c11e3c3d;hpb=8749815cc2069167555bf5e823190727b7004a35;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index 36ce31c6..1189970c 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -1,15 +1,39 @@ +// 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" #include "HYDROData_Tool.h" #include +#include #include +#include +#include +#include #include -#include +#include + +#include +#include IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline) @@ -24,10 +48,45 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ() { } -TopoDS_Wire HYDROData_ProfileUZ::GetWire() const +TopoDS_Shape HYDROData_ProfileUZ::GetShape() const { - // TODO - return TopoDS_Wire(); + return TopoDS_Shape(); +} + +double HYDROData_ProfileUZ::GetDepthFromDistance( const PointsList& thePoints, + const double& theDistance ) +{ + double aResDepth = 0.0; + + int aNbPoints = thePoints.Size(); + if ( aNbPoints < 2 ) + return aResDepth; + + double aCompDist = 0.0; + HYDROData_IPolyline::Point aPrevPoint = thePoints.First(); + for ( int i = 2; i <= aNbPoints; ++i ) + { + const Point& aCurPoint = thePoints.Value( i ); + + double aPntDist = gp_Pnt2d( aPrevPoint.X(), 0 ).Distance( gp_Pnt2d( aCurPoint.X(), 0 ) ); + + aCompDist += aPntDist; + + if ( theDistance < aCompDist ) + { + double aComPntDist = gp_Pnt2d( thePoints.First().X(), 0 ).Distance( gp_Pnt2d( aPrevPoint.X(), 0 ) ); + + double aFindDist = theDistance - aComPntDist; + double aRatio = aFindDist / ( aPntDist - aFindDist ); + + aResDepth = ( aPrevPoint.Y() + aRatio * aCurPoint.Y() ) / ( 1 + aRatio ); + break; + } + + aPrevPoint = aCurPoint; + } + + return aResDepth; } int HYDROData_ProfileUZ::NbSections() const @@ -35,8 +94,47 @@ int HYDROData_ProfileUZ::NbSections() const return 1; } -void HYDROData_ProfileUZ::AddSection( const bool /*theIsClosed*/ ) +void HYDROData_ProfileUZ::AddSection( const TCollection_AsciiString& /*theSectName*/, + const SectionType /*theSectionType*/, + const bool /*theIsClosed*/ ) +{ +} + +TCollection_AsciiString HYDROData_ProfileUZ::GetSectionName( const int /*theSectionIndex*/ ) const { + return "Section_1"; +} + +void HYDROData_ProfileUZ::SetSectionName( const int /*theSectionIndex*/, + const TCollection_AsciiString& /*theSectionName*/ ) +{ +} + +HYDROData_ProfileUZ::SectionType HYDROData_ProfileUZ::GetSectionType( const int /*theSectionIndex*/ ) const +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aTypesList.IsNull() || aTypesList->IsEmpty() ) + return SECTION_POLYLINE; + + return (SectionType)aTypesList->First(); +} + +void HYDROData_ProfileUZ::SetSectionType( const int /*theSectionIndex*/, + const SectionType theSectionType ) +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList ); + if ( aTypesList.IsNull() ) + return; + + // Refill the existing list + aTypesList->Clear(); + aTypesList->Append( theSectionType ); } bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const @@ -44,6 +142,11 @@ bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const return false; } +void HYDROData_ProfileUZ::SetSectionClosed( const int /*theSectionIndex*/, + const bool /*theIsClosed*/ ) +{ +} + void HYDROData_ProfileUZ::RemoveSection( const int /*theSectionIndex*/ ) { RemoveSections(); @@ -118,8 +221,8 @@ void HYDROData_ProfileUZ::AddPoint( const int /*theSectionIndex*/, } void HYDROData_ProfileUZ::SetPoint( const int theSectionIndex, - const int /*thePointIndex*/, - const Point& thePoint ) + const Point& thePoint, + const int /*thePointIndex*/ ) { AddPoint( theSectionIndex, thePoint ); } @@ -175,4 +278,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() ) ); + +} +