X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_LandCoverMap.cxx;h=1ae4bd40d0eb23d0ee5dcc620fec4370bbda463a;hb=9c947f35615e69e9e54a8c4b074dd1f2be13689c;hp=e474ad9ab0f1136c600c77a8c3f180a1626ccfff;hpb=4de6eab0446e075de57f40eb7465c740ec428c7d;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index e474ad9a..1ae4bd40 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include @@ -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 Inds; - Inds.insert(1, 1); - Inds.insert(2, 2); - Inds.insert(3, 3); + QList Inds = QList() << 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() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); + + TopoDS_Face aLC2 = Face( QList() << 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() << 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() << 1 << 1 << 10 << 10 << 10 << 20 ), "Zones de champs cultivé à végétation haute" ); + aMap->LocalPartition( Face( QList() << 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 +}