]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #670: test on copy land cover map
authorasl <asl@opencascade.com>
Tue, 17 Nov 2015 09:19:39 +0000 (12:19 +0300)
committerasl <asl@opencascade.com>
Tue, 17 Nov 2015 09:19:39 +0000 (12:19 +0300)
src/HYDRO_tests/reference_data/LCM_copied.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h

diff --git a/src/HYDRO_tests/reference_data/LCM_copied.png b/src/HYDRO_tests/reference_data/LCM_copied.png
new file mode 100644 (file)
index 0000000..72382b9
Binary files /dev/null and b/src/HYDRO_tests/reference_data/LCM_copied.png differ
index b096850b3c08a08b2df92ec0438d11fcf85ac2c0..286767a636c6bb8756086eaef4d60787adcd1d28 100644 (file)
@@ -1021,3 +1021,45 @@ void test_HYDROData_LandCoverMap::test_export_telemac()
 
   aDoc->Close();
 }
+
+void test_HYDROData_LandCoverMap::test_copy()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_LandCoverMap) aMap =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  aMap->SetName( "map_1" );
+
+  TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 30 << 10 << 20 << 20 );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
+
+  TopoDS_Face aLC2 = Face( QList<double>() << 110 << 10 << 130 << 10 << 120 << 20 );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
+
+  Handle(HYDROData_LandCoverMap) aMap2 =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  aMap->CopyTo( aMap2, true );
+
+  CPPUNIT_ASSERT_EQUAL( QString( "map_2" ), aMap2->GetName() );
+  HYDROData_LandCoverMap::Explorer anIt( aMap2 );
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "Zones de champs cultivé à végétation basse" ), anIt.StricklerType() );
+  CPPUNIT_ASSERT( anIt.Face().TShape()!=aLC1.TShape() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "Zones de champs cultivé à végétation haute" ), anIt.StricklerType() );
+  CPPUNIT_ASSERT( anIt.Face().TShape()!=aLC2.TShape() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
+
+  TopoDS_Shape aShape1 = aMap->GetShape();
+  TopoDS_Shape aShape2 = aMap2->GetShape();
+  gp_Trsf aTr;
+  aTr.SetTranslation( gp_Vec( 0, 50, 0 ) );
+  aShape2.Move( TopLoc_Location( aTr ) );
+  TestViewer::show( aShape1, AIS_Shaded, /*0,*/ true, "LCM_copied" );
+  TestViewer::show( aShape2, AIS_Shaded, /*0,*/ true, "" );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
index 36c8f6bd8ca1cd81ff47233a18488baa67760fe4..79eb35d365663346f95d23071533c6018f341793 100644 (file)
@@ -43,6 +43,7 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture
   CPPUNIT_TEST( test_transparent_prs );
   CPPUNIT_TEST( test_assign_to_calc_case );
   CPPUNIT_TEST( test_export_telemac );
+  CPPUNIT_TEST( test_copy );
 #ifdef SHP_TESTS
   CPPUNIT_TEST( test_shp_import_cyp );
   CPPUNIT_TEST( test_shp_import_clc_dec );
@@ -73,6 +74,7 @@ public:
   void test_shp_import_nld_areas();
   void test_shp_loop_back();
   void test_export_telemac();
+  void test_copy();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );