]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_DTM.h
Salome HOME
new presentation using DTM
[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 #include <gp_Pnt2d.hxx>
25
26 class Handle_HYDROData_Profile;
27 class Handle_Geom2d_BSplineCurve;
28 class Handle_Geom2d_Curve;
29 class gp_Pnt;
30 class gp_Vec2d;
31 class TopoDS_Edge;
32
33 DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
34
35 /**\class HYDROData_DTM
36  * \brief Class that represents the Digital Terrain Model
37  */
38 class HYDROData_DTM : public HYDROData_Bathymetry
39 {
40 protected:
41   /**
42    * Enumeration of tags corresponding to the persistent object parameters.
43    */
44   enum DataTag
45   {
46     DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
47     DataTag_Profiles,
48     DataTag_DDZ,
49     DataTag_SpatialStep,
50   };
51
52 public:
53   DEFINE_STANDARD_RTTI( HYDROData_DTM );
54
55   HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
56   HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
57
58   HYDRODATA_EXPORT double GetDDZ() const;
59   HYDRODATA_EXPORT void SetDDZ( double );
60
61   HYDRODATA_EXPORT double GetSpatialStep() const;
62   HYDRODATA_EXPORT void SetSpatialStep( double );
63
64   HYDRODATA_EXPORT virtual void Update();
65
66   HYDRODATA_EXPORT void CreateBankShapes( TopoDS_Edge& theLeft, TopoDS_Edge& theRight ) const;
67
68 public:
69   struct PointUZ
70   {
71     PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
72     double U;
73     double Z;
74   };
75   class CurveUZ : public std::vector<PointUZ>
76   {
77   public:
78     CurveUZ( double theXcurv );
79     ~CurveUZ();
80
81     double Xcurv() const;
82
83     CurveUZ operator + ( const CurveUZ& ) const;
84     CurveUZ operator * ( double ) const;
85
86   private:
87     double myXcurv;
88   };
89   class Bank
90   {
91   public:
92     void reserve( int theNbPoints );
93     void push_back( const gp_Pnt& thePnt, const gp_Dir& theTangent );
94     void clear();
95     TopoDS_Edge createEdge3d() const;
96
97   private:
98     std::vector<gp_Pnt> myPoints;
99     std::vector<gp_Dir> myDirs;
100   };
101
102 protected:
103   friend class HYDROData_Iterator;
104   friend class test_HYDROData_DTM;
105
106   HYDRODATA_EXPORT HYDROData_DTM();
107   virtual HYDRODATA_EXPORT ~HYDROData_DTM();
108
109   static Handle_Geom2d_BSplineCurve CreateHydraulicAxis( 
110     const std::vector<Handle_HYDROData_Profile>& theProfiles,
111     std::vector<double>& theDistances );
112
113   static std::vector<Handle_Geom2d_Curve> ProfileToParametric( const Handle_HYDROData_Profile& theProfile,
114                                                                double& theUMin, double& theUMax );
115
116   static void GetProperties( const Handle_HYDROData_Profile& theProfile,
117                              gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
118                              bool isNormalDir,
119                              double& theZMin, double& theZMax );
120
121   static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
122                                      double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
123                                      CurveUZ& theMidPointCurve,
124                                      CurveUZ& theWidthCurve,
125                                      double theTolerance = 1E-6 );
126
127   static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
128                          const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
129                          AltitudePoints& thePoints,
130                          Bank* theLeftBank = 0,
131                          Bank* theRightBank = 0,
132                          double dz = 0 );
133   
134   static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
135                            int theNbSteps, std::vector<CurveUZ>& theInterpolation,
136                            bool isAddSecond );
137
138   static AltitudePoints Interpolate( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
139                                      const Handle_HYDROData_Profile& theProfileA,
140                                      double theXCurvA,
141                                      const Handle_HYDROData_Profile& theProfileB,
142                                      double theXCurvB,
143                                      double theDDZ, int theNbSteps, bool isAddSecond,
144                                      Bank* theLeftBank = 0,
145                                      Bank* theRightBank = 0 );
146
147   static AltitudePoints Interpolate( const std::vector<Handle_HYDROData_Profile>& theProfiles,
148                                      double theDDZ, double theSpatialStep,
149                                      Bank* theLeftBank = 0,
150                                      Bank* theRightBank = 0 );
151
152 private:
153   Bank myLeft;
154   Bank myRight;
155 };
156
157 #endif