]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_DTM.h
Salome HOME
limite hauteur interpolation stream
[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 "HYDROData_Profile.h"
24
25 #include <gp_Pnt2d.hxx>
26
27 #include<Geom2d_BSplineCurve.hxx>
28 #include<Geom2d_Curve.hxx>
29 #include<Geom_Plane.hxx>
30
31 #include <TopTools_DataMapOfShapeListOfShape.hxx>
32 #include <TopTools_IndexedMapOfOrientedShape.hxx>
33 #include <TopTools_SequenceOfShape.hxx>
34
35 #include <vector>
36 #include <set>
37
38 class gp_Pnt;
39 class gp_Vec2d;
40 class TopoDS_Edge;
41 class TopoDS_Wire;
42 class TopoDS_Face;
43 class TopoDS_Compound;
44
45
46 /**\class HYDROData_DTM
47  * \brief Class that represents the Digital Terrain Model
48  */
49 class HYDROData_DTM : public HYDROData_Bathymetry
50 {
51 protected:
52   /**
53    * Enumeration of tags corresponding to the persistent object parameters.
54    */
55   enum DataTag
56   {
57     DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
58     DataTag_Profiles,
59     DataTag_DDZ,
60     DataTag_SpatialStep,
61     DataTag_LeftBankShape,
62     DataTag_RightBankShape,
63     DataTag_InletShape,
64     DataTag_OutletShape,
65     DataTag_3DShape,
66     DataTag_2DShape
67   };
68
69 public:
70   DEFINE_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry );
71
72   HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
73   HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
74
75   HYDRODATA_EXPORT double GetDDZ() const;
76   HYDRODATA_EXPORT void SetDDZ( double );
77
78   HYDRODATA_EXPORT double GetSpatialStep() const;
79   HYDRODATA_EXPORT void SetSpatialStep( double );
80
81   HYDRODATA_EXPORT virtual void Update();
82
83 public:
84   struct PointUZ
85   {
86     PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
87     double U;
88     double Z;
89   };
90   class CurveUZ : public std::vector<PointUZ>
91   {
92   public:
93     CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir, double theDeltaZ, double theMaxZ );
94     ~CurveUZ();
95
96     double Xcurv() const;
97     gp_Vec2d ProfileDir() const;
98     double DeltaZ() const;
99     double MaxZ() const;
100
101     CurveUZ operator + ( const CurveUZ& ) const;
102     CurveUZ operator * ( double ) const;
103
104   private:
105     double myXcurv;
106     gp_Vec2d myProfileDir;
107     double myDeltaZ;
108     double myMaxZ;
109   };
110
111 protected:
112   friend class HYDROData_Stream;
113   friend class HYDROData_Iterator;
114   friend class test_HYDROData_DTM;
115
116   HYDRODATA_EXPORT HYDROData_DTM();
117   virtual HYDRODATA_EXPORT ~HYDROData_DTM();
118
119   static Handle(Geom2d_BSplineCurve) CreateHydraulicAxis( 
120     const std::vector<Handle(HYDROData_Profile)>& theProfiles,
121     std::vector<double>& theDistances );
122
123   static std::vector<Handle(Geom2d_Curve)> ProfileToParametric( const Handle(HYDROData_Profile)& theProfile,
124                                                                 double& theUMin, double& theUMax,
125                                                                 gp_Vec2d& theDir );
126
127   static void GetProperties( const Handle(HYDROData_Profile)& theProfile,
128                              gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
129                              double& theZMin, double& theZMax );
130
131   static void ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile,
132                                      double theXCurv, double theMinZ, double theMaxZ, double theTopZ, double theDDZ,
133                                      CurveUZ& theMidPointCurve,
134                                      CurveUZ& theWidthCurve,
135                                      int& intersection_nb,
136                                      double theTolerance = 1E-6 );
137
138   static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
139                          const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
140                          AltitudePoints& thePoints );
141   
142   static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
143                            int theNbSteps, std::vector<CurveUZ>& theInterpolation,
144                            bool isAddSecond );
145
146   static std::vector<AltitudePoints> Interpolate
147     ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
148       const Handle(HYDROData_Profile)& theProfileA,
149       double theXCurvA,
150       const Handle(HYDROData_Profile)& theProfileB,
151       double theXCurvB,
152       double theDDZ, int theNbSteps, bool isAddSecond,
153       int& inter_nb_1, int& inter_nb_2 );
154
155   static AltitudePoints Interpolate( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
156                                      double theDDZ, double theSpatialStep,
157                                      AltitudePoints& theLeft,
158                                      AltitudePoints& theRight,
159                                      std::vector<AltitudePoints>& theMainProfiles,
160                                      std::set<int>& invalInd );
161
162   static void PointsToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
163
164   static void PointsToEdge(const AltitudePoints& pnts, TopoDS_Edge& E );
165
166   //static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
167     //TopTools_DataMapOfShapeListOfShape* E2PE);
168
169   static bool GetPlanarFaceFromBanks(const TopoDS_Edge& LB, const TopoDS_Edge& RB, TopoDS_Face& outF,
170     TopTools_SequenceOfShape* Boundr);
171
172   static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
173                                                           const AltitudePoints& right,
174                                                           const std::vector<AltitudePoints>& main_profiles);
175
176   static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
177                              double theDDZ,
178                              double theSpatialStep,
179                              AltitudePoints& theOutLeft,
180                              AltitudePoints& theOutRight,
181                              AltitudePoints& theOutPoints,
182                              std::vector<AltitudePoints>& theOutMainProfiles,
183                              TopoDS_Shape& Out3dPres,
184                              TopoDS_Shape& Out2dPres,
185                              TopoDS_Shape& OutLeftB,
186                              TopoDS_Shape& OutRightB,
187                              TopoDS_Shape& OutInlet,
188                              TopoDS_Shape& OutOutlet,
189                              bool Create3dPres,
190                              bool Create2dPres,
191                              std::set<int>& InvInd,
192                              bool& ProjStat);
193
194   //static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF, 
195     //TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
196   
197   static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
198                                double theDDZ, double theSpatialStep );
199
200   void GetPresentationShapes( TopoDS_Shape& Out3dPres,
201                               TopoDS_Shape& Out2dPres,
202                               TopoDS_Shape& OutLeftB,
203                               TopoDS_Shape& OutRightB,
204                               TopoDS_Shape& OutInlet,
205                               TopoDS_Shape& OutOutlet );
206 public:
207
208   HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
209                                                        double ddz,
210                                                        double step, 
211                                                        AltitudePoints& points,
212                                                        TopoDS_Shape& Out3dPres,
213                                                        TopoDS_Shape& Out2dPres,
214                                                        TopoDS_Shape& OutLeftB,
215                                                        TopoDS_Shape& OutRightB,
216                                                        TopoDS_Shape& OutInlet,
217                                                        TopoDS_Shape& OutOutlet,
218                                                        bool Create3dPres,
219                                                        bool Create2dPres,
220                                                        std::set<int>& InvInd,
221                                                        int thePntsLimit,
222                                                        bool& WireIntersections);
223 };
224
225
226
227
228 #endif