]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_DTM.h
Salome HOME
stream/channel/dtm presentation redisign + bug fixes for old brep proj, etc.. (draft)
[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 class TopoDS_Face;
34 class TopoDS_Compound;
35 class Handle_Geom_Plane;
36 class TopTools_IndexedMapOfOrientedShape;
37
38 DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
39
40 /**\class HYDROData_DTM
41  * \brief Class that represents the Digital Terrain Model
42  */
43 class HYDROData_DTM : public HYDROData_Bathymetry
44 {
45 protected:
46   /**
47    * Enumeration of tags corresponding to the persistent object parameters.
48    */
49   enum DataTag
50   {
51     DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
52     DataTag_Profiles,
53     DataTag_DDZ,
54     DataTag_SpatialStep,
55     DataTag_LeftBankShape,
56     DataTag_RightBankShape,
57     DataTag_InletShape,
58     DataTag_OutletShape,
59     DataTag_3DShape,
60     DataTag_2DShape
61   };
62
63 public:
64   DEFINE_STANDARD_RTTI( HYDROData_DTM );
65
66   HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
67   HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
68
69   HYDRODATA_EXPORT double GetDDZ() const;
70   HYDRODATA_EXPORT void SetDDZ( double );
71
72   HYDRODATA_EXPORT double GetSpatialStep() const;
73   HYDRODATA_EXPORT void SetSpatialStep( double );
74
75   HYDRODATA_EXPORT virtual void Update();
76
77 public:
78   struct PointUZ
79   {
80     PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
81     double U;
82     double Z;
83   };
84   class CurveUZ : public std::vector<PointUZ>
85   {
86   public:
87     CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir = gp_Vec2d() );
88     ~CurveUZ();
89
90     double Xcurv() const;
91     gp_Vec2d ProfileDir() const; 
92
93     CurveUZ operator + ( const CurveUZ& ) const;
94     CurveUZ operator * ( double ) const;
95
96   private:
97     double myXcurv;
98     gp_Vec2d myProfileDir;
99   };
100
101 protected:
102   friend class HYDROData_Stream;
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                                                                gp_Vec2d& theDir );
116
117   static void GetProperties( const Handle_HYDROData_Profile& theProfile,
118                              gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
119                              bool isNormalDir,
120                              double& theZMin, double& theZMax );
121
122   static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
123                                      double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
124                                      CurveUZ& theMidPointCurve,
125                                      CurveUZ& theWidthCurve,
126                                      double theTolerance = 1E-6 );
127
128   static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
129                          const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
130                          AltitudePoints& thePoints, double dz );
131   
132   static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
133                            int theNbSteps, std::vector<CurveUZ>& theInterpolation,
134                            bool isAddSecond );
135
136   static std::vector<AltitudePoints> Interpolate
137     ( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
138       const Handle_HYDROData_Profile& theProfileA,
139       double theXCurvA,
140       const Handle_HYDROData_Profile& theProfileB,
141       double theXCurvB,
142       double theDDZ, int theNbSteps, bool isAddSecond );
143
144   static AltitudePoints Interpolate( const std::vector<Handle_HYDROData_Profile>& theProfiles,
145                                      double theDDZ, double theSpatialStep,
146                                      AltitudePoints& theLeft,
147                                      AltitudePoints& theRight,
148                                      std::vector<AltitudePoints>& theMainProfiles );
149
150   static void PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
151
152   static void ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire);
153
154   static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
155                                                           const AltitudePoints& right,
156                                                           const std::vector<AltitudePoints>& main_profiles);
157
158   static void CreateProfiles(const std::vector<Handle_HYDROData_Profile>& theProfiles,
159                              double theDDZ,
160                              double theSpatialStep,
161                              AltitudePoints& theOutLeft,
162                              AltitudePoints& theOutRight,
163                              AltitudePoints& theOutPoints,
164                              std::vector<AltitudePoints>& theOutMainProfiles,
165                              TopoDS_Shape& Out3dPres,
166                              TopoDS_Shape& Out2dPres,
167                              TopoDS_Shape& OutLeftB,
168                              TopoDS_Shape& OutRightB,
169                              TopoDS_Shape& OutInlet,
170                              TopoDS_Shape& OutOutlet,
171                              bool Create3dPres,
172                              bool Create2dPres );
173
174   static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF );
175     
176   void GetPresentationShapes( TopoDS_Shape& Out3dPres,
177                               TopoDS_Shape& Out2dPres,
178                               TopoDS_Shape& OutLeftB,
179                               TopoDS_Shape& OutRightB,
180                               TopoDS_Shape& OutInlet,
181                               TopoDS_Shape& OutOutlet );
182 public:
183
184   HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
185                                       double ddz,
186                                       double step, 
187                                       AltitudePoints& points,
188                                       TopoDS_Shape& Out3dPres,
189                                       TopoDS_Shape& Out2dPres,
190                                       TopoDS_Shape& OutLeftB,
191                                       TopoDS_Shape& OutRightB,
192                                       TopoDS_Shape& OutInlet,
193                                       TopoDS_Shape& OutOutlet,
194                                       bool Create3dPres,
195                                       bool Create2dPres );
196 };
197
198
199
200
201 #endif