]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_LandCoverMap.cxx
Salome HOME
patch for crash in tests
[modules/hydro.git] / src / HYDROData / 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 <HYDROData_LandCoverMap.h>
20 #include <HYDROData_Object.h>
21 #include <HYDROData_PolylineXY.h>
22 #include <HYDROData_Tool.h>
23
24 #include <BOPAlgo_BOP.hxx>
25 #include <BOPAlgo_Builder.hxx>
26 #include <BOPAlgo_PaveFiller.hxx>
27 #include <BOPCol_ListOfShape.hxx>
28 #include <BRep_Builder.hxx>
29 #include <BRepAdaptor_Curve.hxx>
30 #include <BRepAlgoAPI_Fuse.hxx>
31 #include <BRepBuilderAPI_MakeFace.hxx>
32 #include <GCPnts_QuasiUniformDeflection.hxx>
33 #include <NCollection_IndexedMap.hxx>
34 #include <TopoDS.hxx>
35 #include <TopoDS_Compound.hxx>
36 #include <TopoDS_Edge.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Iterator.hxx>
39 #include <TopoDS_Shell.hxx>
40 #include <TopExp_Explorer.hxx>
41 #include <TopTools_ListIteratorOfListOfShape.hxx>
42 #include <BOPAlgo_PaveFiller.hxx>
43 #include <BRepTools.hxx>
44 #include <TopExp_Explorer.hxx>
45 #include <ShapeUpgrade_UnifySameDomain.hxx>
46
47 #include <QFile>
48 #include <QString>
49 #include <QTextStream>
50
51 const char TELEMAC_FORMAT = 'f';
52 const int TELEMAC_PRECISION = 3;
53
54
55 IMPLEMENT_STANDARD_HANDLE(HYDROData_LandCoverMap, HYDROData_Entity)
56 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_LandCoverMap, HYDROData_Entity)
57
58 class HYDROData_MapOfFaceToStricklerType : public NCollection_IndexedDataMap<TopoDS_Face, QString>
59 {
60 };
61
62 /**
63   Constructor
64   @param theMap the land cover map to iterate through
65 */
66 HYDROData_LandCoverMap::Iterator::Iterator( const HYDROData_LandCoverMap& theMap )
67 {
68   Init( theMap );
69 }
70
71 HYDROData_LandCoverMap::Iterator::Iterator( const Handle( HYDROData_LandCoverMap )& theMap )
72 {
73   if( theMap.IsNull() )
74   {
75     myIterator = 0;
76     myIndex = -1;
77   }
78   else
79     Init( *theMap );
80 }
81
82 /**
83   Initialize the iterator
84   @param theMap the land cover map to iterate through
85 */
86 void HYDROData_LandCoverMap::Iterator::Init( const HYDROData_LandCoverMap& theMap )
87 {
88   TopoDS_Shape aShape = theMap.GetShape();
89   if( aShape.IsNull() )
90     myIterator = 0;
91   else
92     myIterator = new TopoDS_Iterator( aShape );
93   
94   theMap.myLab.FindChild( DataTag_Types ).FindAttribute( TDataStd_ExtStringArray::GetID(), myArray );
95   if( myArray.IsNull() )
96     myIndex = -1;
97   else
98     myIndex = myArray->Lower();
99 }
100
101 /**
102   Destructor
103 */
104 HYDROData_LandCoverMap::Iterator::~Iterator()
105 {
106   delete myIterator;
107 }
108
109 /**
110   Return the current 0-based index of the iterator
111   @return the current index
112 */
113 int HYDROData_LandCoverMap::Iterator::Index() const
114 {
115   if( myArray.IsNull() )
116     return -1;
117   else
118     return myIndex - myArray->Lower();
119 }
120
121 /**
122   Return if the iterator has more elements
123   @return if the iterator has more elements
124 */
125 bool HYDROData_LandCoverMap::Iterator::More() const
126 {
127   return !myArray.IsNull() && myIterator && myIterator->More();
128 }
129
130 /**
131   Move iterator to the next element
132 */
133 void HYDROData_LandCoverMap::Iterator::Next()
134 {
135   if( myIterator )
136   {
137     myIterator->Next();
138     myIndex++;
139   }
140 }
141
142 /**
143   Get the current land cover (face)
144   @return the land cover's face
145 */
146 TopoDS_Face HYDROData_LandCoverMap::Iterator::Face() const
147 {
148   if( myIterator )
149     return TopoDS::Face( myIterator->Value() );
150   else
151     return TopoDS_Face();
152 }
153
154 /**
155   Get the current land cover's Strickler type 
156   @return the land cover's Strickler type 
157 */
158 QString HYDROData_LandCoverMap::Iterator::StricklerType() const
159 {
160   if( myArray.IsNull() || myIndex < myArray->Lower() || myIndex > myArray->Upper() )
161     return "";
162   else
163     return HYDROData_Tool::toQString( myArray->Value( myIndex ) );
164 }
165
166 /**
167   Set the Strickler type for the current land cover
168   @param theType the Strickler type
169 */
170 void HYDROData_LandCoverMap::Iterator::SetStricklerType( const QString& theType )
171 {
172   if( myArray.IsNull() || myIndex < myArray->Lower() || myIndex > myArray->Upper() )
173     return;
174   else
175     myArray->SetValue( myIndex, HYDROData_Tool::toExtString( theType ) );
176 }
177
178 /**
179   Constructor
180 */
181 HYDROData_LandCoverMap::HYDROData_LandCoverMap()
182   : HYDROData_Entity( Geom_No )
183 {
184 }
185
186 /**
187   Destructor
188 */
189 HYDROData_LandCoverMap::~HYDROData_LandCoverMap()
190 {
191 }
192
193 /**
194   Get object's kind
195   @return object's kind
196 */
197 const ObjectKind HYDROData_LandCoverMap::GetKind() const
198 {
199   return KIND_LAND_COVER_MAP;
200 }
201
202 /**
203   Import the land cover map from QGIS
204   @param theFileName the name of file
205   @return if the import is successful
206 */
207 bool HYDROData_LandCoverMap::ImportQGIS( const QString& theFileName )
208 {
209   //TODO
210   return false;
211 }
212
213 /**
214   Export the land cover map to QGIS
215   @param theFileName the name of file
216   @return if the export is successful
217 */
218 bool HYDROData_LandCoverMap::ExportQGIS( const QString& theFileName ) const
219 {
220   //TODO
221   return false;
222 }
223
224 int HashCode( const gp_Pnt& thePoint, const Standard_Integer theUpper )
225 {
226   int aHashX = HashCode( thePoint.X(), theUpper );
227   int aHashY = HashCode( thePoint.Y(), theUpper );
228   return (aHashX^aHashY)%theUpper;
229 }
230
231 bool operator == ( const gp_Pnt& thePoint1, const gp_Pnt& thePoint2 )
232 {
233   return thePoint1.IsEqual( thePoint2, Precision::Confusion() );
234 }
235
236 bool EdgeDiscretization( const TopoDS_Edge& theEdge, 
237                          Standard_Real theDeflection,
238                          NCollection_IndexedMap<gp_Pnt>& theVerticesMap,
239                          QList<int>& theVerticesIds )
240 {
241   BRepAdaptor_Curve aCurve( theEdge );
242   GCPnts_QuasiUniformDeflection aDiscrete( aCurve, theDeflection );
243   if( !aDiscrete.IsDone() )
244     return false;
245
246   int n = aDiscrete.NbPoints();
247   for( int i=1; i<=n; i++ )
248   {
249     gp_Pnt aPnt = aDiscrete.Value( i );
250     int anId;
251     if( theVerticesMap.Contains( aPnt ) )
252       anId = theVerticesMap.FindIndex( aPnt );
253     else
254     {
255       anId = theVerticesMap.Size();
256       theVerticesMap.Add( aPnt );
257     }
258     theVerticesIds.append( anId );
259   }
260   return true;
261 }
262
263 /**
264   Export the land cover map for the solver (Telemac)
265   @param theFileName the name of file
266   @return if the export is successful
267 */
268 bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName, Standard_Real theDeflection ) const
269 {
270   TopoDS_Shape aLandCoverMapShape = GetShape();
271   TopTools_ListOfShape aListOfFaces;
272   TopExp_Explorer anExp( aLandCoverMapShape, TopAbs_FACE );
273   for( ; anExp.More(); anExp.Next() )
274     aListOfFaces.Append( anExp.Current() );
275
276   TopoDS_Shape aShape = MergeFaces( aListOfFaces, false );
277
278   NCollection_IndexedMap<gp_Pnt> aVerticesMap;
279   NCollection_IndexedDataMap< TopoDS_Edge, QList<int> > anEdgesMap;
280   NCollection_IndexedDataMap< TopoDS_Face, QList<int> > aFacesMap;
281
282   // add into the map all edges existing in the shell
283   TopExp_Explorer anExp1( aShape, TopAbs_EDGE );
284   for( ; anExp1.More(); anExp1.Next() )
285   {
286     TopoDS_Edge anEdge = TopoDS::Edge( anExp1.Current() );
287     QList<int> aVerticesIdsList;
288     if( EdgeDiscretization( anEdge, theDeflection, aVerticesMap, aVerticesIdsList ) )
289       anEdgesMap.Add( anEdge, aVerticesIdsList );
290   }
291
292   // add into the map all faces existing in the shell and correspondence between face and edges ids
293   TopExp_Explorer anExp2( aShape, TopAbs_FACE );
294   for( ; anExp2.More(); anExp2.Next() )
295   {
296     TopoDS_Face aFace = TopoDS::Face( anExp2.Current() );
297     TopExp_Explorer anExp3( aFace, TopAbs_EDGE );
298     QList<int> anEdgesIdsList;
299     for( ; anExp3.More(); anExp3.Next() )
300     {
301       TopoDS_Edge anEdge = TopoDS::Edge( anExp3.Current() );
302       int anEdgeId = anEdgesMap.FindIndex( anEdge );
303       anEdgesIdsList.append( anEdgeId );
304     }
305     aFacesMap.Add( aFace, anEdgesIdsList );
306   }
307
308   QFile aFile( theFileName );
309   if( !aFile.open( QFile::WriteOnly | QFile::Text ) )
310     return false;
311
312   QTextStream aStream( &aFile );
313   aStream << "# nodes\n";
314   NCollection_IndexedMap<gp_Pnt>::Iterator anIt1( aVerticesMap );
315   for( ; anIt1.More(); anIt1.Next() )
316   {
317     gp_Pnt aPnt = anIt1.Value();
318     aStream << QString::number( aPnt.X(), TELEMAC_FORMAT, TELEMAC_PRECISION );
319     aStream << " ";
320     aStream << QString::number( aPnt.Y(), TELEMAC_FORMAT, TELEMAC_PRECISION );
321     aStream << " ";
322     aStream << QString::number( aPnt.Z(), TELEMAC_FORMAT, TELEMAC_PRECISION );
323     aStream << "\n";
324   }
325   aStream << "\n";
326
327   aStream << "# edges\n";
328   NCollection_IndexedDataMap< TopoDS_Edge, QList<int> >::Iterator anIt2( anEdgesMap );
329   for( ; anIt2.More(); anIt2.Next() )
330   {
331     QList<int> aVerticesIds = anIt2.Value();
332     foreach( int anId, aVerticesIds )
333       aStream << anId << " ";
334     aStream << "\n";
335   }
336   aStream << "\n";
337
338   aStream << "# faces\n";
339   NCollection_IndexedDataMap< TopoDS_Face, QList<int> >::Iterator anIt3( aFacesMap );
340   for( ; anIt3.More(); anIt3.Next() )
341   {
342     QList<int> anEdgesIds = anIt3.Value();
343     foreach( int anId, anEdgesIds )
344       aStream << anId << " ";
345     aStream << "\n";
346   }
347   aStream << "\n";
348
349   aFile.close();
350   return true;
351 }
352
353 /**
354   Add a new object as land cover
355   @param theObject the object to add as land cover
356   @param theType the Strickler type for the new land cover
357   @return if the addition is successful
358 */
359 bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_Object )& theObject, const QString& theType )
360 {
361   if( theObject.IsNull() )
362     return false;
363
364   TopoDS_Shape aShape = theObject->GetTopShape();
365   if( aShape.ShapeType()!=TopAbs_FACE )
366     return false;
367
368   TopoDS_Face aFace = TopoDS::Face( aShape );
369   return LocalPartition( aFace, theType );
370 }
371
372 /**
373   Add a new polyline as land cover
374   @param thePolyline the polyline to add as land cover
375   @param theType the Strickler type for the new land cover
376   @return if the addition is successful
377 */
378 bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_PolylineXY )& thePolyline, const QString& theType )
379 {
380   if( thePolyline.IsNull() )
381     return false;
382
383   TopoDS_Shape aShape = thePolyline->GetShape();
384   if( aShape.ShapeType()!=TopAbs_WIRE )
385     return false;
386
387   TopoDS_Wire aWire = TopoDS::Wire( aShape );
388   if( !aWire.Closed() )
389     return false;
390
391   TopoDS_Face aFace = BRepBuilderAPI_MakeFace( aWire, Standard_True ).Face();
392   return LocalPartition( aFace, theType );
393 }
394
395 /**
396   Remove the given face from land cover map
397   @param theFace the face to be removed
398   @return if the removing is successful
399 */
400 bool HYDROData_LandCoverMap::Remove( const TopoDS_Face& theFace )
401 {
402   TopTools_ListOfShape aList;
403   aList.Append( theFace );
404   return Remove( aList );
405 }
406
407 /**
408   Remove the given faces from land cover map
409   @param theFacesToRemove the face list to be removed
410   @return if the removing is successful
411 */
412 bool HYDROData_LandCoverMap::Remove( const TopTools_ListOfShape& theFacesToRemove )
413 {
414   HYDROData_MapOfFaceToStricklerType aFacesToRemove, aNewFaces;
415   TopTools_ListIteratorOfListOfShape aFIt( theFacesToRemove );
416   for( ; aFIt.More(); aFIt.Next() )
417   {
418     TopoDS_Shape aShape = aFIt.Value();
419     if( aShape.ShapeType()==TopAbs_FACE )
420       aFacesToRemove.Add( TopoDS::Face( aShape ), "" );
421   }
422
423   Iterator anIt( *this );
424   for( ; anIt.More(); anIt.Next() )
425     if( !aFacesToRemove.Contains( anIt.Face() ) )
426       aNewFaces.Add( anIt.Face(), anIt.StricklerType() );
427
428   StoreLandCovers( aNewFaces );
429   return true;
430 }
431
432 /**
433   Split the land cover map by the given polyline
434   @param thePolyline the tool polyline to split the land cover map
435   @return if the removing is successful
436 */
437 bool HYDROData_LandCoverMap::Split( const Handle( HYDROData_PolylineXY )& thePolyline )
438 {
439   if( thePolyline.IsNull() )
440     return false;
441
442   TopoDS_Shape aShape = thePolyline->GetShape();
443   return LocalPartition( aShape, "" );
444 }
445
446 /**
447   Merge the given faces in the land cover
448   @param theFaces the faces to merge in the land cover map
449   @param theType the Strickler type for the merged land cover
450   @return if the merge is successful
451 */
452 bool HYDROData_LandCoverMap::Merge( const TopTools_ListOfShape& theFaces, const QString& theType )
453 {
454   // 1. to fuse the faces into the new face
455   TopoDS_Shape aMergedFace = MergeFaces( theFaces, true );
456   if( aMergedFace.ShapeType()==TopAbs_FACE )
457   {
458     // 2. to remove the merged faces from the current map
459     Remove( theFaces );
460
461     // 3. to add the face into the map
462     return LocalPartition( TopoDS::Face( aMergedFace ), theType );
463   }
464   return false;
465 }
466
467 TopoDS_Shape HYDROData_LandCoverMap::MergeFaces( const TopTools_ListOfShape& theFaces,
468                                                  bool IsToUnify, double theTolerance )
469 {
470   int anError;
471   TopTools_ListIteratorOfListOfShape anIt;
472   BOPCol_ListOfShape aLC;
473   anIt.Initialize(theFaces);
474   for( ; anIt.More(); anIt.Next() )
475     aLC.Append( anIt.Value() );
476
477   BOPAlgo_PaveFiller aPF;
478   aPF.SetArguments( aLC );
479   aPF.SetRunParallel( Standard_False );
480   aPF.SetFuzzyValue( theTolerance );
481
482   aPF.Perform();
483   anError = aPF.ErrorStatus();
484   if( anError )
485     return TopoDS_Shape();
486
487   BOPAlgo_Builder anAlgo;
488   anIt.Initialize( theFaces );
489   for( ; anIt.More(); anIt.Next() )
490     anAlgo.AddArgument( anIt.Value() );
491
492   anAlgo.PerformWithFiller( aPF ); 
493   anError = anAlgo.ErrorStatus();
494   if( anError )
495     return TopoDS_Shape();
496
497   const TopoDS_Shape& aMergedShape = anAlgo.Shape();
498
499   BRep_Builder aBuilder;
500   TopoDS_Shell aShell; 
501   aBuilder.MakeShell( aShell ); 
502   aShell.Closed( Standard_False );
503   TopExp_Explorer anExplorer( aMergedShape, TopAbs_FACE );
504   for( ; anExplorer.More(); anExplorer.Next() ) 
505   {
506     const TopoDS_Face& aFace = TopoDS::Face(anExplorer.Current());
507     if( aFace.IsNull() ) 
508       continue;
509     if( aFace.ShapeType() == TopAbs_FACE )
510     {
511       aBuilder.Add( aShell, aFace );
512       aShell.Closed( Standard_False );
513     }
514   }
515
516   TopoDS_Shape aResult;
517   if( IsToUnify )
518   {
519     ShapeUpgrade_UnifySameDomain aUSD;
520     aUSD.Initialize( aShell );
521     aUSD.Build();
522     aResult = aUSD.Shape();
523   }
524   else
525     aResult = aShell;
526
527   anExplorer.Init( aResult, TopAbs_FACE );
528   int i = 0;
529   TopoDS_Face anOneFace;
530   for( ; anExplorer.More(); anExplorer.Next(), i++ ) 
531     anOneFace = TopoDS::Face( anExplorer.Current() );
532
533   if( i == 1 )
534     aResult = anOneFace;
535
536   return aResult;
537 }
538
539 /**
540   Get the shape of the land cover map
541 */
542 TopoDS_Shape HYDROData_LandCoverMap::GetShape() const
543 {
544   return HYDROData_Entity::GetShape( DataTag_Shape );
545 }
546
547 /**
548   Set the shape of the land cover map
549   @param theShape the new shape for the land cover map
550 */
551 void HYDROData_LandCoverMap::SetShape( const TopoDS_Shape& theShape )
552 {
553   HYDROData_Entity::SetShape( DataTag_Shape, theShape );
554 }
555
556 /**
557   Perform the local partition algorithm on the land cover
558   @param theNewShape the new shape to add into the land cover
559   @param theNewType the new Strickler type for the new land cover
560   @return if the local partition is successful
561 */
562 bool HYDROData_LandCoverMap::LocalPartition( const TopoDS_Shape& theNewShape, const QString& theNewType )
563 {
564   if( theNewShape.IsNull() )
565     return false;
566
567   BOPCol_ListOfShape aShapesList;
568   BOPAlgo_PaveFiller aPaveFiller;
569   HYDROData_MapOfFaceToStricklerType aNewFaces;
570
571   // add faces to shapes list
572   Iterator anIt( *this );
573   for( ; anIt.More(); anIt.Next() )
574     aShapesList.Append( anIt.Face() );
575   aShapesList.Append( theNewShape );
576
577   if( aShapesList.Size()==1 && theNewShape.ShapeType()==TopAbs_FACE )
578   {
579     aNewFaces.Add( TopoDS::Face( theNewShape ), theNewType );
580     StoreLandCovers( aNewFaces );
581     return true;
582   }
583
584   // prepare pave filler
585   aPaveFiller.SetArguments( aShapesList );
586   aPaveFiller.Perform();
587   Standard_Integer anError = aPaveFiller.ErrorStatus();
588   if( anError )
589     return false;
590
591   // add faces to builder
592   BOPAlgo_Builder aBuilder;
593   anIt.Init( *this );
594   for( ; anIt.More(); anIt.Next() )
595     aBuilder.AddArgument( anIt.Face() );
596   aBuilder.AddArgument( theNewShape );
597
598   // perform the partition with the pave filler
599   aBuilder.PerformWithFiller( aPaveFiller );
600   anError = aBuilder.ErrorStatus();
601   if( anError )
602     return false;
603
604   // analysis of the history
605   //     a. to fill map of shapes which come from the new face
606   NCollection_IndexedMap<TopoDS_Shape> aShapesFromNewFace;
607   //std::cout << "new: " << theNewShape << " " << theNewType << std::endl;
608   TopTools_ListOfShape aModified = aBuilder.Modified( theNewShape );
609   TopTools_ListIteratorOfListOfShape aMIt( aModified );
610   for( ; aMIt.More(); aMIt.Next() )
611   {
612     //std::cout << "   " << aMIt.Value() << std::endl;
613     aShapesFromNewFace.Add( aMIt.Value() );
614   }
615
616   //     b. to fill map of parts except parts from new face
617   anIt.Init( *this );
618   for( ; anIt.More(); anIt.Next() )
619   {
620     QString aSType = anIt.StricklerType();
621     //std::cout << anIt.Face() << " " << anIt.StricklerType() << std::endl;
622     TopTools_ListOfShape aModified = aBuilder.Modified( anIt.Face() );
623     TopTools_ListIteratorOfListOfShape aMIt( aModified );
624     for( ; aMIt.More(); aMIt.Next() )
625     {
626       TopoDS_Shape aShape = aMIt.Value();
627       bool isFace = aShape.ShapeType()==TopAbs_FACE;
628       bool isAlsoFromNew = aShapesFromNewFace.Contains( aShape );
629       //std::cout << "   " << aShape << " " << isAlsoFromNew << std::endl;
630       if( isFace && !isAlsoFromNew )
631         aNewFaces.Add( TopoDS::Face( aShape ), aSType );
632     }
633   }
634
635   //     c. add the new shape if it is face with its type
636   if( theNewShape.ShapeType()==TopAbs_FACE )
637     aNewFaces.Add( TopoDS::Face( theNewShape ), theNewType );
638   
639   // convert map of shape to type to compound and list of types
640   StoreLandCovers( aNewFaces );
641   return true;
642 }
643
644 /**
645   Replace the set of land covers in the land cover map
646   @param theMap the map of shape (face) to Strickler type (string)
647 */
648 void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStricklerType& theMap )
649 {
650   TopoDS_Compound aCompound;
651   BRep_Builder aCompoundBuilder;
652   aCompoundBuilder.MakeCompound( aCompound );
653
654   int n = theMap.Size();
655   Handle( TDataStd_ExtStringArray ) aTypes = 
656     TDataStd_ExtStringArray::Set( myLab.FindChild( DataTag_Types ), 0, n-1, Standard_True );
657   HYDROData_MapOfFaceToStricklerType::Iterator aNFIt( theMap );
658   for( int i=0; aNFIt.More(); aNFIt.Next(), i++ )
659   {
660     TopoDS_Face aFace = aNFIt.Key();
661     QString aType = aNFIt.Value();
662     aCompoundBuilder.Add( aCompound, aFace );
663     aTypes->SetValue( i, HYDROData_Tool::toExtString( aType ) );
664   }
665
666   SetShape( aCompound );
667 }
668
669 /**
670   Find the land cover for the given point
671   @param thePoint the point laying in some land cover
672   @param theType the returned type
673   @return the found land cover's face
674 */
675 TopoDS_Face HYDROData_LandCoverMap::FindByPoint( const gp_Pnt2d& thePoint, QString& theType ) const
676 {
677   //TODO: some more optimal algorithm
678   Iterator anIt( *this );
679   for( ; anIt.More(); anIt.Next() )
680     if( HYDROData_Tool::ComputePointState( thePoint.XY(), anIt.Face() ) == TopAbs_IN )
681     {
682       theType = anIt.StricklerType();
683       return anIt.Face();
684     }
685
686   theType = "";
687   return TopoDS_Face();
688 }