Salome HOME
Merge branch 'BR_MULTI_BATHS' into HEAD
[modules/hydro.git] / src / HYDROData / HYDROData_DTM.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_DTM_HeaderFile
20 #define HYDROData_DTM_HeaderFile
21
22 #include "HYDROData_Bathymetry.h"
23 #include <vector>
24
25 class Handle_HYDROData_Profile;
26 class Handle_Geom2d_BSplineCurve;
27 class Handle_Geom2d_Curve;
28 class gp_Pnt;
29 class gp_Vec2d;
30
31 DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
32
33 /**\class HYDROData_DTM
34  * \brief Class that represents the Digital Terrain Model
35  */
36 class HYDROData_DTM : public HYDROData_Bathymetry
37 {
38 protected:
39   /**
40    * Enumeration of tags corresponding to the persistent object parameters.
41    */
42   enum DataTag
43   {
44     DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
45     DataTag_Profiles,
46     DataTag_DDZ,
47     DataTag_SpatialStep,
48   };
49
50 public:
51   DEFINE_STANDARD_RTTI( HYDROData_DTM );
52
53   HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
54   HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
55
56   HYDRODATA_EXPORT double GetDDZ() const;
57   HYDRODATA_EXPORT void SetDDZ( double );
58
59   HYDRODATA_EXPORT double GetSpatialStep() const;
60   HYDRODATA_EXPORT void SetSpatialStep( double );
61
62   HYDRODATA_EXPORT virtual void Update();
63
64 public:
65   struct PointUZ
66   {
67     PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
68     double U;
69     double Z;
70   };
71   class CurveUZ : public std::vector<PointUZ>
72   {
73   public:
74     CurveUZ( double theXcurv );
75     ~CurveUZ();
76
77     double Xcurv() const;
78
79     CurveUZ operator + ( const CurveUZ& ) const;
80     CurveUZ operator * ( double ) const;
81
82   private:
83     double myXcurv;
84   };
85
86 protected:
87   friend class HYDROData_Iterator;
88   friend class test_HYDROData_DTM;
89
90   HYDRODATA_EXPORT HYDROData_DTM();
91   virtual HYDRODATA_EXPORT ~HYDROData_DTM();
92
93   static Handle_Geom2d_BSplineCurve CreateHydraulicAxis( 
94     const std::vector<Handle_HYDROData_Profile>& theProfiles,
95     std::vector<double>& theDistances );
96
97   static std::vector<Handle_Geom2d_Curve> ProfileToParametric( const Handle_HYDROData_Profile& theProfile,
98                                                                double& theUMin, double& theUMax );
99
100   static void GetProperties( const Handle_HYDROData_Profile& theProfile,
101                              gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
102                              bool isNormalDir,
103                              double& theZMin, double& theZMax );
104
105   static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
106                                      double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
107                                      CurveUZ& theMidPointCurve,
108                                      CurveUZ& theWidthCurve,
109                                      double theTolerance = 1E-6 );
110
111   static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
112                          const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
113                          AltitudePoints& thePoints );
114   
115   static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
116                            int theNbSteps, std::vector<CurveUZ>& theInterpolation,
117                            bool isAddSecond );
118
119   static AltitudePoints Interpolate( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
120                                      const Handle_HYDROData_Profile& theProfileA,
121                                      double theXCurvA,
122                                      const Handle_HYDROData_Profile& theProfileB,
123                                      double theXCurvB,
124                                      double theDDZ, int theNbSteps, bool isAddSecond );
125
126   static AltitudePoints Interpolate( const std::vector<Handle_HYDROData_Profile>& theProfiles,
127                                      double theDDZ, double theSpatialStep );
128 };
129
130 #endif