X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_DTM.cxx;h=9c06cc7e1fa22078972f99e30f6d2337a0d91427;hb=f50a01345c4f3761fbe64a838253558d4308931e;hp=3cf271fdca1f4a9a43ae56ec6f9f1c70e55d78a8;hpb=3874a2c420b60f4cdcfe90d3286472165ed93405;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index 3cf271fd..9c06cc7e 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -30,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,7 +48,7 @@ class DTM_item : public QGraphicsItem public: DTM_item( HYDROGUI_ShapeBathymetry* theDTM, double d ) { - Handle(AIS_PointCloud) pc = Handle(AIS_PointCloud)::DownCast( theDTM->getAISObject() ); + Handle(AIS_PointCloud) pc = Handle(AIS_PointCloud)::DownCast( theDTM->getAISObjects()[0] ); Handle(Graphic3d_ArrayOfPoints) pp = pc->GetPoints(); myBB = QRectF(); double xmin, xmax, ymin, ymax; @@ -200,7 +201,7 @@ void test_HYDROData_DTM::test_hydraulic_axis() profiles.push_back( aProfile2 ); profiles.push_back( aProfile3 ); - Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances ); + Handle(Geom2d_BSplineCurve) HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances ); CPPUNIT_ASSERT_EQUAL( false, (bool)HA.IsNull() ); CPPUNIT_ASSERT_EQUAL( 3, (int)distances.size() ); @@ -244,8 +245,8 @@ void test_HYDROData_DTM::test_profile_conversion_to_2d() aUMin2 = aUMin1, aUMax2 = aUMax1; gp_Vec2d aProfileDir; - std::vector curves1 = HYDROData_DTM::ProfileToParametric( aProfile1, aUMin1, aUMax1, aProfileDir ); - std::vector curves2 = HYDROData_DTM::ProfileToParametric( aProfile2, aUMin2, aUMax2, aProfileDir ); + std::vector curves1 = HYDROData_DTM::ProfileToParametric( aProfile1, aUMin1, aUMax1, aProfileDir ); + std::vector curves2 = HYDROData_DTM::ProfileToParametric( aProfile2, aUMin2, aUMax2, aProfileDir ); gp_Pnt2d aFirst, aLast; CPPUNIT_ASSERT_EQUAL( 3, (int)curves1.size() ); @@ -338,9 +339,9 @@ void test_HYDROData_DTM::test_profile_discretization_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 ); + HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 ); int dummy = 0; - HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy ); + HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.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 ); @@ -376,9 +377,9 @@ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); 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 ); + HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 ); int dummy = 0 ; - HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy ); + HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.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 ); @@ -431,7 +432,7 @@ void operator << ( std::ostream& s, const HYDROData_DTM::CurveUZ& c ) void test_HYDROData_DTM::test_curves_interpolation() { - HYDROData_DTM::CurveUZ A(1.0, gp_Vec2d(), 0), B(2.0, gp_Vec2d(), 0); + HYDROData_DTM::CurveUZ A(1.0, gp_Vec2d(), 0, 0), B(2.0, gp_Vec2d(), 0, 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 ) ); @@ -496,12 +497,12 @@ void test_HYDROData_DTM::test_curve_to_3d() profiles.push_back( aProfile1 ); profiles.push_back( aProfile2 ); - Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances ); + Handle(Geom2d_BSplineCurve) HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances ); HYDROData_DTM::AltitudePoints points; - HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10), 0 ); + HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10), 0, 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 ); + HYDROData_DTM::CurveUZ wid( 5.0, gp_Vec2d(-10,10), 0, 0 ); wid.push_back( HYDROData_DTM::PointUZ( 2, 5 ) ); wid.push_back( HYDROData_DTM::PointUZ( 6, 6 ) ); HYDROData_DTM::CurveTo3D( HA, mid, wid, points ); @@ -549,13 +550,13 @@ void test_HYDROData_DTM::test_presentation() CPPUNIT_ASSERT_EQUAL( 9177, (int)DTM->GetAltitudePoints().size() ); - Handle_AIS_InteractiveContext aContext = TestViewer::context(); + 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(); + Handle(AIS_ColorScale) aCS = TestViewer::colorScale(); aCS->SetMin( 0.0 ); aCS->SetMax( 5.0 ); aCS->SetNumberOfIntervals( 10 ); @@ -602,14 +603,14 @@ void test_HYDROData_DTM::test_garonne() CPPUNIT_ASSERT_EQUAL( 282338, (int)DTM->GetAltitudePoints().size() ); - Handle_AIS_InteractiveContext aContext = TestViewer::context(); + 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(); + Handle(AIS_ColorScale) aCS = TestViewer::colorScale(); aCS->SetMin( 0.0 ); aCS->SetMax( 25.0 ); aCS->SetNumberOfIntervals( 30 ); @@ -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( (int)DocError_OK, (int)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( false, aCase.IsNull() ); + std::vector 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 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 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(); } +