Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_LandCoverMap.cxx
index e474ad9ab0f1136c600c77a8c3f180a1626ccfff..1ae4bd40d0eb23d0ee5dcc620fec4370bbda463a 100644 (file)
@@ -19,6 +19,7 @@
 #include <test_HYDROData_LandCoverMap.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_LandCoverMap.h>
+#include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_PolylineXY.h>
 #include <HYDROData_StricklerTable.h>
 #include <HYDROData_Tool.h>
@@ -34,6 +35,7 @@
 #include <QString>
 #include <QColor>
 #include <QMap>
+#include <QDir>
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
 
@@ -441,17 +443,13 @@ void test_HYDROData_LandCoverMap::test_import_dbf()
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
   
   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
-  QMap<int, int> Inds;
-  Inds.insert(1, 1);
-  Inds.insert(2, 2);
-  Inds.insert(3, 3);
+  QList<int> Inds = QList<int>() << 1 << 2 << 3;
   aMap->ImportDBF(aFileName, "TESTFIELD1", aDBFV, aST, Inds);
   HYDROData_LandCoverMap::Iterator anIt( aMap );
  
-  CPPUNIT_ASSERT_EQUAL(true, "water" == anIt.StricklerType());
+  CPPUNIT_ASSERT_EQUAL( QString( "forest" ), anIt.StricklerType() );
   anIt.Next();
-  CPPUNIT_ASSERT_EQUAL(true, "forest" == anIt.StricklerType());
-
+  CPPUNIT_ASSERT_EQUAL( QString( "road" ), anIt.StricklerType() );
 }
 
 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
@@ -524,3 +522,69 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
   aDoc->Close();
 }
 
+void test_HYDROData_LandCoverMap::test_dump_python()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_LandCoverMap) aMap =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  aMap->SetName( "test_LCM" );
+
+  CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
+
+  TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
+
+  TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
+                                              44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
+                                             128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
+                                              31 << 114 );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
+
+  TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
+                                            127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
+
+  QString aTmpPath = QDir::tempPath() + "/lc_dump.py";
+  CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
+
+  //TODO: compare files
+}
+
+void test_HYDROData_LandCoverMap::test_transparent_prs()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_StricklerTable) aTable =
+    Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+  CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
+
+  Handle(HYDROData_PolylineXY) aPoly =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPoly->AddSection( "", HYDROData_PolylineXY::SECTION_SPLINE, true );
+  aPoly->AddPoint( 0, gp_XY( 0, 0 ) );
+  aPoly->AddPoint( 0, gp_XY( 20, 0 ) );
+  aPoly->AddPoint( 0, gp_XY( 10, 10 ) );
+  aPoly->Update();
+
+  Handle(HYDROData_ImmersibleZone) aZone =
+    Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) );
+  aZone->SetPolyline( aPoly );
+  aZone->Update();
+
+  Handle(HYDROData_LandCoverMap) aMap =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  aMap->LocalPartition( Face( QList<double>() << 1 << 1 << 10 << 10 << 10 << 20 ), "Zones de champs cultivé à végétation haute" );
+  aMap->LocalPartition( Face( QList<double>() << 5 << 5 << 10 << 5 << 10 << 8 << 5 << 12 << 5 << 8 ), "Zones de champs cultivé à végétation haute" );
+  aMap->SetName( "test_LCM" );
+
+  TestViewer::show( aZone->GetTopShape(), AIS_Shaded, true, "LandCoverMap_TransparentPrs" );
+
+  Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
+  aPrs->SetTable( aTable );
+  aPrs->SetTransparency( 0.5 );
+  TestViewer::show( aPrs, AIS_Shaded, 0, true, "" );
+
+  CPPUNIT_ASSERT_IMAGES
+}