Salome HOME
7abf5e1258d94cce19a06e09cd4a3f5a7b60f48a
[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 #include <TopExp_Explorer.hxx>
28
29 class HYDROData_StricklerTable;
30 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
31
32 typedef NCollection_IndexedDataMap<TopoDS_Face, QString> HYDROData_MapOfFaceToStricklerType;
33
34 class TopoDS_Shape;
35 class TopoDS_Wire;
36 class TopoDS_Iterator;
37 class HYDROData_PolylineXY;
38 class HYDROData_Object;
39 class gp_Pnt2d;
40
41 class HYDROData_LandCoverMap : public HYDROData_Entity
42 {
43 protected:
44   friend class HYDROData_Iterator;
45
46   enum DataTag
47   {
48     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
49     DataTag_Shape,                                         ///< the shape presentation of the land cover map
50     DataTag_Types,
51     DataTag_Transparency,
52   };
53
54 public:
55   class Explorer
56   {
57   public:
58     Explorer( const HYDROData_LandCoverMap& );
59     HYDRODATA_EXPORT Explorer( const Handle( HYDROData_LandCoverMap )& );
60     HYDRODATA_EXPORT ~Explorer();
61
62     void Init( const HYDROData_LandCoverMap& );
63     HYDRODATA_EXPORT bool More() const;
64     HYDRODATA_EXPORT void Next();
65     
66     int Index() const;
67     HYDRODATA_EXPORT TopoDS_Face Face() const;
68     HYDRODATA_EXPORT QString StricklerType() const;
69     void SetStricklerType( const QString& );
70
71   private:
72     TopExp_Explorer* myExplorer;
73     int              myIndex;
74     Handle(TDataStd_ExtStringArray) myArray;
75   };
76
77   enum DBFStatus
78   {
79     DBFStatus_OK,
80     DBFStatus_DIFF_SIZE_ERROR,
81     DBFStatus_OPEN_FILE_ERROR,
82     DBFStatus_NO_SUCH_FIELD_ERROR,
83     DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING
84   };
85
86   HYDRODATA_EXPORT HYDROData_LandCoverMap();
87   HYDRODATA_EXPORT virtual ~HYDROData_LandCoverMap();
88
89   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const;
90
91   HYDRODATA_EXPORT bool ImportSHP( const QString& theSHPFileName,
92                                    const QList<int>& theIndices = QList<int>() );
93  
94   HYDRODATA_EXPORT bool ExportSHP( const QString& theSHPFileName, bool bUseDiscr = false, double theDefl = 0.1) const;
95
96   HYDRODATA_EXPORT DBFStatus ImportDBF( const QString& theDBFFileName, 
97                                         const QString& theFieldName, 
98                                         const QStringList& DBFValues,
99                                         const QStringList& StricklerTypes,
100                                         const QList<int>& theIndices = QList<int>() );
101
102   HYDRODATA_EXPORT void ExportDBF( const QString& theDBFFileName,
103                                    const QString& theFieldName, 
104                                    const QStringList& theDBFValues,
105                                    const QStringList& theStricklerTypes ) const;
106
107   HYDRODATA_EXPORT bool ExportTelemac( const QString& theFileName,
108                                        double theDeflection,
109                                        const Handle(HYDROData_StricklerTable)& theTable ) const;
110
111   HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType );
112   HYDRODATA_EXPORT bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType );
113
114   using HYDROData_Entity::Remove;
115   HYDRODATA_EXPORT bool Remove( const TopoDS_Face& );
116   HYDRODATA_EXPORT bool Remove( const TopTools_ListOfShape& );
117
118   HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& );
119   HYDRODATA_EXPORT bool Split( const TopoDS_Shape& );
120   HYDRODATA_EXPORT bool Merge( const TopTools_ListOfShape&, const QString& theType );
121
122   HYDRODATA_EXPORT bool ChangeType( const TopTools_ListOfShape&, const QString& theType );
123
124   HYDRODATA_EXPORT TopoDS_Face FindByPoint( const gp_Pnt2d&, QString& theType ) const;
125
126   HYDRODATA_EXPORT TopoDS_Shape GetShape() const;
127
128   HYDRODATA_EXPORT QString StricklerType( const TopoDS_Face& ) const;
129
130   HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
131                                                      MapOfTreatedObjects& theTreatedObjects ) const;
132
133   HYDRODATA_EXPORT int GetLCCount() const;
134   HYDRODATA_EXPORT bool IsEmpty() const;
135
136   HYDRODATA_EXPORT void StoreLandCovers( const HYDROData_MapOfFaceToStricklerType& );
137
138   HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
139
140   HYDRODATA_EXPORT void SetTransparency( double );
141   HYDRODATA_EXPORT double GetTransparency() const;
142
143   HYDRODATA_EXPORT void RemoveInternal(TopoDS_Shape& ShToRebuild, NCollection_IndexedDataMap<TopoDS_Face, TopoDS_Face>* aF2FReplace);
144
145   HYDRODATA_EXPORT bool CheckLinear();
146
147   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
148
149 protected:
150   void SetShape( const TopoDS_Shape& );
151
152   bool Add( const TopoDS_Wire&, const QString& );
153
154   bool LocalPartition( const TopoDS_Shape&, const QString& theNewType );
155
156   static TopoDS_Shape MergeFaces(const TopTools_ListOfShape& theFaces,
157                                  bool IsToUnify,
158                                  TopTools_IndexedDataMapOfShapeListOfShape* theShHistory = NULL, 
159                                  double theTolerance = 1E-5 );
160
161 public:
162   DEFINE_STANDARD_RTTIEXT( HYDROData_LandCoverMap, HYDROData_Entity );
163
164 private:
165   friend class Explorer;
166   friend class test_HYDROData_LandCoverMap;
167 };
168
169 #endif