From: asl Date: Thu, 6 Oct 2016 13:46:53 +0000 (+0300) Subject: debug of tests for DTM X-Git-Tag: v1.6~64 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f9d37ee66fa46871478d806faa54de237225d3c6;p=modules%2Fhydro.git debug of tests for DTM --- diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 036936fc..544dd2e5 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -35,8 +35,8 @@ IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry ) IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry ) -HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv ) - : myXcurv( theXCurv ) +HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir ) + : myXcurv( theXCurv ), myProfileDir( theProfileDir ) { } @@ -49,9 +49,14 @@ double HYDROData_DTM::CurveUZ::Xcurv() const return myXcurv; } +gp_Vec2d HYDROData_DTM::CurveUZ::ProfileDir() const +{ + return myProfileDir; +} + HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator + ( const CurveUZ& c ) const { - HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv() ); + HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir() ); size_t n = size(); res.reserve( n ); for( int i=0; i HYDROData_DTM::ProfileToParametric( const Handle_HYDROData_Profile& theProfile, - double& theUMin, double& theUMax ) + double& theUMin, double& theUMax, gp_Vec2d& theDir ) { std::vector curves; // Transformation of the coordinate systems gp_Pnt aLowest; - gp_Vec2d aDir; double zmin, zmax; - GetProperties( theProfile, aLowest, aDir, false, zmin, zmax ); + GetProperties( theProfile, aLowest, theDir, false, zmin, zmax ); gp_Ax3 aStd3d( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( 1, 0, 0 ) ); - gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( aDir.X(), aDir.Y(), 0 ) ); + gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( theDir.X(), theDir.Y(), 0 ) ); gp_Trsf aTransf; aTransf.SetTransformation( aStd3d, aLocal ); @@ -422,7 +426,8 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr aUMax = -aUMin, aVMax = 1000000; - std::vector curves = ProfileToParametric( theProfile, aUMin, aUMax ); + gp_Vec2d aProfileDir; + std::vector curves = ProfileToParametric( theProfile, aUMin, aUMax, aProfileDir ); size_t n = curves.size(); if( n==0 ) @@ -442,9 +447,9 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr curves.push_back( aT2 ); int psize = ( int )( ( theMaxZ-theMinZ ) / theDDZ + 1 ); - theMidPointCurve = CurveUZ( theXCurv ); + theMidPointCurve = CurveUZ( theXCurv, aProfileDir ); theMidPointCurve.reserve( psize ); - theWidthCurve = CurveUZ( theXCurv ); + theWidthCurve = CurveUZ( theXCurv, aProfileDir ); theWidthCurve.reserve( psize ); n = curves.size(); @@ -510,12 +515,11 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi double aParam = ap.Parameter(); gp_Pnt2d point; - gp_Vec2d tangent, profile_dir; - anAdaptor.D1( aParam, point, tangent ); - profile_dir.SetCoord( tangent.Y(), -tangent.X() ); + anAdaptor.D0( aParam, point ); + gp_Vec2d profile_dir = theMidCurve.ProfileDir(); + gp_Dir tangent_n( -profile_dir.Y(), profile_dir.X(), dz ); profile_dir.Normalize(); - gp_Dir tangent_n( tangent.X(), tangent.Y(), -dz ); - //gp_Dir tangent_n( 0, 0, 1 ); + size_t n = theMidCurve.size(); double min_param = 1E+15; double max_param = -1E+15; @@ -558,7 +562,7 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi if( theLeft ) { - gp_Pnt2d left2d = point/*.Translated( min_param * profile_dir )*/; + gp_Pnt2d left2d = point.Translated( min_param * profile_dir ); gp_Pnt left( left2d.X(), left2d.Y(), z1 ); theLeft->push_back( left, tangent_n ); } @@ -601,8 +605,8 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate double zmin = max( zminA, zminB ); double zmax = max( zmaxA, zmaxB ); - CurveUZ midA(0), midB(0); - CurveUZ widA(0), widB(0); + CurveUZ midA(0, gp_Vec2d()), midB(0, gp_Vec2d()); + CurveUZ widA(0, gp_Vec2d()), widB(0, gp_Vec2d()); ProfileDiscretization( theProfileA, theXCurvA, zmin, zmax, theDDZ, midA, widA ); ProfileDiscretization( theProfileB, theXCurvB, zmin, zmax, theDDZ, midB, widB ); diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h index 4a78ed7f..81c3f1bb 100644 --- a/src/HYDROData/HYDROData_DTM.h +++ b/src/HYDROData/HYDROData_DTM.h @@ -75,16 +75,18 @@ public: class CurveUZ : public std::vector { public: - CurveUZ( double theXcurv ); + CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir = gp_Vec2d() ); ~CurveUZ(); double Xcurv() const; + gp_Vec2d ProfileDir() const; CurveUZ operator + ( const CurveUZ& ) const; CurveUZ operator * ( double ) const; private: double myXcurv; + gp_Vec2d myProfileDir; }; class Bank { @@ -111,7 +113,8 @@ protected: std::vector& theDistances ); static std::vector ProfileToParametric( const Handle_HYDROData_Profile& theProfile, - double& theUMin, double& theUMax ); + double& theUMin, double& theUMax, + gp_Vec2d& theDir ); static void GetProperties( const Handle_HYDROData_Profile& theProfile, gp_Pnt& theLowestPoint, gp_Vec2d& theDir, diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index a73f805e..5194e06e 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -111,6 +111,8 @@ SET(REFERENCE_DATA cc_int_w_3.png StreamDlg.png Profiles.xyz + DTM_1.png + DTM_2.png ) # Application tests diff --git a/src/HYDRO_tests/reference_data/DTM_1.png b/src/HYDRO_tests/reference_data/DTM_1.png index e84a2fca..1353db09 100644 Binary files a/src/HYDRO_tests/reference_data/DTM_1.png and b/src/HYDRO_tests/reference_data/DTM_1.png differ diff --git a/src/HYDRO_tests/reference_data/DTM_2.png b/src/HYDRO_tests/reference_data/DTM_2.png new file mode 100644 index 00000000..02660014 Binary files /dev/null and b/src/HYDRO_tests/reference_data/DTM_2.png differ diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index 6659e930..ad4e5f17 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -243,8 +243,9 @@ void test_HYDROData_DTM::test_profile_conversion_to_2d() aUMax1 = -aUMin1, aUMin2 = aUMin1, aUMax2 = aUMax1; - std::vector curves1 = HYDROData_DTM::ProfileToParametric( aProfile1, aUMin1, aUMax1 ); - std::vector curves2 = HYDROData_DTM::ProfileToParametric( aProfile2, aUMin2, aUMax2 ); + gp_Vec2d 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() ); @@ -346,7 +347,7 @@ void test_HYDROData_DTM::test_profile_discretization_polyline() CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aMid[1].Z, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.215, aMid[5].U, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aMid[5].Z, EPS ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.589, aMid[10].U, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.768, aMid[10].U, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aMid[10].Z, EPS ); CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() ); @@ -383,7 +384,7 @@ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aMid[1].Z, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.473, aMid[5].U, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aMid[5].Z, EPS ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.589, aMid[10].U, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.768, aMid[10].U, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aMid[10].Z, EPS ); CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() ); @@ -495,19 +496,19 @@ void test_HYDROData_DTM::test_curve_to_3d() Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances ); HYDROData_DTM::AltitudePoints points; - HYDROData_DTM::CurveUZ mid( 5.0 ); + HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10) ); mid.push_back( HYDROData_DTM::PointUZ( 0, 5 ) ); mid.push_back( HYDROData_DTM::PointUZ( 1, 6 ) ); - HYDROData_DTM::CurveUZ wid( 5.0 ); + HYDROData_DTM::CurveUZ wid( 5.0, gp_Vec2d(-10,10) ); wid.push_back( HYDROData_DTM::PointUZ( 2, 5 ) ); wid.push_back( HYDROData_DTM::PointUZ( 6, 6 ) ); HYDROData_DTM::CurveTo3D( HA, mid, wid, points ); CPPUNIT_ASSERT_EQUAL( 4, (int)points.size() ); - CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 15.434, -0.598, 5.0 ), points[0] ); - CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 14.497, -0.947, 5.0 ), points[1] ); - CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 15.903, -0.423, 6.0 ), points[2] ); - CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 13.092, -1.471, 6.0 ), points[3] ); + CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 15.673, -1.479, 5.0 ), points[0] ); + CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 14.259, -0.065, 5.0 ), points[1] ); + CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 16.380, -2.186, 6.0 ), points[2] ); + CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 12.137, 2.056, 6.0 ), points[3] ); aDoc->Close(); } @@ -544,7 +545,7 @@ void test_HYDROData_DTM::test_presentation() CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS ); DTM->Update(); - CPPUNIT_ASSERT_EQUAL( 10200, (int)DTM->GetAltitudePoints().size() ); + CPPUNIT_ASSERT_EQUAL( 10098, (int)DTM->GetAltitudePoints().size() ); Handle_AIS_InteractiveContext aContext = TestViewer::context(); HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM ); @@ -597,7 +598,7 @@ void test_HYDROData_DTM::test_garonne() CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS ); DTM->Update(); - CPPUNIT_ASSERT_EQUAL( 282336, (int)DTM->GetAltitudePoints().size() ); + CPPUNIT_ASSERT_EQUAL( 277158, (int)DTM->GetAltitudePoints().size() ); Handle_AIS_InteractiveContext aContext = TestViewer::context(); HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );