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