+ 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"));
+ }