X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_DTM.cxx;h=4db3a948b63f60fa52fc018b1ea6fa81c9ff54f3;hb=d398a8be8e0b0259b476b358d53d234ce4c82379;hp=384f672a1348247ef936ac23b5f9523756fb6397;hpb=5124dac22315ff6a5e6cce6509a5f86ea15e1b78;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 384f672a..4db3a948 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry ) @@ -82,8 +85,70 @@ HYDROData_DTM::~HYDROData_DTM() { } +HYDROData_SequenceOfObjects HYDROData_DTM::GetProfiles() const +{ + return GetReferenceObjects( DataTag_Profiles ); +} + +void HYDROData_DTM::SetProfiles( const HYDROData_SequenceOfObjects& theProfiles ) +{ + SetReferenceObjects( theProfiles, DataTag_Profiles ); +} + +double HYDROData_DTM::GetDDZ() const +{ + return GetDouble( DataTag_DDZ ); +} + +void HYDROData_DTM::SetDDZ( double theDDZ ) +{ + SetDouble( DataTag_DDZ, theDDZ ); +} + +double HYDROData_DTM::GetSpatialStep() const +{ + return GetDouble( DataTag_SpatialStep ); +} + +void HYDROData_DTM::SetSpatialStep( double theSpatialStep ) +{ + SetDouble( DataTag_SpatialStep, theSpatialStep ); +} + +void HYDROData_DTM::Update() +{ + HYDROData_SequenceOfObjects objs = GetProfiles(); + int aLower = objs.Lower(), anUpper = objs.Upper(); + size_t n = anUpper-aLower+1; + + std::vector profiles; + profiles.reserve( n ); + for( int i=aLower; i<=anUpper; i++ ) + { + Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( objs.Value( i ) ); + if( !aProfile.IsNull() ) + profiles.push_back( aProfile ); + } + + double ddz = GetDDZ(); + double step = GetSpatialStep(); + const double EPS = 1E-3; + AltitudePoints points; + if( ddz>EPS && step>EPS ) + points = Interpolate( profiles, ddz, step ); + SetAltitudePoints( points ); +} + -void GetProperties( const Handle_HYDROData_Profile& theProfile, + + + + + + + + +void HYDROData_DTM::GetProperties( const Handle_HYDROData_Profile& theProfile, gp_Pnt& theLowestPoint, gp_Vec2d& theDir, bool isNormalDir, double& theZMin, double& theZMax ) @@ -99,6 +164,20 @@ void GetProperties( const Handle_HYDROData_Profile& theProfile, theDir = gp_Vec2d( -y, x ); else theDir = gp_Vec2d( x, y ); + + HYDROData_Profile::ProfilePoints points = theProfile->GetProfilePoints(); + int lo = points.Lower(); + int up = points.Upper(); + theZMin = std::numeric_limits::max(); + theZMax = -theZMin; + for( int i=lo; i<=up; i++ ) + { + double z = points.Value( i ).Z(); + if( z>theZMax ) + theZMax = z; + if( zValue( i ); + Geom2dAPI_ProjectPointOnCurve aProject( aPnt, aResult ); + Standard_Real aParam = aProject.LowerDistanceParameter(); + double aDistance = GCPnts_AbscissaPoint::Length( anAdaptor, aParamFirst, aParam ); + theDistances.push_back( aDistance ); + } } return aResult; } @@ -278,7 +371,8 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr { double aDblMax = std::numeric_limits::max(), aUMin = aDblMax, - aUMax = -aUMin; + aUMax = -aUMin, + aVMax = 1000000; std::vector curves = ProfileToParametric( theProfile, aUMin, aUMax ); size_t n = curves.size(); @@ -291,10 +385,10 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr curves[0]->D0( curves[0]->FirstParameter(), aFirst ); curves[n-1]->D0( curves[n-1]->LastParameter(), aLast ); Handle(Geom2d_Line) aV1 = new Geom2d_Line( aFirst, gp_Dir2d( 0, 1 ) ); - Handle(Geom2d_TrimmedCurve) aT1 = new Geom2d_TrimmedCurve( aV1, 0.0, aDblMax ); + Handle(Geom2d_TrimmedCurve) aT1 = new Geom2d_TrimmedCurve( aV1, 0.0, aVMax ); Handle(Geom2d_Line) aV2 = new Geom2d_Line( aLast, gp_Dir2d( 0, 1 ) ); - Handle(Geom2d_TrimmedCurve) aT2 = new Geom2d_TrimmedCurve( aV2, 0.0, aDblMax ); + Handle(Geom2d_TrimmedCurve) aT2 = new Geom2d_TrimmedCurve( aV2, 0.0, aVMax ); curves.push_back( aT1 ); curves.push_back( aT2 ); @@ -315,7 +409,7 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr { Handle_Geom2d_Curve aCurve = curves[i]; Geom2dAPI_InterCurveCurve anIntersect( aCurve, aLine, theTolerance ); - for( int k=0, m=anIntersect.NbPoints(); k0 ? 2*mid[0].size() : 1; + AltitudePoints points; + points.reserve( p*q ); + for( size_t i=0; i& theProfiles, - double theDDZ, double theSpatialStep, AltitudePoints& thePoints ) +HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate + ( const std::vector& theProfiles, + double theDDZ, double theSpatialStep ) { + AltitudePoints points; size_t n = theProfiles.size(); if( n<=1 ) - return; + return points; std::vector distances; Handle_Geom2d_BSplineCurve aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances ); if( aHydraulicAxis.IsNull() ) - return; + return points; for( size_t i=0, n1=n-1; i