+
+void test_HYDROData_DTM::test_profile_properties()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile->SetParametricPoints( points );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 20, 25 ) );
+
+ gp_Pnt lp;
+ gp_Vec2d dd;
+ double zmin, zmax;
+ HYDROData_DTM::GetProperties( aProfile, lp, dd, false, zmin, zmax );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.75, lp.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 15.625, lp.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lp.Z(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 10, dd.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 15, dd.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, zmin, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, zmax, EPS );
+
+ HYDROData_DTM::GetProperties( aProfile, lp, dd, true, zmin, zmax );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.75, lp.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 15.625, lp.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lp.Z(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, dd.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 10, dd.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, zmin, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, zmax, EPS );
+
+ aDoc->Close();
+}
+
+void test_HYDROData_DTM::test_profile_discretization_polyline()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile->SetParametricPoints( points );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ 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 );
+ int dummy = 0;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.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 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.11, aMid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aMid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.215, aMid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aMid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.768, aMid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aMid[10].Z, EPS );
+
+ CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aWid[0].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aWid[0].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.989, aWid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aWid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 8.618, aWid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aWid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 14.142, aWid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aWid[10].Z, EPS );
+
+ aDoc->Close();
+}
+
+void test_HYDROData_DTM::test_profile_discretization_spline()
+{
+Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile->SetParametricPoints( points );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+ 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 );
+ int dummy = 0 ;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.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 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.755, aMid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aMid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.473, aMid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aMid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.768, aMid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aMid[10].Z, EPS );
+
+ CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.484, aWid[0].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aWid[0].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.809, aWid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aWid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 9.472, aWid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aWid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 14.142, aWid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aWid[10].Z, EPS );
+
+ aDoc->Close();
+}
+
+void operator << ( std::ostream& s, const HYDROData_DTM::PointUZ& p )
+{
+ s << "(" << p.U << "; " << p.Z << ") ";
+}
+
+void operator << ( std::ostream& s, const HYDROData_DTM::AltitudePoint& p )
+{
+ s << "(" << p.X << "; " << p.Y << "; " << p.Z << ") ";
+}
+
+bool operator == ( const HYDROData_DTM::PointUZ& p1, const HYDROData_DTM::PointUZ& p2 )
+{
+ return fabs(p1.U-p2.U)<EPS && fabs(p1.Z-p2.Z)<EPS;
+}
+
+bool operator == ( const HYDROData_DTM::AltitudePoint& p1, const HYDROData_DTM::AltitudePoint& p2 )
+{
+ return fabs(p1.X-p2.X)<EPS && fabs(p1.Y-p2.Y)<EPS && fabs(p1.Z-p2.Z)<EPS;
+}
+
+void operator << ( std::ostream& s, const HYDROData_DTM::CurveUZ& c )
+{
+ size_t n = c.size();
+ for( size_t i=0; i<n; i++ )
+ s << c[i];
+}
+
+void test_HYDROData_DTM::test_curves_interpolation()
+{
+ HYDROData_DTM::CurveUZ A(1.0, gp_Vec2d(), 0), B(2.0, gp_Vec2d(), 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 ) );
+ B.push_back( HYDROData_DTM::PointUZ( 10, 0 ) );
+ B.push_back( HYDROData_DTM::PointUZ( 15, 1 ) );
+ B.push_back( HYDROData_DTM::PointUZ( 20, 2 ) );
+
+ std::vector<HYDROData_DTM::CurveUZ> i1;
+ HYDROData_DTM::Interpolate( A, B, 1, i1, false );
+
+ CPPUNIT_ASSERT_EQUAL( 2, (int)i1.size() );
+ CPPUNIT_ASSERT_EQUAL( A, i1[0] );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i1[1].size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 5, 0 ), i1[1][0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 8, 1 ), i1[1][1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 11, 2 ), i1[1][2] );
+
+ std::vector<HYDROData_DTM::CurveUZ> i2;
+ HYDROData_DTM::Interpolate( A, B, 1, i2, true );
+
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i2.size() );
+ CPPUNIT_ASSERT_EQUAL( A, i2[0] );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i2[1].size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 5, 0 ), i2[1][0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 8, 1 ), i2[1][1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 11, 2 ), i2[1][2] );
+ CPPUNIT_ASSERT_EQUAL( B, i2[2] );
+
+ std::vector<HYDROData_DTM::CurveUZ> i3;
+ HYDROData_DTM::Interpolate( A, B, 3, i3, false );
+
+ CPPUNIT_ASSERT_EQUAL( 4, (int)i3.size() );
+ CPPUNIT_ASSERT_EQUAL( A, i3[0] );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i3[1].size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 2.5, 0 ), i3[1][0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 4.5, 1 ), i3[1][1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 6.5, 2 ), i3[1][2] );
+}
+
+void test_HYDROData_DTM::test_curve_to_3d()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->SetParametricPoints( points );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile1->SetLeftPoint( gp_XY( 20, 0 ) );
+ aProfile1->SetRightPoint( gp_XY( 10, 10 ) );
+
+ aProfile2->SetParametricPoints( points );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile2->SetLeftPoint( gp_XY( 100, 0 ) );
+ aProfile2->SetRightPoint( gp_XY( 110, 0 ) );
+
+ std::vector<double> distances;
+ std::vector<Handle(HYDROData_Profile)> profiles;
+ profiles.push_back( aProfile1 );
+ profiles.push_back( aProfile2 );
+
+ Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances );
+ HYDROData_DTM::AltitudePoints points;
+ HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10), 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 );
+ wid.push_back( HYDROData_DTM::PointUZ( 2, 5 ) );
+ wid.push_back( HYDROData_DTM::PointUZ( 6, 6 ) );
+ HYDROData_DTM::CurveTo3D( HA, mid, wid, points );
+
+ CPPUNIT_ASSERT_EQUAL( 4, (int)points.size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 16.380, -2.186, 6.0 ), points[0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 15.673, -1.479, 5.0 ), points[1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 14.259, -0.065, 5.0 ), points[2] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 12.137, 2.056, 6.0 ), points[3] );
+
+ aDoc->Close();
+}
+
+void test_HYDROData_DTM::test_presentation()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->SetParametricPoints( points );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+ aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
+
+ aProfile2->SetParametricPoints( points );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+ aProfile2->SetLeftPoint( gp_XY( 110, 10 ) );
+ aProfile2->SetRightPoint( gp_XY( 100, 0 ) );
+
+ HYDROData_SequenceOfObjects seq;
+ seq.Append( aProfile1 );
+ seq.Append( aProfile2 );
+ DTM->SetProfiles( seq );
+ DTM->SetDDZ( 0.1 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
+ DTM->SetSpatialStep( 1.0 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
+ DTM->Update();
+
+ CPPUNIT_ASSERT_EQUAL( 9177, (int)DTM->GetAltitudePoints().size() );
+
+ Handle_AIS_InteractiveContext aContext = TestViewer::context();
+ HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
+ aBathPrs->update( true, false );
+
+ TestViewer::showColorScale( true );
+ Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
+ aCS->SetMin( 0.0 );
+ aCS->SetMax( 5.0 );
+ aCS->SetNumberOfIntervals( 10 );
+ aBathPrs->UpdateWithColorScale( aCS );
+
+ QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
+ CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_1" );
+ delete aBathPrs;
+
+ aDoc->Close();
+}
+
+void test_HYDROData_DTM::test_garonne()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
+ fname += "/Profiles.xyz";
+ NCollection_Sequence<int> bad_ids;
+
+ int aSize = HYDROData_Profile::ImportFromFile( aDoc, fname, bad_ids, true );
+
+ CPPUNIT_ASSERT_EQUAL( 0, bad_ids.Size() );
+ CPPUNIT_ASSERT_EQUAL( 46, aSize );
+
+ HYDROData_SequenceOfObjects profiles;
+ HYDROData_Iterator it( aDoc, KIND_PROFILE );
+ for( int i=0; it.More(); it.Next(), i++ )
+ {
+ if( i>=25 && i<=35 )
+ profiles.Append( Handle(HYDROData_Profile)::DownCast( it.Current() ) );
+ }
+
+ CPPUNIT_ASSERT_EQUAL( 11, (int)profiles.Size() );
+
+
+
+ Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+ DTM->SetProfiles( profiles );
+ DTM->SetDDZ( 0.1 );
+ DTM->SetSpatialStep( 1.0 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
+ DTM->Update();
+
+ CPPUNIT_ASSERT_EQUAL( 275690, (int)DTM->GetAltitudePoints().size() );
+
+ Handle_AIS_InteractiveContext aContext = TestViewer::context();
+ HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
+ aBathPrs->update( true, false );
+
+ TestViewer::showColorScale( true );
+ Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
+ aCS->SetMin( 0.0 );
+ aCS->SetMax( 25.0 );
+ aCS->SetNumberOfIntervals( 30 );
+ aBathPrs->UpdateWithColorScale( aCS );
+
+ QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
+ CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_2" );
+ delete aBathPrs;
+
+ aDoc->Close();
+}