X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_DTM.cxx;h=9cc0ea758876f3975397cf6964ab1f61201ac986;hb=eac08495379067b7417f2856e174b4f1ae80e538;hp=51de524a2aee4101d9c1956ba8114258b7917569;hpb=77da7ec61fd91293d259edd5ee22fcde7d4e6a0b;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index 51de524a..9cc0ea75 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -38,6 +38,8 @@ #include #include #include +#include +#include const double EPS = 1E-3; @@ -158,7 +160,7 @@ void test_HYDROData_DTM::setUp() void test_HYDROData_DTM::test_creation() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) ); @@ -170,7 +172,7 @@ void test_HYDROData_DTM::test_creation() void test_HYDROData_DTM::test_hydraulic_axis() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_Profile) aProfile1 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); @@ -223,7 +225,7 @@ void test_HYDROData_DTM::test_hydraulic_axis() void test_HYDROData_DTM::test_profile_conversion_to_2d() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_Profile) aProfile1 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); @@ -294,7 +296,7 @@ void test_HYDROData_DTM::test_profile_conversion_to_2d() void test_HYDROData_DTM::test_profile_properties() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); @@ -330,7 +332,7 @@ void test_HYDROData_DTM::test_profile_properties() void test_HYDROData_DTM::test_profile_discretization_polyline() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); @@ -342,7 +344,8 @@ void test_HYDROData_DTM::test_profile_discretization_polyline() 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, 5.0, 0.5, aMid, aWid, dummy ); + QSet warnings; + HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings ); 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 ); @@ -368,7 +371,7 @@ void test_HYDROData_DTM::test_profile_discretization_polyline() void test_HYDROData_DTM::test_profile_discretization_spline() { -Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); +Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); @@ -380,7 +383,8 @@ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); 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, 5.0, 0.5, aMid, aWid, dummy ); + QSet warnings; + HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings ); 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 ); @@ -475,7 +479,7 @@ void test_HYDROData_DTM::test_curves_interpolation() void test_HYDROData_DTM::test_curve_to_3d() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_Profile) aProfile1 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); @@ -519,7 +523,7 @@ void test_HYDROData_DTM::test_curve_to_3d() void test_HYDROData_DTM::test_presentation() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) ); @@ -574,7 +578,7 @@ void test_HYDROData_DTM::test_presentation() void test_HYDROData_DTM::test_garonne() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); fname += "/Profiles.xyz"; @@ -630,9 +634,9 @@ 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 ) ); + CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString() ) ); - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); Handle(HYDROData_CalculationCase) aCase = Handle(HYDROData_CalculationCase)::DownCast( aDoc->FindObjectByName( "Case_1" ) ); @@ -666,3 +670,82 @@ void test_HYDROData_DTM::test_classifier_1() 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 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 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 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 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 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 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(); +}