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