Salome HOME
Correct compilation errors after merge.
[modules/hydro.git] / src / HYDROData / HYDROData_LandCoverMap.h
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 #ifndef HYDROData_LANDCOVER_MAP_HeaderFile
20 #define HYDROData_LANDCOVER_MAP_HeaderFile
21
22 #include <HYDROData_Entity.h>
23 #include <TDataStd_ExtStringArray.hxx>
24 #include <QMap>
25
26 DEFINE_STANDARD_HANDLE( HYDROData_LandCoverMap, HYDROData_Entity )
27
28 class TopoDS_Face;
29 class TopoDS_Shape;
30 class TopoDS_Iterator;
31 class TopTools_ListOfShape;
32 class Handle( HYDROData_PolylineXY );
33 class Handle( HYDROData_Object );
34 class HYDROData_MapOfFaceToStricklerType;
35 class gp_Pnt2d;
36
37 class HYDROData_LandCoverMap : public HYDROData_Entity
38 {
39 protected:
40   friend class HYDROData_Iterator;
41
42   enum DataTag
43   {
44     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
45     DataTag_Shape,                                         ///< the shape presentation of the land cover map
46     DataTag_Types,
47   };
48
49 public:
50   class Iterator
51   {
52   public:
53     Iterator( const HYDROData_LandCoverMap& );
54     HYDRODATA_EXPORT Iterator( const Handle( HYDROData_LandCoverMap )& );
55     HYDRODATA_EXPORT ~Iterator();
56
57     void Init( const HYDROData_LandCoverMap& );
58     HYDRODATA_EXPORT bool More() const;
59     HYDRODATA_EXPORT void Next();
60     
61     int Index() const;
62     HYDRODATA_EXPORT TopoDS_Face Face() const;
63     HYDRODATA_EXPORT QString StricklerType() const;
64     void SetStricklerType( const QString& );
65
66   private:
67     TopoDS_Iterator* myIterator;
68     int              myIndex;
69     Handle(TDataStd_ExtStringArray) myArray;
70   };
71
72   enum DBFStatus
73   {
74     DBFStatus_OK,
75     DBFStatus_DIFF_SIZE_ERROR,
76     DBFStatus_OPEN_FILE_ERROR,
77     DBFStatus_NO_SUCH_FIELD_ERROR,
78     DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING
79   };
80
81   HYDROData_LandCoverMap();
82   ~HYDROData_LandCoverMap();
83
84   virtual const ObjectKind GetKind() const;
85
86   DBFStatus ImportDBF( const QString& theDBFFileName, 
87     const QString& theFieldName, 
88     const QStringList& DBFValues,
89     const QStringList& StricklerTypes,
90     QMap<int, int> theIndices );
91  
92   void ExportDBF( const QString& theDBFFileName,
93     const QString& theFieldName, 
94     const QStringList& theDBFValues,
95     const QStringList& theStricklerTypes) const;
96
97   bool ExportTelemac( const QString& theFileName, double theDeflection ) const;
98
99   bool Add( const Handle( HYDROData_Object )&, const QString& theType );
100   bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType );
101
102   bool Remove( const TopoDS_Face& );
103   bool Remove( const TopTools_ListOfShape& );
104
105   bool Split( const Handle( HYDROData_PolylineXY )& );
106   bool Merge( const TopTools_ListOfShape&, const QString& theType );
107
108   TopoDS_Face FindByPoint( const gp_Pnt2d&, QString& theType ) const;
109
110   HYDRODATA_EXPORT TopoDS_Shape GetShape() const;
111
112 protected:
113   void SetShape( const TopoDS_Shape& );
114
115   bool LocalPartition( const TopoDS_Shape&, const QString& theNewType );
116   static TopoDS_Shape MergeFaces(const TopTools_ListOfShape& theFaces,
117                       bool IsToUnify, double theTolerance = 1E-3 );
118   void StoreLandCovers( const HYDROData_MapOfFaceToStricklerType& );
119
120 public:
121   DEFINE_STANDARD_RTTI( HYDROData_LandCoverMap );
122
123 private:
124   friend class Iterator;
125   friend class test_HYDROData_LandCoverMap;
126 };
127
128 #endif