Salome HOME
e1f52ed7c2190701facf6a4226208d923a1fa37a
[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 <BRepTools.hxx>
38 #include <BRep_Builder.hxx>
39
40 const QString REF_DATA_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
41 const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table.txt";
42
43 void test_HYDROData_LandCoverMap::test_add_2_objects()
44 {
45   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
46
47   Handle(HYDROData_LandCoverMap) aMap =
48     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
49
50   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
51
52   TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
53   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
54
55   TopoDS_Face aLC2 = Face( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
56   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
57
58   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Add_2_Objects" );
59   CPPUNIT_ASSERT_IMAGES
60
61   HYDROData_LandCoverMap::Iterator anIt( aMap );
62   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
63   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
64   anIt.Next();
65   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
66   CPPUNIT_ASSERT_EQUAL( QString( "test2" ), anIt.StricklerType() );
67   anIt.Next();
68   CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
69
70   aDoc->Close();
71 }
72
73 void test_HYDROData_LandCoverMap::test_split()
74 {
75   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
76
77   Handle(HYDROData_LandCoverMap) aMap =
78     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
79
80   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
81
82   TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
83   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
84
85   Handle(HYDROData_PolylineXY) aPolyline =
86     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
87   TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false );
88   aPolyline->SetShape( aWire );
89
90   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
91
92   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Split_1" );
93   TestViewer::show( aWire, 0, true, Qt::blue );
94   CPPUNIT_ASSERT_IMAGES
95
96   HYDROData_LandCoverMap::Iterator anIt( aMap );
97   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
98   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
99   anIt.Next();
100   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
101   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
102   anIt.Next();
103   CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
104
105   aDoc->Close();
106 }
107
108 void test_HYDROData_LandCoverMap::test_incomplete_split()
109 {
110   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
111
112   Handle(HYDROData_LandCoverMap) aMap =
113     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
114
115   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
116
117   TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
118   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
119
120   Handle(HYDROData_PolylineXY) aPolyline =
121     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
122   TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10, false );
123   aPolyline->SetShape( aWire );
124
125   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
126
127   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Split_2" );
128   TestViewer::show( aWire, 0, true, Qt::green );
129   CPPUNIT_ASSERT_IMAGES
130
131   HYDROData_LandCoverMap::Iterator anIt( aMap );
132   CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
133   CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
134   anIt.Next();
135   CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
136
137   aDoc->Close();
138 }
139
140 void test_HYDROData_LandCoverMap::test_merge()
141 {
142   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
143
144   Handle(HYDROData_LandCoverMap) aMap =
145     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
146
147   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
148
149   TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
150
151   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
152
153   TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
154                                               44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
155                                              128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
156                                               31 << 114 );
157   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
158
159   TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
160                                             127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
161   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
162
163   //TestViewer::show( aMap->GetShape(), AIS_Shaded, true );
164   //TestViewer::AssertEqual( "LandCoverMap_Before_Merge" );
165
166   //BRepTools::Write( aMap->GetShape(), "c:\\map.brep" );
167
168   QString aType1, aType2;
169   gp_Pnt2d aPnt1( 25, 35 );
170   gp_Pnt2d aPnt2( 45, 55 );
171   //gp_Pnt2d aPnt3( 45, 10 );
172   //gp_Pnt2d aPnt4( 45, 80 );
173   TopTools_ListOfShape aList;
174   aList.Append( aMap->FindByPoint( aPnt1, aType1 ) );
175   aList.Append( aMap->FindByPoint( aPnt2, aType2 ) );
176   CPPUNIT_ASSERT_EQUAL( true, aMap->Merge( aList, "new" ) );
177
178   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Merge_1" );
179   //TestViewer::show( BRepBuilderAPI_MakeEdge( gp_Pnt(aPnt1.X(), aPnt1.Y(), 0), gp_Pnt(aPnt2.X(), aPnt2.Y(), 0) ).Edge(), QColor( Qt::blue ), AIS_Shaded );
180   CPPUNIT_ASSERT_IMAGES
181
182   aDoc->Close();
183 }
184
185 void test_HYDROData_LandCoverMap::test_remove()
186 {
187   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
188
189   Handle(HYDROData_LandCoverMap) aMap =
190     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
191
192   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
193
194   TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
195
196   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
197
198   TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
199                                               44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
200                                              128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
201                                               31 << 114 );
202   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
203
204   TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
205                                             127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
206   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
207
208   QString aType1, aType2;
209   gp_Pnt2d aPnt1( 25, 35 );
210   gp_Pnt2d aPnt2( 45, 55 );
211   TopTools_ListOfShape aList;
212   aList.Append( aMap->FindByPoint( aPnt1, aType1 ) );
213   aList.Append( aMap->FindByPoint( aPnt2, aType2 ) );
214   CPPUNIT_ASSERT_EQUAL( true, aMap->Remove( aList ) );
215
216   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Remove_1" );
217   CPPUNIT_ASSERT_IMAGES
218
219   aDoc->Close();
220 }
221
222 void test_HYDROData_LandCoverMap::test_merge_faces_boxes()
223 {
224   TopoDS_Shape pp1, pp2, pp3, pp4;
225   BRep_Builder BB;
226   BRepTools::Read(pp1, (REF_DATA_PATH + "/pp1.brep").toStdString().c_str(), BB);
227   BRepTools::Read(pp2, (REF_DATA_PATH + "/pp2.brep").toStdString().c_str(), BB);
228   BRepTools::Read(pp3, (REF_DATA_PATH + "/pp3.brep").toStdString().c_str(), BB);
229   BRepTools::Read(pp4, (REF_DATA_PATH + "/pp4.brep").toStdString().c_str(), BB);
230
231   CPPUNIT_ASSERT(!pp1.IsNull());
232   CPPUNIT_ASSERT(!pp2.IsNull());
233   CPPUNIT_ASSERT(!pp3.IsNull());
234   CPPUNIT_ASSERT(!pp4.IsNull());
235
236   //Test mergeFaces() func // boxes // USD == true
237   {
238     TopTools_ListOfShape Faces;
239     Faces.Append(pp1);
240     Faces.Append(pp2);
241     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
242     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_11" );
243     CPPUNIT_ASSERT_IMAGES
244     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
245   }
246   {
247     TopTools_ListOfShape Faces;
248     Faces.Append(pp1);
249     Faces.Append(pp3);
250     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
251     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_12" );
252     CPPUNIT_ASSERT_IMAGES
253     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
254   }
255   {
256     TopTools_ListOfShape Faces;
257     Faces.Append(pp1);
258     Faces.Append(pp2);
259     Faces.Append(pp4);
260     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
261     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_13" );
262     CPPUNIT_ASSERT_IMAGES
263     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
264   }
265   {
266     TopTools_ListOfShape Faces;
267     Faces.Append(pp1);
268     Faces.Append(pp3);
269     Faces.Append(pp4);
270     Faces.Append(pp2);
271     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
272     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_14" );
273     CPPUNIT_ASSERT_IMAGES
274     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
275   }
276   //
277
278   //Test mergeFaces() func // boxes // USD == false
279   {
280     TopTools_ListOfShape Faces;
281     Faces.Append(pp1);
282     Faces.Append(pp2);
283     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
284     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_21" );
285     CPPUNIT_ASSERT_IMAGES
286     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
287   }
288   {
289     TopTools_ListOfShape Faces;
290     Faces.Append(pp1);
291     Faces.Append(pp3);
292     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
293     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_22" );
294     CPPUNIT_ASSERT_IMAGES
295     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
296   }
297   {
298     TopTools_ListOfShape Faces;
299     Faces.Append(pp1);
300     Faces.Append(pp2);
301     Faces.Append(pp4);
302     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
303     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_23" );
304     CPPUNIT_ASSERT_IMAGES
305     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
306   }
307   {
308     TopTools_ListOfShape Faces;
309     Faces.Append(pp1);
310     Faces.Append(pp3);
311     Faces.Append(pp4);
312     Faces.Append(pp2);
313     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
314     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_boxes_24" );
315     CPPUNIT_ASSERT_IMAGES
316     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
317   }
318 }
319
320
321 void test_HYDROData_LandCoverMap::test_merge_faces_circles()
322 {
323   TopoDS_Shape ff1, ff2, ff3;
324   BRep_Builder BB;
325   BRepTools::Read(ff1, (REF_DATA_PATH + "/ff1.brep").toStdString().c_str(), BB);
326   BRepTools::Read(ff2, (REF_DATA_PATH + "/ff2.brep").toStdString().c_str(), BB);
327   BRepTools::Read(ff3, (REF_DATA_PATH + "/ff3.brep").toStdString().c_str(), BB);
328
329   CPPUNIT_ASSERT(!ff1.IsNull());
330   CPPUNIT_ASSERT(!ff2.IsNull());
331   CPPUNIT_ASSERT(!ff3.IsNull());
332
333   //Test mergeFaces() func // circles // USD == true
334   { 
335     TopTools_ListOfShape Faces;
336     Faces.Append(ff1);
337     Faces.Append(ff2);
338     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
339     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_11" );
340     CPPUNIT_ASSERT_IMAGES
341     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
342   }
343   {
344     TopTools_ListOfShape Faces;
345     Faces.Append(ff1);
346     Faces.Append(ff3);
347     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
348     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_12" );
349     CPPUNIT_ASSERT_IMAGES
350     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
351   }
352   {
353     TopTools_ListOfShape Faces;
354     Faces.Append(ff1);
355     Faces.Append(ff2);
356     Faces.Append(ff3);
357     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
358     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_13" );
359     CPPUNIT_ASSERT_IMAGES
360     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
361   }
362   {
363     TopTools_ListOfShape Faces;
364     Faces.Append(ff1);
365     Faces.Append(ff3);
366     Faces.Append(ff2);
367     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
368     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_14" );
369     CPPUNIT_ASSERT_IMAGES
370     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
371   }
372   //
373
374   //Test mergeFaces() func // circles // USD == false
375   {
376     TopTools_ListOfShape Faces;
377     Faces.Append(ff1);
378     Faces.Append(ff2);
379     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
380     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_21" );
381     CPPUNIT_ASSERT_IMAGES
382     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
383   }
384   {
385     TopTools_ListOfShape Faces;
386     Faces.Append(ff1);
387     Faces.Append(ff3);
388     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
389     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_22" );
390     CPPUNIT_ASSERT_IMAGES
391     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
392   }
393   {
394     TopTools_ListOfShape Faces;
395     Faces.Append(ff1);
396     Faces.Append(ff2);
397     Faces.Append(ff3);
398     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
399     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_23" );
400     CPPUNIT_ASSERT_IMAGES
401     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
402   }
403   {
404     TopTools_ListOfShape Faces;
405     Faces.Append(ff1);
406     Faces.Append(ff3);
407     Faces.Append(ff2);
408     TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
409     TestViewer::show( aMergedFace, AIS_Shaded, true, "merge_faces_circles_24" );
410     CPPUNIT_ASSERT_IMAGES
411     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
412   }
413
414 }
415
416 void test_HYDROData_LandCoverMap::test_import_dbf()
417 {
418   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
419
420   Handle(HYDROData_LandCoverMap) aMap =
421     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
422
423   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
424   QString aFileName = REF_DATA_PATH + "/t1.dbf";
425   QStringList aDBFV;
426   QStringList aST;
427   aDBFV.append("100");
428   aDBFV.append("200");
429   aDBFV.append("300");
430   aST.append("water");
431   aST.append("forest");
432   aST.append("road");
433   // aST.size() == aDBFV.size()!!
434   Handle(HYDROData_PolylineXY) aPolyline =
435     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
436   TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 );
437   aPolyline->SetShape( aWire );
438   for (int i = 0; i < 3; i++)
439     aMap->Add(aPolyline, "");
440   TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
441   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
442   
443   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
444   QMap<int, int> Inds;
445   Inds.insert(1, 1);
446   Inds.insert(2, 2);
447   Inds.insert(3, 3);
448   aMap->ImportDBF(aFileName, "TESTFIELD1", aDBFV, aST, Inds);
449   HYDROData_LandCoverMap::Iterator anIt( aMap );
450  
451   CPPUNIT_ASSERT_EQUAL(true, "water" == anIt.StricklerType());
452   anIt.Next();
453   CPPUNIT_ASSERT_EQUAL(true, "forest" == anIt.StricklerType());
454
455 }
456
457 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
458 {
459   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
460
461   Handle(HYDROData_StricklerTable) aTable =
462     Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
463   CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
464
465   Handle(HYDROData_LandCoverMap) aMap =
466     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
467
468   TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
469   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
470
471   TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
472                                               44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
473                                              128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
474                                               31 << 114 );
475   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
476
477   TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
478                                             127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
479   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
480
481   // build presentation object 
482   Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
483   aPrs->SetTable( aTable );
484   // show presentation in viewer
485   TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" );
486   // select one of faces (first)
487   TestViewer::select( 200, 300 );
488   CPPUNIT_ASSERT_IMAGES
489
490   aDoc->Close();
491 }
492
493 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
494 {
495   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
496
497   Handle(HYDROData_StricklerTable) aTable =
498     Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
499   CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
500
501   Handle(HYDROData_LandCoverMap) aMap =
502     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
503
504   TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
505   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
506
507   TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
508                                               44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
509                                              128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
510                                               31 << 114 );
511   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
512
513   TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
514                                             127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
515   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
516
517   Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
518   aPrs->SetTable( aTable );
519   aPrs->SetColorScale( TestViewer::showColorScale( true ) );
520   TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByCoeff" );
521   CPPUNIT_ASSERT_IMAGES
522
523   TestViewer::showColorScale( false );
524   aDoc->Close();
525 }
526