1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <test_HYDROData_LandCoverMap.h>
20 #include <HYDROData_Document.h>
21 #include <HYDROData_LandCoverMap.h>
22 #include <HYDROData_PolylineXY.h>
23 #include <HYDROData_StricklerTable.h>
24 #include <HYDROData_Tool.h>
25 #include <HYDROGUI_LandCoverMapPrs.h>
26 #include <TopoDS_Edge.hxx>
27 #include <TopoDS_Wire.hxx>
28 #include <TopoDS_Face.hxx>
29 #include <TestViewer.h>
30 #include <TestShape.h>
31 #include <TopTools_ListOfShape.hxx>
32 #include <AIS_DisplayMode.hxx>
33 #include <Aspect_ColorScale.hxx>
38 #include <BRepTools.hxx>
39 #include <BRep_Builder.hxx>
41 const QString REF_DATA_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
42 const QString DEF_STR_PATH = qgetenv( "HYDRO_SRC_DIR" ) + "/src/HYDROGUI/resources/def_strickler_table.txt";
44 void test_HYDROData_LandCoverMap::test_add_2_objects()
46 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
48 Handle(HYDROData_LandCoverMap) aMap =
49 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
51 CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
53 TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
54 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
56 TopoDS_Face aLC2 = Face( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
57 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
59 TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Add_2_Objects" );
62 HYDROData_LandCoverMap::Iterator anIt( aMap );
63 CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
64 CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
66 CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
67 CPPUNIT_ASSERT_EQUAL( QString( "test2" ), anIt.StricklerType() );
69 CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
74 void test_HYDROData_LandCoverMap::test_split()
76 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
78 Handle(HYDROData_LandCoverMap) aMap =
79 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
81 CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
83 TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
84 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
86 Handle(HYDROData_PolylineXY) aPolyline =
87 Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
88 TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false );
89 aPolyline->SetShape( aWire );
91 CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
93 TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Split_1" );
94 TestViewer::show( aWire, 0, true, Qt::blue );
97 HYDROData_LandCoverMap::Iterator anIt( aMap );
98 CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
99 CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
101 CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
102 CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
104 CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
109 void test_HYDROData_LandCoverMap::test_incomplete_split()
111 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
113 Handle(HYDROData_LandCoverMap) aMap =
114 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
116 CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
118 TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
119 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
121 Handle(HYDROData_PolylineXY) aPolyline =
122 Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
123 TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10, false );
124 aPolyline->SetShape( aWire );
126 CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
128 TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Split_2" );
129 TestViewer::show( aWire, 0, true, Qt::green );
130 CPPUNIT_ASSERT_IMAGES
132 HYDROData_LandCoverMap::Iterator anIt( aMap );
133 CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
134 CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
136 CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
141 void test_HYDROData_LandCoverMap::test_merge()
143 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
145 Handle(HYDROData_LandCoverMap) aMap =
146 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
148 CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
150 TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
152 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
154 TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
155 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
156 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
158 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
160 TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
161 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
162 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
164 //TestViewer::show( aMap->GetShape(), AIS_Shaded, true );
165 //TestViewer::AssertEqual( "LandCoverMap_Before_Merge" );
167 //BRepTools::Write( aMap->GetShape(), "c:\\map.brep" );
169 QString aType1, aType2;
170 gp_Pnt2d aPnt1( 25, 35 );
171 gp_Pnt2d aPnt2( 45, 55 );
172 //gp_Pnt2d aPnt3( 45, 10 );
173 //gp_Pnt2d aPnt4( 45, 80 );
174 TopTools_ListOfShape aList;
175 aList.Append( aMap->FindByPoint( aPnt1, aType1 ) );
176 aList.Append( aMap->FindByPoint( aPnt2, aType2 ) );
177 CPPUNIT_ASSERT_EQUAL( true, aMap->Merge( aList, "new" ) );
179 TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Merge_1" );
180 //TestViewer::show( BRepBuilderAPI_MakeEdge( gp_Pnt(aPnt1.X(), aPnt1.Y(), 0), gp_Pnt(aPnt2.X(), aPnt2.Y(), 0) ).Edge(), QColor( Qt::blue ), AIS_Shaded );
181 CPPUNIT_ASSERT_IMAGES
186 void test_HYDROData_LandCoverMap::test_remove()
188 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
190 Handle(HYDROData_LandCoverMap) aMap =
191 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
193 CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
195 TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
197 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
199 TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
200 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
201 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
203 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
205 TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
206 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
207 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
209 QString aType1, aType2;
210 gp_Pnt2d aPnt1( 25, 35 );
211 gp_Pnt2d aPnt2( 45, 55 );
212 TopTools_ListOfShape aList;
213 aList.Append( aMap->FindByPoint( aPnt1, aType1 ) );
214 aList.Append( aMap->FindByPoint( aPnt2, aType2 ) );
215 CPPUNIT_ASSERT_EQUAL( true, aMap->Remove( aList ) );
217 TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Remove_1" );
218 CPPUNIT_ASSERT_IMAGES
223 void test_HYDROData_LandCoverMap::test_merge_faces_boxes()
225 TopoDS_Shape pp1, pp2, pp3, pp4;
227 BRepTools::Read(pp1, (REF_DATA_PATH + "/pp1.brep").toStdString().c_str(), BB);
228 BRepTools::Read(pp2, (REF_DATA_PATH + "/pp2.brep").toStdString().c_str(), BB);
229 BRepTools::Read(pp3, (REF_DATA_PATH + "/pp3.brep").toStdString().c_str(), BB);
230 BRepTools::Read(pp4, (REF_DATA_PATH + "/pp4.brep").toStdString().c_str(), BB);
232 CPPUNIT_ASSERT(!pp1.IsNull());
233 CPPUNIT_ASSERT(!pp2.IsNull());
234 CPPUNIT_ASSERT(!pp3.IsNull());
235 CPPUNIT_ASSERT(!pp4.IsNull());
237 //Test mergeFaces() func // boxes // USD == true
239 TopTools_ListOfShape Faces;
242 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
243 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_11" );
244 CPPUNIT_ASSERT_IMAGES
245 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
248 TopTools_ListOfShape Faces;
251 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
252 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_12" );
253 CPPUNIT_ASSERT_IMAGES
254 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
257 TopTools_ListOfShape Faces;
261 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
262 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_13" );
263 CPPUNIT_ASSERT_IMAGES
264 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
267 TopTools_ListOfShape Faces;
272 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
273 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_14" );
274 CPPUNIT_ASSERT_IMAGES
275 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
279 //Test mergeFaces() func // boxes // USD == false
281 TopTools_ListOfShape Faces;
284 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
285 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_21" );
286 CPPUNIT_ASSERT_IMAGES
287 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
290 TopTools_ListOfShape Faces;
293 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
294 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_22" );
295 CPPUNIT_ASSERT_IMAGES
296 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
299 TopTools_ListOfShape Faces;
303 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
304 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_23" );
305 CPPUNIT_ASSERT_IMAGES
306 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
309 TopTools_ListOfShape Faces;
314 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
315 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_24" );
316 CPPUNIT_ASSERT_IMAGES
317 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
322 void test_HYDROData_LandCoverMap::test_merge_faces_circles()
324 TopoDS_Shape ff1, ff2, ff3;
326 BRepTools::Read(ff1, (REF_DATA_PATH + "/ff1.brep").toStdString().c_str(), BB);
327 BRepTools::Read(ff2, (REF_DATA_PATH + "/ff2.brep").toStdString().c_str(), BB);
328 BRepTools::Read(ff3, (REF_DATA_PATH + "/ff3.brep").toStdString().c_str(), BB);
330 CPPUNIT_ASSERT(!ff1.IsNull());
331 CPPUNIT_ASSERT(!ff2.IsNull());
332 CPPUNIT_ASSERT(!ff3.IsNull());
334 //Test mergeFaces() func // circles // USD == true
336 TopTools_ListOfShape Faces;
339 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
340 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_11" );
341 CPPUNIT_ASSERT_IMAGES
342 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
345 TopTools_ListOfShape Faces;
348 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
349 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_12" );
350 CPPUNIT_ASSERT_IMAGES
351 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
354 TopTools_ListOfShape Faces;
358 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
359 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_13" );
360 CPPUNIT_ASSERT_IMAGES
361 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
364 TopTools_ListOfShape Faces;
368 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
369 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_14" );
370 CPPUNIT_ASSERT_IMAGES
371 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
375 //Test mergeFaces() func // circles // USD == false
377 TopTools_ListOfShape Faces;
380 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
381 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_21" );
382 CPPUNIT_ASSERT_IMAGES
383 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
386 TopTools_ListOfShape Faces;
389 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
390 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_22" );
391 CPPUNIT_ASSERT_IMAGES
392 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
395 TopTools_ListOfShape Faces;
399 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
400 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_23" );
401 CPPUNIT_ASSERT_IMAGES
402 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
405 TopTools_ListOfShape Faces;
409 TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
410 TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_24" );
411 CPPUNIT_ASSERT_IMAGES
412 CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
417 void test_HYDROData_LandCoverMap::test_import_dbf()
419 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
421 Handle(HYDROData_LandCoverMap) aMap =
422 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
424 CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
425 QString aFileName = REF_DATA_PATH + "/t1.dbf";
432 aST.append("forest");
434 // aST.size() == aDBFV.size()!!
435 Handle(HYDROData_PolylineXY) aPolyline =
436 Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
437 TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 );
438 aPolyline->SetShape( aWire );
439 for (int i = 0; i < 3; i++)
440 aMap->Add(aPolyline, "");
441 TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
442 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
444 CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
445 QList<int> Inds = QList<int>() << 1 << 2 << 3;
446 aMap->ImportDBF(aFileName, "TESTFIELD1", aDBFV, aST, Inds);
447 HYDROData_LandCoverMap::Iterator anIt( aMap );
449 CPPUNIT_ASSERT_EQUAL( QString( "forest" ), anIt.StricklerType() );
451 CPPUNIT_ASSERT_EQUAL( QString( "road" ), anIt.StricklerType() );
454 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
456 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
458 Handle(HYDROData_StricklerTable) aTable =
459 Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
460 CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
462 Handle(HYDROData_LandCoverMap) aMap =
463 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
465 TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
466 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
468 TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
469 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
470 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
472 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
474 TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
475 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
476 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
478 // build presentation object
479 Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
480 aPrs->SetTable( aTable );
481 // show presentation in viewer
482 TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" );
483 // select one of faces (first)
484 TestViewer::select( 200, 300 );
485 CPPUNIT_ASSERT_IMAGES
490 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
492 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
494 Handle(HYDROData_StricklerTable) aTable =
495 Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
496 CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
498 Handle(HYDROData_LandCoverMap) aMap =
499 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
501 TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
502 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
504 TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
505 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
506 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
508 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
510 TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
511 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
512 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
514 Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
515 aPrs->SetTable( aTable );
516 aPrs->SetColorScale( TestViewer::showColorScale( true ) );
517 TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByCoeff" );
518 CPPUNIT_ASSERT_IMAGES
520 TestViewer::showColorScale( false );
524 void test_HYDROData_LandCoverMap::test_dump_python()
526 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
528 Handle(HYDROData_LandCoverMap) aMap =
529 Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
530 aMap->SetName( "test_LCM" );
532 CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
534 TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
536 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
538 TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
539 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
540 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
542 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
544 TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
545 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
546 CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
548 QString aTmpPath = QDir::tempPath() + "/lc_dump.py";
549 CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
551 //TODO: compare files