X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_DTM.cxx;h=544dd2e53184269221fe352cacc1f099c5b7fb0f;hb=f9d37ee66fa46871478d806faa54de237225d3c6;hp=579c09eb19386692d46980371ac2a602ff987db1;hpb=8a699901ec6830f65a1515467162ad7471a1a951;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 579c09eb..544dd2e5 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -35,8 +35,8 @@ IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry ) IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry ) -HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv ) - : myXcurv( theXCurv ) +HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir ) + : myXcurv( theXCurv ), myProfileDir( theProfileDir ) { } @@ -49,9 +49,14 @@ double HYDROData_DTM::CurveUZ::Xcurv() const return myXcurv; } +gp_Vec2d HYDROData_DTM::CurveUZ::ProfileDir() const +{ + return myProfileDir; +} + HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator + ( const CurveUZ& c ) const { - HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv() ); + HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir() ); size_t n = size(); res.reserve( n ); for( int i=0; iSetValue( (int)i, aPnt ); tangents.SetValue( (int)i, aVec ); flags->SetValue( (int)i, Standard_True ); @@ -352,18 +356,17 @@ Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis( std::vector HYDROData_DTM::ProfileToParametric( const Handle_HYDROData_Profile& theProfile, - double& theUMin, double& theUMax ) + double& theUMin, double& theUMax, gp_Vec2d& theDir ) { std::vector curves; // Transformation of the coordinate systems gp_Pnt aLowest; - gp_Vec2d aDir; double zmin, zmax; - GetProperties( theProfile, aLowest, aDir, false, zmin, zmax ); + GetProperties( theProfile, aLowest, theDir, false, zmin, zmax ); gp_Ax3 aStd3d( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( 1, 0, 0 ) ); - gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( aDir.X(), aDir.Y(), 0 ) ); + gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( theDir.X(), theDir.Y(), 0 ) ); gp_Trsf aTransf; aTransf.SetTransformation( aStd3d, aLocal ); @@ -390,26 +393,14 @@ std::vector HYDROData_DTM::ProfileToParametric( } -double CalcGC( const std::vector& intersections ) -{ - double u = 0; - size_t n = intersections.size(); - for( size_t i = 0; i < n; i++ ) - { - u += intersections[i].X(); - } - u /= n; - return u; -} - -double CalcWidth( const std::vector& intersections ) +bool CalcMidWidth( const std::vector& intersections, double& theMid, double& theWid ) { double umin = std::numeric_limits::max(), umax = -umin; size_t n = intersections.size(); if( n <= 1 ) - return 0; + return false; for( size_t i = 0; i < n; i++ ) { @@ -419,7 +410,9 @@ double CalcWidth( const std::vector& intersections ) if( u>umax ) umax = u; } - return umax-umin; + theMid = ( umin+umax )/2; + theWid = umax-umin; + return true; } void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& theProfile, @@ -433,7 +426,8 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr aUMax = -aUMin, aVMax = 1000000; - std::vector curves = ProfileToParametric( theProfile, aUMin, aUMax ); + gp_Vec2d aProfileDir; + std::vector curves = ProfileToParametric( theProfile, aUMin, aUMax, aProfileDir ); size_t n = curves.size(); if( n==0 ) @@ -453,9 +447,9 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr curves.push_back( aT2 ); int psize = ( int )( ( theMaxZ-theMinZ ) / theDDZ + 1 ); - theMidPointCurve = CurveUZ( theXCurv ); + theMidPointCurve = CurveUZ( theXCurv, aProfileDir ); theMidPointCurve.reserve( psize ); - theWidthCurve = CurveUZ( theXCurv ); + theWidthCurve = CurveUZ( theXCurv, aProfileDir ); theWidthCurve.reserve( psize ); n = curves.size(); @@ -474,13 +468,15 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr if( intersections.size() >= 2 ) { - double u_mid = CalcGC( intersections ); + double u_mid, u_wid; + if( !CalcMidWidth( intersections, u_mid, u_wid ) ) + continue; + PointUZ p_mid; p_mid.U = u_mid; p_mid.Z = z; theMidPointCurve.push_back( p_mid ); - double u_wid = CalcWidth( intersections ); PointUZ p_wid; p_wid.U = u_wid; p_wid.Z = z; @@ -507,23 +503,23 @@ void HYDROData_DTM::Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCur if( isAddSecond ) theInterpolation.push_back( theCurveB ); } - +#include void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis, const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve, AltitudePoints& thePoints, Bank* theLeft, Bank* theRight, double dz ) { Geom2dAdaptor_Curve anAdaptor( theHydraulicAxis ); + TopoDS_Edge E2d = BRepLib_MakeEdge2d(theHydraulicAxis).Edge(); GCPnts_AbscissaPoint ap( anAdaptor, theMidCurve.Xcurv(), anAdaptor.FirstParameter() ); double aParam = ap.Parameter(); gp_Pnt2d point; - gp_Vec2d tangent, profile_dir; - anAdaptor.D1( aParam, point, tangent ); - profile_dir.SetCoord( tangent.Y(), -tangent.X() ); + anAdaptor.D0( aParam, point ); + gp_Vec2d profile_dir = theMidCurve.ProfileDir(); + gp_Dir tangent_n( -profile_dir.Y(), profile_dir.X(), dz ); profile_dir.Normalize(); - gp_Dir tangent_n( tangent.X(), tangent.Y(), dz ); - + size_t n = theMidCurve.size(); double min_param = 1E+15; double max_param = -1E+15; @@ -533,8 +529,8 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi double param1 = theMidCurve[i].U - theWidthCurve[i].U / 2; double param2 = theMidCurve[i].U + theWidthCurve[i].U / 2; - gp_Pnt2d p1 = point.Translated( param1 * profile_dir / 2 ); - gp_Pnt2d p2 = point.Translated( param2 * profile_dir / 2 ); + gp_Pnt2d p1 = point.Translated( param1 * profile_dir); + gp_Pnt2d p2 = point.Translated( param2 * profile_dir); double z = theMidCurve[i].Z; @@ -566,13 +562,13 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi if( theLeft ) { - gp_Pnt2d left2d = point.Translated( min_param * profile_dir / 2 ); + gp_Pnt2d left2d = point.Translated( min_param * profile_dir ); gp_Pnt left( left2d.X(), left2d.Y(), z1 ); theLeft->push_back( left, tangent_n ); } if( theRight ) { - gp_Pnt2d right2d = point.Translated( max_param * profile_dir / 2 ); + gp_Pnt2d right2d = point.Translated( max_param * profile_dir ); gp_Pnt right( right2d.X(), right2d.Y(), z2 ); theRight->push_back( right, tangent_n ); } @@ -586,6 +582,8 @@ inline double max( double a, double b ) return b; } +#include + HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate ( const Handle_Geom2d_BSplineCurve& theHydraulicAxis, const Handle_HYDROData_Profile& theProfileA, @@ -607,8 +605,8 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate double zmin = max( zminA, zminB ); double zmax = max( zmaxA, zmaxB ); - CurveUZ midA(0), midB(0); - CurveUZ widA(0), widB(0); + CurveUZ midA(0, gp_Vec2d()), midB(0, gp_Vec2d()); + CurveUZ widA(0, gp_Vec2d()), widB(0, gp_Vec2d()); ProfileDiscretization( theProfileA, theXCurvA, zmin, zmax, theDDZ, midA, widA ); ProfileDiscretization( theProfileB, theXCurvB, zmin, zmax, theDDZ, midB, widB ); @@ -624,6 +622,10 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate for( size_t i=0; imyPoints.size() - 1; i++) + WM.Add(BRepLib_MakeEdge(theLeft->myPoints[i], theLeft->myPoints[i+1]).Edge()); + TopoDS_Wire W = WM.Wire(); return points; } @@ -647,7 +649,7 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate for( size_t i=0, n1=n-1; ireserve( aNbStepsComplete ); @@ -657,7 +659,7 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate for( size_t i=0, n1=n-1; i