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