Salome HOME
#649: draft version of the land cover map automatic test
authorasl <asl@opencascade.com>
Tue, 13 Oct 2015 14:55:52 +0000 (17:55 +0300)
committerasl <asl@opencascade.com>
Tue, 13 Oct 2015 14:55:52 +0000 (17:55 +0300)
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_LandCoverMap.h [new file with mode: 0644]

index 95d7426c7bfc99a04e8e85abc2fa5d5258c34eaa..eb977ea8270007301a696b820b4db1db93fac6ed 100644 (file)
@@ -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
   }
 }
index f02cb5eb49fad82dade8413eda0e6e5f12e0042f..9b715c18ea53064829f98f47a15b3a488389fffa 100644 (file)
@@ -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)
index a52f932836fc2536b5be1dc6cba83c9ea9cc86c2..c92eda184b1f50141dbf8d2f09df8b4dfe960b6f 100644 (file)
@@ -43,6 +43,7 @@
 #include "HYDROData_Zone.h"
 #include "HYDROData_StricklerTable.h"
 #include "HYDROData_LandCover.h"
+#include "HYDROData_LandCoverMap.h"
 
 #include <TDataStd_Name.hxx>
 #include <TDataStd_NamedData.hxx>
@@ -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;
   }
 
index ee6119e5b71bd4551e788abd5e05cee5427766d3..c801780fd80cbb46cdd3d5aa249cecebac203bf1 100644 (file)
@@ -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
index 7d9939cfe3c870ba1c43290bc1e4000871ae5405..bcc4c0c9196f9f93acf42d0d4883530f46b7b44d 100644 (file)
@@ -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;
index 657f9a173b2fc15740640b88cdd26aff3a01e985..9437e76295b88ff6e64dcbd841e34c9198e2fba7 100644 (file)
@@ -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 (file)
index 0000000..d81d898
--- /dev/null
@@ -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 <test_HYDROData_LandCoverMap.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_LandCoverMap.h>
+#include <TopoDS_Edge.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <GeomAPI_Interpolate.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <stdarg.h>
+
+TopoDS_Edge Spline( bool isClosed, double x, double y, ... )
+{
+  va_list anArgs;
+  va_start( anArgs, y );
+  QList<gp_Pnt> 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 (file)
index 0000000..15628e5
--- /dev/null
@@ -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 <cppunit/extensions/HelperMacros.h>
+
+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