Salome HOME
automatic test for DTM, refs issue #1066
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_DTM.cxx
index 3a84e0bc8f86ad9f8e83cc288ad24c15f38dcea1..c9934653c6cc5a1d3af64f02cf33d60b13b08d0c 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>
@@ -305,7 +306,7 @@ void test_HYDROData_DTM::test_profile_properties()
   gp_Pnt lp;
   gp_Vec2d dd;
   double zmin, zmax;
-  HYDROData_DTM::GetProperties( aProfile, lp, dd, false, zmin, zmax );
+  HYDROData_DTM::GetProperties( aProfile, lp, dd, 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 );
@@ -314,14 +315,14 @@ void test_HYDROData_DTM::test_profile_properties()
   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 );
/* 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 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, zmax, EPS );*/
 
   aDoc->Close();
 }
@@ -553,6 +554,7 @@ void test_HYDROData_DTM::test_presentation()
   HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
   aBathPrs->update( true, false );
 
+  bool ColorScaleIsDisp = TestViewer::ColorScaleIsDisplayed();
   TestViewer::showColorScale( true );
   Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
   aCS->SetMin( 0.0 );
@@ -563,6 +565,7 @@ void test_HYDROData_DTM::test_presentation()
   QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
   CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_1" );
   delete aBathPrs;
+  TestViewer::showColorScale( ColorScaleIsDisp );
 
   aDoc->Close();
 }
@@ -590,8 +593,6 @@ void test_HYDROData_DTM::test_garonne()
 
   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 );
@@ -601,10 +602,12 @@ void test_HYDROData_DTM::test_garonne()
   DTM->Update();
   
   CPPUNIT_ASSERT_EQUAL( 282338, (int)DTM->GetAltitudePoints().size() ); 
-
+  
   Handle_AIS_InteractiveContext aContext = TestViewer::context();
   HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
   aBathPrs->update( true, false );
+  
+  bool ColorScaleIsDisp = TestViewer::ColorScaleIsDisplayed();
 
   TestViewer::showColorScale( true );
   Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
@@ -615,7 +618,33 @@ void test_HYDROData_DTM::test_garonne()
   
   QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
   CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_2" );
+  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 ) );
+
+  std::vector<double> values = aCase->GetStricklerCoefficientForPoints( points, 0.0, true );
+  CPPUNIT_ASSERT_EQUAL( 3, (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 );
 
   aDoc->Close();
 }
+