Salome HOME
porting on linux
[modules/hydro.git] / src / HYDROData / HYDROData_Bathymetry.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_Bathymetry_HeaderFile
20 #define HYDROData_Bathymetry_HeaderFile
21
22 #include "HYDROData_IAltitudeObject.h"
23 #include <vector>
24
25 class QFile;
26 class gp_XYZ;
27 class gp_XY;
28 class Handle_HYDROData_PolylineXY;
29 class HYDROData_QuadtreeNode;
30 class vtkPolyData;
31 class vtkIdList;
32
33 DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
34
35
36 /**\class HYDROData_Bathymetry
37  * \brief Class that stores/retreives information about the Bathymetry.
38  *
39  * The Bathymetry represents measurement of the altitude of points on the terrain.
40  */
41 class HYDROData_Bathymetry : public HYDROData_IAltitudeObject
42 {
43 public:
44   struct AltitudePoint
45   {
46     AltitudePoint( double x=0, double y=0, double z=0 ) { X=x; Y=y; Z=z; }
47     double X;
48     double Y;
49     double Z;
50   };
51   typedef std::vector<AltitudePoint> AltitudePoints;
52
53 protected:
54
55   /**
56    * Enumeration of tags corresponding to the persistent object parameters.
57    */
58   enum DataTag
59   {
60     DataTag_First = HYDROData_IAltitudeObject::DataTag_First + 100, ///< first tag, to reserve
61     DataTag_AltitudePoints,    ///< altitude points, array of reals
62     DataTag_FilePath,          ///< bathymetry imported file path
63     DataTag_FilePaths,         ///< bathymetry imported file paths
64     DataTag_AltitudesInverted, ///< flag to invert z values
65   };
66
67 public:
68
69   DEFINE_STANDARD_RTTI(HYDROData_Bathymetry);
70
71   /**
72    * Returns the kind of this object. Must be redefined in all objects of known type.
73    */
74   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_BATHYMETRY; }
75
76
77   /**
78    * Dump Bathymetry object to Python script representation.
79    */
80   HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
81                                                      MapOfTreatedObjects& theTreatedObjects ) const;
82
83 public:      
84   // Public methods to work with Bathymetry altitudes.
85
86   /**
87    * Replace current altitude points by new one.
88    * \param thePoints the altitude points list
89    */
90   HYDRODATA_EXPORT virtual void             SetAltitudePoints( const AltitudePoints& thePoints );
91
92   /**
93    * Returns altitude points list.
94    * \return points list
95    */
96   HYDRODATA_EXPORT virtual AltitudePoints   GetAltitudePoints(bool IsConvertToGlobal = false) const;
97   HYDRODATA_EXPORT virtual HYDROData_QuadtreeNode* GetQuadtreeNodes() const;
98
99 #ifndef LIGHT_MODE
100   HYDRODATA_EXPORT virtual vtkPolyData* GetVtkDelaunay2D() const;
101   //HYDRODATA_EXPORT bool interpolZtriangle(const gp_XY& point, vtkIdList* triangle, double* z);
102 #endif
103
104   /**
105    * Remove all altitude points.
106    */
107   HYDRODATA_EXPORT virtual void             RemoveAltitudePoints();
108
109   /**
110    * Returns altitude for given point.
111    * \param thePoint the point to examine
112    * \param theMethod interpolation model, default 0 = nearest point
113    * \return altitude value
114    */
115   HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint, int theMethod=0 ) const;
116
117 public:
118   // Public methods to work with files.
119
120   /**
121    * Stores the bathymetry file path
122    * \param theFilePath image file path
123    */
124   HYDRODATA_EXPORT void                     SetFilePath( const TCollection_AsciiString& theFilePath );
125
126   HYDRODATA_EXPORT void                     SetFilePaths( const QStringList& theFilePaths );
127
128   /**
129    * Returns uploaded bathymetry file path
130    */
131   HYDRODATA_EXPORT TCollection_AsciiString  GetFilePath() const;
132
133   HYDRODATA_EXPORT QStringList GetFilePaths() const;
134
135   /**
136    * Set flag indicating needs to invert altitude values
137    * \param theIsInverted new invert value
138    * \param theIsUpdate flag indicating necessity to update points
139    */
140   HYDRODATA_EXPORT void                     SetAltitudesInverted( const bool theIsInverted,
141                                                                   const bool theIsUpdate = true );
142
143   /**
144    * Returns flag indicating needs to invert altitude values.
145    */
146   HYDRODATA_EXPORT bool                     IsAltitudesInverted() const;
147
148   /**
149    * Imports Bathymetry data from file. The supported file types:
150    *  - xyz
151    * \param theFileName the path to file
152    * \return \c true if file has been successfully read
153    */
154   HYDRODATA_EXPORT virtual bool             ImportFromFiles( const QStringList& theFileNames );
155
156   HYDRODATA_EXPORT virtual bool             ImportFromFile( const QString& theFileName );
157
158   HYDRODATA_EXPORT Handle_HYDROData_PolylineXY CreateBoundaryPolyline() const;
159
160   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
161
162 private:
163
164   /**
165    * Imports Bathymetry data from 'XYZ' file.
166    */
167   bool                                      importFromXYZFile( QFile&          theFile,
168                                                                AltitudePoints& thePoints ) const;
169   static std::map<int, HYDROData_QuadtreeNode*> myQuadtrees;
170 #ifndef LIGHT_MODE
171   static std::map<int, vtkPolyData*> myDelaunay2D;
172 #endif
173   bool                                      importFromASCFile( QFile&          theFile,
174                                                                AltitudePoints& thePoints ) const;
175
176 protected:
177
178   friend class HYDROData_Iterator;
179
180   /**
181    * Creates new object in the internal data structure. Use higher level objects 
182    * to create objects with real content.
183    */
184   HYDRODATA_EXPORT HYDROData_Bathymetry();
185
186   /**
187    * Destructs properties of the object and object itself, removes it from the document.
188    */
189   HYDRODATA_EXPORT ~HYDROData_Bathymetry();
190 };
191
192 #endif