From: asl Date: Tue, 13 Oct 2015 14:55:52 +0000 (+0300) Subject: #649: draft version of the land cover map automatic test X-Git-Tag: v1.5~134 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b7783f8b6083202f887c371c74395cf7da13b990;p=modules%2Fhydro.git #649: draft version of the land cover map automatic test --- diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 95d7426c..eb977ea8 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -605,6 +605,7 @@ QString HYDROData_Entity::getPyTypeID() const case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE"; case KIND_STRICKLER_TABLE: return "KIND_STRICKLER_TABLE"; case KIND_LAND_COVER: return "KIND_LAND_COVER"; + case KIND_LAND_COVER_MAP: return "KIND_LAND_COVER_MAP"; default: return "KIND_UNKNOWN"; ///! Unrecognized object } } diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index f02cb5eb..9b715c18 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -65,6 +65,7 @@ const ObjectKind KIND_STREAM_ALTITUDE = 24; const ObjectKind KIND_OBSTACLE_ALTITUDE = 25; const ObjectKind KIND_STRICKLER_TABLE = 26; const ObjectKind KIND_LAND_COVER = 27; +const ObjectKind KIND_LAND_COVER_MAP = 28; const ObjectKind KIND_LAST = KIND_LAND_COVER; DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared) diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index a52f9328..c92eda18 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -43,6 +43,7 @@ #include "HYDROData_Zone.h" #include "HYDROData_StricklerTable.h" #include "HYDROData_LandCover.h" +#include "HYDROData_LandCoverMap.h" #include #include @@ -153,6 +154,7 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel ) case KIND_OBSTACLE_ALTITUDE: aResult = new HYDROData_ObstacleAltitude(); break; case KIND_STRICKLER_TABLE: aResult = new HYDROData_StricklerTable(); break; case KIND_LAND_COVER: aResult = new HYDROData_LandCover(); break; + case KIND_LAND_COVER_MAP: aResult = new HYDROData_LandCoverMap(); break; default: break; } diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index ee6119e5..c801780f 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -121,6 +121,15 @@ HYDROData_LandCoverMap::~HYDROData_LandCoverMap() { } +/** + Get object's kind + @return object's kind +*/ +const ObjectKind HYDROData_LandCoverMap::GetKind() const +{ + return KIND_LAND_COVER_MAP; +} + /** Import the land cover map from QGIS @param theFileName the name of file diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index 7d9939cf..bcc4c0c9 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -44,6 +44,7 @@ protected: DataTag_Types, }; +public: class Iterator { public: @@ -66,6 +67,8 @@ protected: HYDROData_LandCoverMap(); ~HYDROData_LandCoverMap(); + virtual const ObjectKind GetKind() const; + bool ImportQGIS( const QString& theFileName ); bool ExportQGIS( const QString& theFileName ) const; bool ExportTelemac( const QString& theFileName ) const; diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 657f9a17..9437e762 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -7,6 +7,7 @@ set(PROJECT_HEADERS test_HYDROData_Entity.h test_HYDROData_Image.h test_HYDROData_Iterator.h + test_HYDROData_LandCoverMap.h test_HYDROData_OperationsFactory.h test_HYDROData_PolylineXY.h test_HYDROData_Profile.h @@ -22,6 +23,7 @@ set(PROJECT_SOURCES test_HYDROData_Entity.cxx test_HYDROData_Image.cxx test_HYDROData_Iterator.cxx + test_HYDROData_LandCoverMap.cxx test_HYDROData_Main.cxx test_HYDROData_OperationsFactory.cxx test_HYDROData_PolylineXY.cxx @@ -29,8 +31,6 @@ set(PROJECT_SOURCES test_HYDROData_StricklerTable.cxx test_HYDROGUI_ListModel.cxx - ${EXTERNAL_FILES} - TestViewer.cxx ) @@ -71,7 +71,9 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../shapelib ) -add_executable( HYDROData_tests ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +source_group( "External files" FILES ${EXTERNAL_FILES} ) + +add_executable( HYDROData_tests ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${EXTERNAL_FILES} ) target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib ) IF( ${WIN32} ) diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx new file mode 100644 index 00000000..d81d898c --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -0,0 +1,74 @@ +// 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 + +TopoDS_Edge Spline( bool isClosed, double x, double y, ... ) +{ + va_list anArgs; + va_start( anArgs, y ); + QList aPointsList; + while( true ) + { + double x = va_arg( anArgs, double ); + if( x <= 0 ) + break; + double y = va_arg( anArgs, double ); + gp_Pnt aPnt( x, y, 0 ); + aPointsList.append( aPnt ); + } + va_end( anArgs ); + + int n = aPointsList.size(); + Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n ); + for( int i=1; i<=n; i++ ) + aPointsArray->SetValue( i, aPointsList[i-1] ); + + GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 ); + anInterpolator.Perform(); + bool aResult = anInterpolator.IsDone() == Standard_True; + if( aResult ) + { + Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve(); + return BRepBuilderAPI_MakeEdge( aCurve ).Edge(); + } + else + return TopoDS_Edge(); +} + +void test_HYDROData_LandCoverMap::test_local_partition() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_LandCoverMap) aMap = + Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); + + CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); + + + + aDoc->Close(); +} + diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.h b/src/HYDRO_tests/test_HYDROData_LandCoverMap.h new file mode 100644 index 00000000..15628e53 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.h @@ -0,0 +1,40 @@ +// 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 +// + +#ifdef WIN32 + #pragma warning( disable: 4251 ) +#endif + +#include + +class test_HYDROData_LandCoverMap : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( test_HYDROData_LandCoverMap ); + CPPUNIT_TEST( test_local_partition ); + CPPUNIT_TEST_SUITE_END(); + +public: + void test_local_partition(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_LandCoverMap, "HYDROData_LandCoverMap" ); + +#ifdef WIN32 + #pragma warning( default: 4251 ) +#endif