From: isn Date: Thu, 25 Apr 2019 10:32:58 +0000 (+0300) Subject: tests for DTM/warnings X-Git-Tag: SH_V2_2_0~99^2~14^2^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8a4fba27faa30e582f7256754ef09ae3ea81910f;p=modules%2Fhydro.git tests for DTM/warnings --- diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 7349737f..7cf256fc 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -824,7 +824,7 @@ void HYDROData_DTM::ProfileDiscretization( const Handle(HYDROData_Profile)& theP for( double z1 = theMinZ; z1 <= theMaxZ; z1 += theDDZ ) { Handle(Geom2d_Line) aLine = new Geom2d_Line( gp_Pnt2d( 0, z1 ), gp_Dir2d( 1, 0 ) ); - std::set intersections; + std::set intersections; //TODO the solutions should be treated with some epsilon~1e-8 (computation error of intersector) Bnd_Box2d intersect_bndbox; for( size_t i = 0; i < n; i++ ) { diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index 48a47069..be6e80ef 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -670,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(1); + + { + 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(); +} diff --git a/src/HYDRO_tests/test_HYDROData_DTM.h b/src/HYDRO_tests/test_HYDROData_DTM.h index 57413786..5b0d0d28 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.h +++ b/src/HYDRO_tests/test_HYDROData_DTM.h @@ -32,6 +32,7 @@ class test_HYDROData_DTM : public CppUnit::TestFixture CPPUNIT_TEST( test_presentation ); CPPUNIT_TEST( test_garonne ); CPPUNIT_TEST( test_classifier_1 ); + CPPUNIT_TEST( test_profile_discretization_warnings ); CPPUNIT_TEST_SUITE_END(); public: @@ -49,6 +50,7 @@ public: void test_presentation(); void test_garonne(); void test_classifier_1(); + void test_profile_discretization_warnings(); }; CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_DTM );