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