From abdcba0f2ee048bf3c1f6073ef7fea4f0b200dcb Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 6 Sep 2016 16:13:29 +0300 Subject: [PATCH] draft version of the DTM object --- src/HYDROData/CMakeLists.txt | 4 +- src/HYDROData/HYDROData_Bathymetry.cxx | 1 + src/HYDROData/HYDROData_Bathymetry.h | 10 +- src/HYDROData/HYDROData_DTM.cxx | 191 +++++++++++++++++++ src/HYDROData/HYDROData_DTM.h | 86 +++++++++ src/HYDROData/HYDROData_Entity.h | 1 + src/HYDROData/HYDROData_Iterator.cxx | 2 + src/HYDROData/HYDROData_Object.cxx | 2 +- src/HYDROData/HYDROData_PolylineOperator.cxx | 4 +- src/HYDROData/HYDROData_PolylineXY.cxx | 6 +- src/HYDROData/HYDROData_Profile.h | 1 - src/HYDROData/HYDROData_TopoCurve.cxx | 6 +- src/HYDRO_tests/CMakeLists.txt | 2 + src/HYDRO_tests/ExternalFiles.cmake | 1 + src/HYDRO_tests/test_HYDROData_DTM.cxx | 109 +++++++++++ src/HYDRO_tests/test_HYDROData_DTM.h | 37 ++++ src/HYDRO_tests/test_HYDROData_Main.cxx | 4 +- 17 files changed, 446 insertions(+), 21 deletions(-) create mode 100644 src/HYDROData/HYDROData_DTM.cxx create mode 100644 src/HYDROData/HYDROData_DTM.h create mode 100644 src/HYDRO_tests/test_HYDROData_DTM.cxx create mode 100644 src/HYDRO_tests/test_HYDROData_DTM.h diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 86edacf8..e831498a 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -63,7 +63,7 @@ set(PROJECT_HEADERS HYDROData_ShapeFile.h HYDROData_LandCoverMap.h HYDROData_LCM_FaceClassifier.h - + HYDROData_DTM.h ) set(PROJECT_SOURCES @@ -125,7 +125,7 @@ set(PROJECT_SOURCES HYDROData_ShapeFile.cxx HYDROData_LandCoverMap.cxx HYDROData_LCM_FaceClassifier.cxx - + HYDROData_DTM.cxx ) add_definitions( diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index db677852..22b00788 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -20,6 +20,7 @@ #include "HYDROData_Document.h" #include "HYDROData_Tool.h" #include "HYDROData_PolylineXY.h" +#include "HYDROData_QuadtreeNode.hxx" #include #include diff --git a/src/HYDROData/HYDROData_Bathymetry.h b/src/HYDROData/HYDROData_Bathymetry.h index 1fed12a2..1cffaaf2 100644 --- a/src/HYDROData/HYDROData_Bathymetry.h +++ b/src/HYDROData/HYDROData_Bathymetry.h @@ -20,18 +20,14 @@ #define HYDROData_Bathymetry_HeaderFile #include "HYDROData_IAltitudeObject.h" -#include "HYDROData_QuadtreeNode.hxx" - -#ifndef LIGHT_MODE -#include -#include -#endif class QFile; class gp_XYZ; class gp_XY; class Handle_HYDROData_PolylineXY; - +class HYDROData_QuadtreeNode; +class vtkPolyData; +class vtkIdList; DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject) diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx new file mode 100644 index 00000000..a80edf22 --- /dev/null +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -0,0 +1,191 @@ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry ) +IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry ) + +HYDROData_DTM::HYDROData_DTM() +{ +} + +HYDROData_DTM::~HYDROData_DTM() +{ +} + + +void GetProperties( const Handle_HYDROData_Profile& theProfile, + gp_Pnt& theLowestPoint, + gp_Vec2d& theDir, + bool isNormalDir ) +{ + theLowestPoint = theProfile->GetBottomPoint(); + + gp_XY aLeft, aRight; + theProfile->GetLeftPoint( aLeft, true, true ); + theProfile->GetRightPoint( aRight, true, true ); + double x = aRight.X()-aLeft.X(); + double y = aRight.Y()-aLeft.Y(); + if( isNormalDir ) + theDir = gp_Vec2d( -y, x ); + else + theDir = gp_Vec2d( x, y ); +} + +inline gp_Pnt2d To2D( const gp_Pnt& thePnt, const gp_Trsf& theTr ) +{ + gp_Pnt p = thePnt.Transformed( theTr ); + return gp_Pnt2d( p.X(), p.Z() ); +} + +Handle(TColgp_HArray1OfPnt2d) To2D( const TColgp_Array1OfPnt& thePoints, const gp_Trsf& theTr ) +{ + int low = thePoints.Lower(), up = thePoints.Upper(); + Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( low, up ); + for( int i=low; i<=up; i++ ) + points->SetValue( i, To2D( thePoints.Value( i ), theTr ) ); + return points; +} + +Handle(Geom2d_Curve) CurveTo2D( const Handle(Geom_Curve)& theCurve, + Standard_Real theFirst, Standard_Real theLast, + const gp_Trsf& theTr ) +{ + if( theCurve->IsKind( STANDARD_TYPE( Geom_Line ) ) ) + { + gp_Pnt aFirstPnt, aLastPnt; + theCurve->D0( theFirst, aFirstPnt ); + theCurve->D0( theLast, aLastPnt ); + + gp_Pnt2d + aFirst2d = To2D( aFirstPnt, theTr ), + aLast2d = To2D( aLastPnt, theTr ); + + gp_Vec2d dir( aFirst2d, aLast2d ); + Handle_Geom2d_Line aLine2d = new Geom2d_Line( aFirst2d, gp_Dir2d( dir.X(), dir.Y() ) ); + return new Geom2d_TrimmedCurve( aLine2d, 0, aLast2d.Distance( aFirst2d ) ); + } + + if( theCurve->IsKind( STANDARD_TYPE( Geom_BSplineCurve ) ) ) + { + Handle(Geom_BSplineCurve) aSpline = Handle(Geom_BSplineCurve)::DownCast( theCurve ); + + Handle(TColgp_HArray1OfPnt2d) poles = To2D( aSpline->Poles(), theTr ); + const TColStd_Array1OfReal& knots = aSpline->Knots(); + const TColStd_Array1OfInteger& multiplicities = aSpline->Multiplicities(); + int aDegree = aSpline->Degree(); + + return new Geom2d_BSplineCurve( poles->Array1(), knots, multiplicities, aDegree ); + } + + return Handle(Geom2d_Curve)(); +} + +Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis( + const std::vector& theProfiles ) +{ + size_t n = theProfiles.size(); + Handle_Geom2d_BSplineCurve aResult; + + Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, (int)n ); + TColgp_Array1OfVec2d tangents( 1, (int)n ); + Handle(TColStd_HArray1OfBoolean) flags = new TColStd_HArray1OfBoolean( 1, (int)n ); + + for( size_t i = 1; i <= n; i++ ) + { + Handle_HYDROData_Profile aProfile = theProfiles[i-1]; + gp_Pnt aLowest; + gp_Vec2d aTangent; + GetProperties( aProfile, aLowest, aTangent, true ); + aTangent.Normalize(); + + points->SetValue( (int)i, gp_Pnt2d( aLowest.X(), aLowest.Y() ) ); + tangents.SetValue( (int)i, aTangent ); + flags->SetValue( (int)i, Standard_True ); + } + + Geom2dAPI_Interpolate anInterpolator( points, Standard_False, Standard_False ); + anInterpolator.Load( tangents, flags ); + anInterpolator.Perform(); + if( anInterpolator.IsDone() ) + aResult = anInterpolator.Curve(); + return aResult; +} + +std::vector HYDROData_DTM::ProfileToParametric( const Handle_HYDROData_Profile& theProfile ) +{ + std::vector curves; + theProfile->Update(); + + // Transformation of the coordinate systems + gp_Pnt aLowest; + gp_Vec2d aDir; + GetProperties( theProfile, aLowest, aDir, false ); + + 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_Trsf aTransf; + aTransf.SetTransformation( aStd3d, aLocal ); + + // Iteration via edges + TopoDS_Wire aWire = TopoDS::Wire( theProfile->GetShape3D() ); + TopExp_Explorer anExp( aWire, TopAbs_EDGE ); + for( ; anExp.More(); anExp.Next() ) + { + // Extract an edge from wire + TopoDS_Edge anEdge = TopoDS::Edge( anExp.Current() ); + + // Extract a curve corresponding to the edge + TopLoc_Location aLoc; + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aLoc, aFirst, aLast ); + + // Convert the curve to 2d CS + Handle(Geom2d_Curve) aCurve2d = CurveTo2D( aCurve, aFirst, aLast, aTransf ); + if( !aCurve2d.IsNull() ) + curves.push_back( aCurve2d ); + } + return curves; +} + +void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& theProfile, + double theMinZ, double theMaxZ, double theDDZ, + CurveUZ& theMidPointCurve, + CurveUZ& theWidthCurve ) +{ + /*for( double z = theMinZ; z<=theMaxZ; z += theDDZ ) + { + + }*/ +} + +void HYDROData_DTM::Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, + int theNbSteps, std::vector& theInterpolation ) +{ +} + +void HYDROData_DTM::CurveTo3d( const CurveUZ& theCurve, const CurveUZ& theCurveB, + int theNbSteps, std::vector& theInterpolation ) +{ +} diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h new file mode 100644 index 00000000..a91357ed --- /dev/null +++ b/src/HYDROData/HYDROData_DTM.h @@ -0,0 +1,86 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROData_DTM_HeaderFile +#define HYDROData_DTM_HeaderFile + +#include "HYDROData_Bathymetry.h" +#include + +class Handle_HYDROData_Profile; +class Handle_Geom2d_BSplineCurve; +class Handle_Geom2d_Curve; + +DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry ) + +/**\class HYDROData_DTM + * \brief Class that represents the Digital Terrain Model + */ +class HYDROData_DTM : public HYDROData_Bathymetry +{ +protected: + /** + * Enumeration of tags corresponding to the persistent object parameters. + */ + enum DataTag + { + DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve + }; + +public: + DEFINE_STANDARD_RTTI( HYDROData_DTM ); + +protected: + friend class HYDROData_Iterator; + friend class test_HYDROData_DTM; + + HYDRODATA_EXPORT HYDROData_DTM(); + virtual HYDRODATA_EXPORT ~HYDROData_DTM(); + + struct PointUZ + { + double U; + double Z; + }; + class CurveUZ : public std::vector + { + public: + CurveUZ( double theXCurv ); + ~CurveUZ(); + + private: + double Xcurv; + }; + + static Handle_Geom2d_BSplineCurve CreateHydraulicAxis( const std::vector& theProfiles ); + + static std::vector ProfileToParametric( const Handle_HYDROData_Profile& theProfile ); + + static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile, + double theMinZ, double theMaxZ, double theDDZ, + CurveUZ& theMidPointCurve, + CurveUZ& theWidthCurve ); + + static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, + int theNbSteps, std::vector& theInterpolation ); + + static void CurveTo3d( const CurveUZ& theCurve, const CurveUZ& theCurveB, + int theNbSteps, std::vector& theInterpolation ); +}; + +#endif diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index 51186e60..a38e771d 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -65,6 +65,7 @@ const ObjectKind KIND_STRICKLER_TABLE = 26; const ObjectKind KIND_LAND_COVER_OBSOLETE = 27; const ObjectKind KIND_CHANNEL_ALTITUDE = 28; const ObjectKind KIND_LAND_COVER_MAP = 29; +const ObjectKind KIND_DTM = 30; const ObjectKind KIND_LAST = KIND_LAND_COVER_MAP; DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared) diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 09c6dee2..8382162a 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -44,6 +44,7 @@ #include "HYDROData_VisualState.h" #include "HYDROData_Zone.h" #include "HYDROData_StricklerTable.h" +#include "HYDROData_DTM.h" #include #include @@ -160,6 +161,7 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel ) case KIND_LAND_COVER_OBSOLETE: break; case KIND_CHANNEL_ALTITUDE: aResult = new HYDROData_ChannelAltitude(); break; case KIND_LAND_COVER_MAP: aResult = new HYDROData_LandCoverMap(); break; + case KIND_DTM: aResult = new HYDROData_DTM(); break; default: break; } diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 240db460..f2570cfe 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -313,7 +313,7 @@ void HYDROData_Object::checkAndSetAltitudeObject() Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); ObjectKind anAltitudeObjectType = getAltitudeObjectType(); - DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType); + //DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType); if ( anAltitudeObjectType == KIND_UNKNOWN ) return; // No need to create altitude object diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index c311866a..fd4a5edc 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -236,11 +236,11 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD aSplitCurves.end(); for (int iw=0; aCIt != aLastCIt; ++aCIt, iw++) { - std::stringstream brepName; + /*std::stringstream brepName; brepName << "theSplitWire_"; brepName << iw; brepName << ".brep"; - BRepTools::Write(aCIt->Wire() , brepName.str().c_str() ); + BRepTools::Write(aCIt->Wire() , brepName.str().c_str() );*/ aResult.push_back(aCIt->Wire()); } } diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index 6013e653..fc975249 100644 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -624,9 +624,9 @@ bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape, if ( theShape.IsNull() ) return false; - std::string brepName = this->GetName().toStdString(); - brepName += ".brep"; - BRepTools::Write( theShape, brepName.c_str() ); + //std::string brepName = this->GetName().toStdString(); + //brepName += ".brep"; + //BRepTools::Write( theShape, brepName.c_str() ); RemoveSections(); diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index 5bcc450d..f35b5c00 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -20,7 +20,6 @@ #define HYDROData_Profile_HeaderFile #include "HYDROData_Object.h" - #include "HYDROData_ProfileUZ.h" DEFINE_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object) diff --git a/src/HYDROData/HYDROData_TopoCurve.cxx b/src/HYDROData/HYDROData_TopoCurve.cxx index a69395d4..c08d6bf6 100644 --- a/src/HYDROData/HYDROData_TopoCurve.cxx +++ b/src/HYDROData/HYDROData_TopoCurve.cxx @@ -660,9 +660,9 @@ int HYDROData_TopoCurve::Intersect( const TopoDS_Wire& theWire, std::deque >& theParameters) const { - std::string brepName = "theWireToIntersect"; - brepName += ".brep"; - BRepTools::Write( theWire, brepName.c_str() ); + //std::string brepName = "theWireToIntersect"; + //brepName += ".brep"; + //BRepTools::Write( theWire, brepName.c_str() ); int aIntCount = 0; theParameters.resize(myEdges.size()); diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 8ff5e1c0..47a3e942 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -20,6 +20,7 @@ set(PROJECT_HEADERS test_HYDROGUI_Shape.h test_HYDROGUI_LandCoverMapDlg.h test_Dependencies.h + test_HYDROData_DTM.h TestShape.h TestViewer.h @@ -41,6 +42,7 @@ set(PROJECT_SOURCES test_HYDROData_Profile.cxx test_HYDROData_ShapeFile.cxx test_HYDROData_StricklerTable.cxx + test_HYDROData_DTM.cxx test_HYDROGUI_ListModel.cxx test_HYDROGUI_Shape.cxx test_HYDROGUI_LandCoverMapDlg.cxx diff --git a/src/HYDRO_tests/ExternalFiles.cmake b/src/HYDRO_tests/ExternalFiles.cmake index 998b5c7d..b137e502 100644 --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@ -58,6 +58,7 @@ set( EXTERNAL_FILES ../HYDROData/HYDROData_QuadTree.cxx ../HYDROData/HYDROData_QuadTreeNode.cxx ../HYDROData/HYDROData_LCM_FaceClassifier.cxx + ../HYDROData/HYDROData_DTM.cxx ../HYDROGUI/HYDROGUI_ListModel.cxx ../HYDROGUI/HYDROGUI_DataObject.cxx diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx new file mode 100644 index 00000000..d1189c74 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -0,0 +1,109 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const double EPS = 1E-3; + +void test_HYDROData_DTM::test_creation() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_DTM) DTM = + Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) ); + + CPPUNIT_ASSERT_EQUAL( false, (bool)DTM.IsNull() ); + + aDoc->Close(); +} + +void test_HYDROData_DTM::test_profile_conversion_to_2d() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_Profile) aProfile1 = + Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); + + Handle(HYDROData_Profile) aProfile2 = + Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); + + NCollection_Sequence points; + points.Append( gp_XY( 0.0, 5.0 ) ); + points.Append( gp_XY( 1.0, 1.0 ) ); + points.Append( gp_XY( 1.5, 0.0 ) ); + points.Append( gp_XY( 4.0, 4.0 ) ); + + aProfile1->SetParametricPoints( points ); + aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE ); + aProfile1->SetLeftPoint( gp_XY( 10, 10 ) ); + aProfile1->SetRightPoint( gp_XY( 20, 20 ) ); + + aProfile2->SetParametricPoints( points ); + aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE ); + aProfile2->SetLeftPoint( gp_XY( 10, 10 ) ); + aProfile2->SetRightPoint( gp_XY( 20, 20 ) ); + + std::vector curves1 = HYDROData_DTM::ProfileToParametric( aProfile1 ); + std::vector curves2 = HYDROData_DTM::ProfileToParametric( aProfile2 ); + + gp_Pnt2d aFirst, aLast; + CPPUNIT_ASSERT_EQUAL( 3, (int)curves1.size() ); + curves1[0]->D0( curves1[0]->FirstParameter(), aFirst ); + curves1[0]->D0( curves1[0]->LastParameter(), aLast ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aFirst.X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aFirst.Y(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aLast.X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, aLast.Y(), EPS ); + curves1[1]->D0( curves1[1]->FirstParameter(), aFirst ); + curves1[1]->D0( curves1[1]->LastParameter(), aLast ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aFirst.X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, aFirst.Y(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aLast.X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aLast.Y(), EPS ); + curves1[2]->D0( curves1[2]->FirstParameter(), aFirst ); + curves1[2]->D0( curves1[2]->LastParameter(), aLast ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aFirst.X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aFirst.Y(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 8.839, aLast.X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 4.0, aLast.Y(), EPS ); + + CPPUNIT_ASSERT_EQUAL( 1, (int)curves2.size() ); + Handle(Geom2d_BSplineCurve) aBSpline = Handle(Geom2d_BSplineCurve)::DownCast( curves2[0] ); + CPPUNIT_ASSERT_EQUAL( false, (bool)aBSpline.IsNull() ); + const TColgp_Array1OfPnt2d& poles = aBSpline->Poles(); + CPPUNIT_ASSERT_EQUAL( 1, (int)poles.Lower() ); + CPPUNIT_ASSERT_EQUAL( 8, (int)poles.Upper() ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, poles.Value( 1 ).X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, poles.Value( 1 ).Y(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -4.125, poles.Value( 2 ).X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.667, poles.Value( 2 ).Y(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -3.150, poles.Value( 3 ).X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.120, poles.Value( 3 ).Y(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.242, poles.Value( 4 ).X(), EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.574, poles.Value( 4 ).Y(), EPS ); + + aDoc->Close(); +} diff --git a/src/HYDRO_tests/test_HYDROData_DTM.h b/src/HYDRO_tests/test_HYDROData_DTM.h new file mode 100644 index 00000000..30eac980 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_DTM.h @@ -0,0 +1,37 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +class test_HYDROData_DTM : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( test_HYDROData_DTM ); + CPPUNIT_TEST( test_creation ); + CPPUNIT_TEST( test_profile_conversion_to_2d ); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() {} + void tearDown() {} + + void test_creation(); + void test_profile_conversion_to_2d(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_DTM ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_DTM, "HYDROData_DTM" ); diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index c6a979d0..d50bdcf7 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -68,8 +68,8 @@ int main( int argc, char* argv[] ) CppUnit::TestFactoryRegistry::getRegistry(); // Add the top suite to the test runner TestLib_Runner runner; - //QString aPath = qgetenv( "HYDRO_SRC_DIR" ) + "/src/tests.cfg"; - //runner.Load( aPath.toStdString() ); + QString aPath = qgetenv( "HYDRO_SRC_DIR" ) + "/src/tests.cfg"; + runner.Load( aPath.toStdString() ); runner.addTest( registry.makeTest() ); try { -- 2.39.2