IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
-HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir, double theDeltaZ )
- : myXcurv( theXCurv ), myProfileDir( theProfileDir ), myDeltaZ( theDeltaZ )
+HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir, double theDeltaZ, double theMaxZ )
+ : myXcurv( theXCurv ), myProfileDir( theProfileDir ), myDeltaZ( theDeltaZ ), myMaxZ (theMaxZ)
{
}
return myDeltaZ;
}
+double HYDROData_DTM::CurveUZ::MaxZ() const
+{
+ return myMaxZ;
+}
+
HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator + ( const CurveUZ& c ) const
{
- HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir(), DeltaZ() + c.DeltaZ() );
+ HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir(), DeltaZ() + c.DeltaZ(), MaxZ() + c.MaxZ() );
size_t n = size(), n1 = c.size();
if( n!=n1 )
{
HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator * ( double d ) const
{
- HYDROData_DTM::CurveUZ res( Xcurv()*d, ProfileDir()*d, DeltaZ()*d );
+ HYDROData_DTM::CurveUZ res( Xcurv()*d, ProfileDir()*d, DeltaZ()*d, MaxZ()*d );
size_t n = size();
res.reserve( n );
for( int i=0; i<n; i++ )
}
void HYDROData_DTM::ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile,
- double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
+ double theXCurv, double theMinZ, double theMaxZ, double theTopZ, double theDDZ,
CurveUZ& theMidPointCurve,
CurveUZ& theWidthCurve,
int& intersection_nb,
curves.push_back( aT2 );
int psize = ( int )( ( theMaxZ-theMinZ ) / theDDZ + 1 );
- theMidPointCurve = CurveUZ( theXCurv, aProfileDir, theMinZ );
+ theMidPointCurve = CurveUZ( theXCurv, aProfileDir, theMinZ, theTopZ);
theMidPointCurve.reserve( psize );
- theWidthCurve = CurveUZ( theXCurv, aProfileDir, theMinZ );
+ theWidthCurve = CurveUZ( theXCurv, aProfileDir, theMinZ, theTopZ );
theWidthCurve.reserve( psize );
n = curves.size();
size_t n = theMidCurve.size();
std::map<double, AltitudePoint> sorted_points;
- for( size_t i=0; i<n; i++ )
+ bool isOnTop = false;
+ for( size_t i=0; i<n; i++ ) // build the two banks of the interpolated profile, from bottom to top
{
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);
gp_Pnt2d p2 = point.Translated( param2 * profile_dir);
- double z = theMidCurve[i].Z + theMidCurve.DeltaZ();
-
- AltitudePoint p3d_1( p1.X(), p1.Y(), z ), p3d_2( p2.X(), p2.Y(), z );
-
- sorted_points[param1] = p3d_1;
- sorted_points[param2] = p3d_2;
+ bool arrivedOnTop = false;
+ double z = 0;
+ if (theMidCurve[i].Z <= theMidCurve.MaxZ())
+ z = theMidCurve[i].Z + theMidCurve.DeltaZ();
+ else
+ {
+ z = theMidCurve.MaxZ() + theMidCurve.DeltaZ(); // limit z to linear interpolation between maxima on extremity profiles
+ arrivedOnTop = true; // do not keep points after this one
+ }
+ if (!isOnTop)
+ {
+ AltitudePoint p3d_1( p1.X(), p1.Y(), z ), p3d_2( p2.X(), p2.Y(), z );
+
+ sorted_points[param1] = p3d_1;
+ sorted_points[param2] = p3d_2;
+ }
+ //if (arrivedOnTop)
+ // isOnTop =true; // do not keep points after this one (commented: leads to strange limits of 2D shape)
}
thePoints.reserve( sorted_points.size() );
//double zmin = min( zminA, zminB );
//double zmax = max( zmaxA, zmaxB );
- CurveUZ midA(0, gp_Vec2d(), 0), midB(0, gp_Vec2d(), 0);
- CurveUZ widA(0, gp_Vec2d(), 0), widB(0, gp_Vec2d(), 0);
+ CurveUZ midA(0, gp_Vec2d(), 0, 0), midB(0, gp_Vec2d(), 0, 0);
+ CurveUZ widA(0, gp_Vec2d(), 0, 0), widB(0, gp_Vec2d(), 0, 0);
- ProfileDiscretization( theProfileA, theXCurvA, zminA, zminA+hmax, theDDZ, midA, widA, inter_nb_1 );
- ProfileDiscretization( theProfileB, theXCurvB, zminB, zminB+hmax, theDDZ, midB, widB, inter_nb_2 );
+ ProfileDiscretization( theProfileA, theXCurvA, zminA, zminA+hmax, zmaxA-zminA, theDDZ, midA, widA, inter_nb_1 );
+ ProfileDiscretization( theProfileB, theXCurvB, zminB, zminB+hmax, zmaxB-zminB, theDDZ, midB, widB, inter_nb_2 );
std::vector<CurveUZ> mid, wid;
Interpolate( midA, midB, theNbSteps, mid, isAddSecond );
aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
aProfile->SetRightPoint( gp_XY( 20, 20 ) );
- HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0 ), aWid( 0.0, gp_Vec2d(), 0 );
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
int dummy = 0;
- HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy );
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy );
CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].U, EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );
aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
aProfile->SetRightPoint( gp_XY( 20, 20 ) );
- HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0 ), aWid( 0.0, gp_Vec2d(), 0 );
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
int dummy = 0 ;
- HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy );
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy );
CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.242, aMid[0].U, EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );
void test_HYDROData_DTM::test_curves_interpolation()
{
- HYDROData_DTM::CurveUZ A(1.0, gp_Vec2d(), 0), B(2.0, gp_Vec2d(), 0);
+ HYDROData_DTM::CurveUZ A(1.0, gp_Vec2d(), 0, 0), B(2.0, gp_Vec2d(), 0, 0);
A.push_back( HYDROData_DTM::PointUZ( 0, 0 ) );
A.push_back( HYDROData_DTM::PointUZ( 1, 1 ) );
A.push_back( HYDROData_DTM::PointUZ( 2, 2 ) );
Handle(Geom2d_BSplineCurve) HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances );
HYDROData_DTM::AltitudePoints points;
- HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10), 0 );
+ HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10), 0, 0 );
mid.push_back( HYDROData_DTM::PointUZ( 0, 5 ) );
mid.push_back( HYDROData_DTM::PointUZ( 1, 6 ) );
- HYDROData_DTM::CurveUZ wid( 5.0, gp_Vec2d(-10,10), 0 );
+ HYDROData_DTM::CurveUZ wid( 5.0, gp_Vec2d(-10,10), 0, 0 );
wid.push_back( HYDROData_DTM::PointUZ( 2, 5 ) );
wid.push_back( HYDROData_DTM::PointUZ( 6, 6 ) );
HYDROData_DTM::CurveTo3D( HA, mid, wid, points );