+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
+
+ 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( 281898, (int)DTM->GetAltitudePoints().size() );
+
+ Handle(AIS_InteractiveContext) aContext = TestViewer::context();
+ HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
+ aBathPrs->update( true, false );
+ aBathPrs->RescaleDefault();
+
+ bool ColorScaleIsDisp = TestViewer::ColorScaleIsDisplayed();
+
+ TestViewer::showColorScale( true );
+ Handle(AIS_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_IMAGES3( &aDTMPrs, "DTM_2", false );
+ TestViewer::showColorScale( ColorScaleIsDisp );
+ delete aBathPrs;
+ aDoc->Close();
+}
+
+void test_HYDROData_DTM::test_classifier_1()
+{
+ TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
+ fname += "/pb_1066.cbf";
+ CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString() ) );
+
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
+
+ Handle(HYDROData_CalculationCase) aCase =
+ Handle(HYDROData_CalculationCase)::DownCast( aDoc->FindObjectByName( "Case_1" ) );
+ CPPUNIT_ASSERT_EQUAL( false, aCase.IsNull() );
+ std::vector<gp_XY> points;
+ points.push_back( gp_XY( 43.4842, 3.33176 ) );
+ points.push_back( gp_XY( -125.777, 2.24728 ) );
+ points.push_back( gp_XY( -60.1628, 168.262 ) );
+ points.push_back( gp_XY( 21.8055587645, 154.699344457 ) );
+ points.push_back( gp_XY( -84.4764138524, 79.2606012276 ) );
+ points.push_back( gp_XY( -73.4132070504, 69.7096313266 ) );
+
+ std::vector<double> values = aCase->GetStricklerCoefficientForPoints( points, 0.0, true );
+ CPPUNIT_ASSERT_EQUAL( 6, (int)values.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0123, values[0], EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0123, values[1], EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0221, values[2], EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0221, values[3], EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0221, values[4], EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0221, values[5], EPS );
+
+ std::vector<int> types = aCase->GetStricklerTypeForPoints( points );
+ CPPUNIT_ASSERT_EQUAL( 6, (int)types.size() );
+ CPPUNIT_ASSERT_EQUAL( 123, types[0] );
+ CPPUNIT_ASSERT_EQUAL( 123, types[1] );
+ CPPUNIT_ASSERT_EQUAL( 221, types[2] );
+ CPPUNIT_ASSERT_EQUAL( 221, types[3] );
+ CPPUNIT_ASSERT_EQUAL( 221, types[4] );
+ CPPUNIT_ASSERT_EQUAL( 221, types[5] );
+
+ aDoc->Close();
+}
+
+void test_HYDROData_DTM::test_profile_discretization_warnings()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
+
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ NCollection_Sequence<gp_XY> pnts;
+ pnts.Append( gp_XY( 0.0, 1.0 ) );
+ pnts.Append( gp_XY( 1.0, 0.0 ) );
+ pnts.Append( gp_XY( 2.0, 4.0 ) );
+ pnts.Append( gp_XY( 3.0, 5.0 ) );
+
+ aProfile->SetParametricPoints( pnts );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+ int dummy = 0;
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+ //CPPUNIT_ASSERT_EQUAL(1, warnings.size());
+ CPPUNIT_ASSERT( warnings.contains("One of the extreme points is higher than another"));
+ }
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ NCollection_Sequence<gp_XY> pnts;
+ pnts.Append( gp_XY( 0.0, 1.0 ) );
+ pnts.Append( gp_XY( 1.0, 0.0 ) );
+ pnts.Append( gp_XY( 2.0, 5.0 ) );
+ pnts.Append( gp_XY( 3.0, 0.0 ) );
+ pnts.Append( gp_XY( 4.0, 1.0 ) );
+
+ aProfile->SetParametricPoints( pnts );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+ int dummy = 0;
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+ CPPUNIT_ASSERT_EQUAL(1, warnings.size());
+ CPPUNIT_ASSERT( warnings.contains("More than 2 intersections between profile & altitude Z-lines found"));
+ }
+ {
+ //plato case
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ NCollection_Sequence<gp_XY> pnts;
+ pnts.Append( gp_XY( 0.0, 5.0 ) );
+ pnts.Append( gp_XY( 1.0, 5.0 ) );
+ pnts.Append( gp_XY( 2.0, 0.5 ) );
+ pnts.Append( gp_XY( 3.0, 5.0 ) );
+ pnts.Append( gp_XY( 4.0, 5.0 ) );
+
+ aProfile->SetParametricPoints( pnts );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+ int dummy = 0;
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+ CPPUNIT_ASSERT_EQUAL(2, warnings.size());
+ CPPUNIT_ASSERT( warnings.contains("Plato case on extremes"));
+ }
+
+ aDoc->Close();