#include <gp_Pnt2d.hxx>
+const double EPS = 1E-4;
+
void generateOne( QTextStream& theStream,
double theFirstX, double theFirstY,
double theLastX, double theLastY )
{
const int aNbPoints = 50;
-
- double aComDist = gp_Pnt2d( theFirstX, theFirstY ).Distance( gp_Pnt2d( theLastX, theLastY ) );
- double aStep = aComDist / (double)aNbPoints;
-
double aStepZ = -5;
- double aCurDist = 0.0;
- for ( int i = 0; i <= aNbPoints; ++i )
+ const double dt = 1.0 / aNbPoints;
+
+ for( double t=0.0; t<=1.0; t += dt )
{
- double aRatio = ( aCurDist / ( aComDist - aCurDist ) );
-
- double anX = ( theFirstX + aRatio * theLastX ) / ( 1 + aRatio );
- double anY = ( theFirstY + aRatio * theLastY ) / ( 1 + aRatio );
+ double anX = theFirstX * (1-t) + theLastX * t;
+ double anY = theFirstY * (1-t) + theLastY * t;
double aZ = aStepZ * aStepZ + sin( (float)rand() );
theStream << anX << " " << anY << " " << aZ << " \n";
- aCurDist += aStep;
aStepZ += 0.2;
}
}
CPPUNIT_ASSERT( aBathymetry->ImportFromFile( aFileName.toStdString().c_str() ) );
HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry->GetAltitudePoints();
- CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
+ CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
gp_XY aTestPoint( 1, 1 );
double anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 10.0 ) );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.9755, anAltitude, EPS );
aTestPoint = gp_XY( 0.5, 0.5 );
anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 5.0 ) );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0147, anAltitude, EPS );
aTestPoint = gp_XY( 1.5, 1 );
anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 10.0 ) );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.9534, anAltitude, EPS );
aTestPoint = gp_XY( 1.5, 0.7 );
anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 7.0 ) );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5032, anAltitude, EPS );
aTestPoint = gp_XY( 1.5, -0.7 );
anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, HYDROData_Bathymetry::GetInvalidAltitude() ) );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 6.3088, anAltitude, EPS );
aTestPoint = gp_XY( 2, 3.5 );
anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
- CPPUNIT_ASSERT( ValuesEquals( anAltitude, 35.0 ) );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 11.090, anAltitude, EPS );
aDoc->Close();
}
CPPUNIT_ASSERT( aBathymetry1->ImportFromFile( aFileName.toStdString().c_str() ) );
HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry1->GetAltitudePoints();
- CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
+ CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
}
Handle(HYDROData_Bathymetry) aBathymetry2 =
if ( anIsFileCreated )
{
HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry2->GetAltitudePoints();
- CPPUNIT_ASSERT( anAltitudePoints.Length() == 20 );
+ CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
}
aDoc->Close();
NCollection_Sequence<bool> aSectClosures;
aPolyline->GetSections( aSectNames, aSectTypes, aSectClosures );
- CPPUNIT_ASSERT( aSectNames.Value( 0 ) == "Section_1" );
- CPPUNIT_ASSERT( aSectTypes.Value( 0 ) == HYDROData_PolylineXY::SECTION_POLYLINE );
- CPPUNIT_ASSERT( aSectClosures.Value( 0 ) == false );
-
- CPPUNIT_ASSERT( aSectNames.Value( 1 ) == "Section_2" );
- CPPUNIT_ASSERT( aSectTypes.Value( 1 ) == HYDROData_PolylineXY::SECTION_SPLINE );
- CPPUNIT_ASSERT( aSectClosures.Value( 1 ) == true );
+ CPPUNIT_ASSERT_EQUAL( 2, aSectNames.Size() );
+ CPPUNIT_ASSERT( aSectNames.Value( 1 ) == "Section_1" );
+ CPPUNIT_ASSERT( aSectTypes.Value( 1 ) == HYDROData_PolylineXY::SECTION_POLYLINE );
+ CPPUNIT_ASSERT( aSectClosures.Value( 1 ) == false );
+
+ CPPUNIT_ASSERT( aSectNames.Value( 2 ) == "Section_2" );
+ CPPUNIT_ASSERT( aSectTypes.Value( 2 ) == HYDROData_PolylineXY::SECTION_SPLINE );
+ CPPUNIT_ASSERT( aSectClosures.Value( 2 ) == true );
aDoc->Close();
}
#include <QFile>
#include <QTextStream>
+const double EPS = 1E-2;
+
bool test_HYDROData_Profile::createTestFile( const QString& theFileName,
const bool theIsParametric )
{
CPPUNIT_ASSERT( aProfilePoints.Length() == 5 );
HYDROData_Profile::ProfilePoint aProfilePoint = aProfilePoints.Value( 3 );
- CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.X(), 1040509.21 ) );
- CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.Y(), 6788619.81 ) );
- CPPUNIT_ASSERT( ValuesEquals( aProfilePoint.Z(), 181.63 ) );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( aProfilePoint.X(), 1040509.21, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( aProfilePoint.Y(), 6788619.81, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( aProfilePoint.Z(), 181.63, EPS );
aDoc->Close();
}