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