Salome HOME
829211fac81cc8677f267bab061f2a43100e5e74
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_LandCoverMap.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
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>
34 #include <QString>
35 #include <QColor>
36 #include <QMap>
37 #include <QDir>
38 #include <BRepTools.hxx>
39 #include <BRep_Builder.hxx>
40
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";
43
44 void test_HYDROData_LandCoverMap::test_add_2_objects()
45 {
46   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
47
48   Handle(HYDROData_LandCoverMap) aMap =
49     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
50
51   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
52
53   TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
54   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
55
56   TopoDS_Face aLC2 = Face( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
57   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
58
59   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Add_2_Objects" );
60   CPPUNIT_ASSERT_IMAGES
61
62   HYDROData_LandCoverMap::Iterator anIt( aMap );
63   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
64   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
65   anIt.Next();
66   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
67   CPPUNIT_ASSERT_EQUAL( QString( "test2" ), anIt.StricklerType() );
68   anIt.Next();
69   CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
70
71   aDoc->Close();
72 }
73
74 void test_HYDROData_LandCoverMap::test_split()
75 {
76   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
77
78   Handle(HYDROData_LandCoverMap) aMap =
79     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
80
81   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
82
83   TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
84   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
85
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 );
90
91   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
92
93   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Split_1" );
94   TestViewer::show( aWire, 0, true, Qt::blue );
95   CPPUNIT_ASSERT_IMAGES
96
97   HYDROData_LandCoverMap::Iterator anIt( aMap );
98   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
99   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
100   anIt.Next();
101   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
102   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
103   anIt.Next();
104   CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
105
106   aDoc->Close();
107 }
108
109 void test_HYDROData_LandCoverMap::test_incomplete_split()
110 {
111   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
112
113   Handle(HYDROData_LandCoverMap) aMap =
114     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
115
116   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
117
118   TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
119   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
120
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 );
125
126   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
127
128   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Split_2" );
129   TestViewer::show( aWire, 0, true, Qt::green );
130   CPPUNIT_ASSERT_IMAGES
131
132   HYDROData_LandCoverMap::Iterator anIt( aMap );
133   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
134   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
135   anIt.Next();
136   CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
137
138   aDoc->Close();
139 }
140
141 void test_HYDROData_LandCoverMap::test_merge()
142 {
143   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
144
145   Handle(HYDROData_LandCoverMap) aMap =
146     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
147
148   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
149
150   TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
151
152   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
153
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 <<
157                                               31 << 114 );
158   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
159
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" ) );
163
164   //TestViewer::show( aMap->GetShape(), AIS_Shaded, true );
165   //TestViewer::AssertEqual( "LandCoverMap_Before_Merge" );
166
167   //BRepTools::Write( aMap->GetShape(), "c:\\map.brep" );
168
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" ) );
178
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
182
183   aDoc->Close();
184 }
185
186 void test_HYDROData_LandCoverMap::test_remove()
187 {
188   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
189
190   Handle(HYDROData_LandCoverMap) aMap =
191     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
192
193   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
194
195   TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
196
197   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
198
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 <<
202                                               31 << 114 );
203   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
204
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" ) );
208
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 ) );
216
217   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Remove_1" );
218   CPPUNIT_ASSERT_IMAGES
219
220   aDoc->Close();
221 }
222
223 void test_HYDROData_LandCoverMap::test_merge_faces_boxes()
224 {
225   TopoDS_Shape pp1, pp2, pp3, pp4;
226   BRep_Builder BB;
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);
231
232   CPPUNIT_ASSERT(!pp1.IsNull());
233   CPPUNIT_ASSERT(!pp2.IsNull());
234   CPPUNIT_ASSERT(!pp3.IsNull());
235   CPPUNIT_ASSERT(!pp4.IsNull());
236
237   //Test mergeFaces() func // boxes // USD == true
238   {
239     TopTools_ListOfShape Faces;
240     Faces.Append(pp1);
241     Faces.Append(pp2);
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);
246   }
247   {
248     TopTools_ListOfShape Faces;
249     Faces.Append(pp1);
250     Faces.Append(pp3);
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);
255   }
256   {
257     TopTools_ListOfShape Faces;
258     Faces.Append(pp1);
259     Faces.Append(pp2);
260     Faces.Append(pp4);
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);
265   }
266   {
267     TopTools_ListOfShape Faces;
268     Faces.Append(pp1);
269     Faces.Append(pp3);
270     Faces.Append(pp4);
271     Faces.Append(pp2);
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);
276   }
277   //
278
279   //Test mergeFaces() func // boxes // USD == false
280   {
281     TopTools_ListOfShape Faces;
282     Faces.Append(pp1);
283     Faces.Append(pp2);
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);
288   }
289   {
290     TopTools_ListOfShape Faces;
291     Faces.Append(pp1);
292     Faces.Append(pp3);
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);
297   }
298   {
299     TopTools_ListOfShape Faces;
300     Faces.Append(pp1);
301     Faces.Append(pp2);
302     Faces.Append(pp4);
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);
307   }
308   {
309     TopTools_ListOfShape Faces;
310     Faces.Append(pp1);
311     Faces.Append(pp3);
312     Faces.Append(pp4);
313     Faces.Append(pp2);
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);
318   }
319 }
320
321
322 void test_HYDROData_LandCoverMap::test_merge_faces_circles()
323 {
324   TopoDS_Shape ff1, ff2, ff3;
325   BRep_Builder BB;
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);
329
330   CPPUNIT_ASSERT(!ff1.IsNull());
331   CPPUNIT_ASSERT(!ff2.IsNull());
332   CPPUNIT_ASSERT(!ff3.IsNull());
333
334   //Test mergeFaces() func // circles // USD == true
335   { 
336     TopTools_ListOfShape Faces;
337     Faces.Append(ff1);
338     Faces.Append(ff2);
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);
343   }
344   {
345     TopTools_ListOfShape Faces;
346     Faces.Append(ff1);
347     Faces.Append(ff3);
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);
352   }
353   {
354     TopTools_ListOfShape Faces;
355     Faces.Append(ff1);
356     Faces.Append(ff2);
357     Faces.Append(ff3);
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);
362   }
363   {
364     TopTools_ListOfShape Faces;
365     Faces.Append(ff1);
366     Faces.Append(ff3);
367     Faces.Append(ff2);
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);
372   }
373   //
374
375   //Test mergeFaces() func // circles // USD == false
376   {
377     TopTools_ListOfShape Faces;
378     Faces.Append(ff1);
379     Faces.Append(ff2);
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);
384   }
385   {
386     TopTools_ListOfShape Faces;
387     Faces.Append(ff1);
388     Faces.Append(ff3);
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);
393   }
394   {
395     TopTools_ListOfShape Faces;
396     Faces.Append(ff1);
397     Faces.Append(ff2);
398     Faces.Append(ff3);
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);
403   }
404   {
405     TopTools_ListOfShape Faces;
406     Faces.Append(ff1);
407     Faces.Append(ff3);
408     Faces.Append(ff2);
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);
413   }
414
415 }
416
417 void test_HYDROData_LandCoverMap::test_import_dbf()
418 {
419   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
420
421   Handle(HYDROData_LandCoverMap) aMap =
422     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
423
424   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
425   QString aFileName = REF_DATA_PATH + "/t1.dbf";
426   QStringList aDBFV;
427   QStringList aST;
428   aDBFV.append("100");
429   aDBFV.append("200");
430   aDBFV.append("300");
431   aST.append("water");
432   aST.append("forest");
433   aST.append("road");
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" ) );
443   
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 );
448  
449   CPPUNIT_ASSERT_EQUAL( QString( "forest" ), anIt.StricklerType() );
450   anIt.Next();
451   CPPUNIT_ASSERT_EQUAL( QString( "road" ), anIt.StricklerType() );
452 }
453
454 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
455 {
456   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
457
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 ) );
461
462   Handle(HYDROData_LandCoverMap) aMap =
463     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
464
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" ) );
467
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 <<
471                                               31 << 114 );
472   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
473
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" ) );
477
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
486
487   aDoc->Close();
488 }
489
490 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
491 {
492   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
493
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 ) );
497
498   Handle(HYDROData_LandCoverMap) aMap =
499     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
500
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" ) );
503
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 <<
507                                               31 << 114 );
508   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
509
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" ) );
513
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
519
520   TestViewer::showColorScale( false );
521   aDoc->Close();
522 }
523
524 void test_HYDROData_LandCoverMap::test_dump_python()
525 {
526   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
527
528   Handle(HYDROData_LandCoverMap) aMap =
529     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
530   aMap->SetName( "test_LCM" );
531
532   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
533
534   TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
535
536   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
537
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 <<
541                                               31 << 114 );
542   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
543
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" ) );
547
548   QString aTmpPath = QDir::tempPath() + "/lc_dump.py";
549   CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
550
551   //TODO: compare files
552 }