Salome HOME
update of the test for classifier
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_DTM.cxx
index 3cf271fdca1f4a9a43ae56ec6f9f1c70e55d78a8..136b8e5a12011bd9e733af7ff29f9d5308d06a04 100644 (file)
@@ -21,6 +21,7 @@
 #include <HYDROData_Profile.h>
 #include <HYDROData_DTM.h>
 #include <HYDROData_Iterator.h>
+#include <HYDROData_CalculationCase.h>
 #include <Geom2d_Curve.hxx>
 #include <Geom2d_BSplineCurve.hxx>
 #include <gp_XY.hxx>
@@ -620,5 +621,45 @@ void test_HYDROData_DTM::test_garonne()
   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( DocError_OK, HYDROData_Document::Load( fname.ToCString(), 1 ) );
+
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+  
+  Handle(HYDROData_CalculationCase) aCase = 
+    Handle(HYDROData_CalculationCase)::DownCast( aDoc->FindObjectByName( "Case_1" ) );
+  CPPUNIT_ASSERT_EQUAL( Standard_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.0123, values[3], EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0123, values[4], EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0123, 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( 123, types[3] );
+  CPPUNIT_ASSERT_EQUAL( 123, types[4] );
+  CPPUNIT_ASSERT_EQUAL( 123, types[5] );
+
+  aDoc->Close();
 }
+