]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_DTM.h
Salome HOME
Merge branch 'BR_HYDRO_IMPS_2016' of ssh://gitolite3@git.salome-platform.org/modules...
[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 );
94     ~CurveUZ();
95
96     double Xcurv() const;
97     gp_Vec2d ProfileDir() const;
98     double DeltaZ() const;
99
100     CurveUZ operator + ( const CurveUZ& ) const;
101     CurveUZ operator * ( double ) const;
102
103   private:
104     double myXcurv;
105     gp_Vec2d myProfileDir;
106     double myDeltaZ;
107   };
108
109 protected:
110   friend class HYDROData_Stream;
111   friend class HYDROData_Iterator;
112   friend class test_HYDROData_DTM;
113
114   HYDRODATA_EXPORT HYDROData_DTM();
115   virtual HYDRODATA_EXPORT ~HYDROData_DTM();
116
117   static Handle(Geom2d_BSplineCurve) CreateHydraulicAxis( 
118     const std::vector<Handle(HYDROData_Profile)>& theProfiles,
119     std::vector<double>& theDistances );
120
121   static std::vector<Handle(Geom2d_Curve)> ProfileToParametric( const Handle(HYDROData_Profile)& theProfile,
122                                                                 double& theUMin, double& theUMax,
123                                                                 gp_Vec2d& theDir );
124
125   static void GetProperties( const Handle(HYDROData_Profile)& theProfile,
126                              gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
127                              double& theZMin, double& theZMax );
128
129   static void ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile,
130                                      double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
131                                      CurveUZ& theMidPointCurve,
132                                      CurveUZ& theWidthCurve,
133                                      int& intersection_nb,
134                                      double theTolerance = 1E-6 );
135
136   static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
137                          const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
138                          AltitudePoints& thePoints );
139   
140   static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
141                            int theNbSteps, std::vector<CurveUZ>& theInterpolation,
142                            bool isAddSecond );
143
144   static std::vector<AltitudePoints> Interpolate
145     ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
146       const Handle(HYDROData_Profile)& theProfileA,
147       double theXCurvA,
148       const Handle(HYDROData_Profile)& theProfileB,
149       double theXCurvB,
150       double theDDZ, int theNbSteps, bool isAddSecond,
151       int& inter_nb_1, int& inter_nb_2 );
152
153   static AltitudePoints Interpolate( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
154                                      double theDDZ, double theSpatialStep,
155                                      AltitudePoints& theLeft,
156                                      AltitudePoints& theRight,
157                                      std::vector<AltitudePoints>& theMainProfiles,
158                                      std::set<int>& invalInd );
159
160   static void PointsToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
161
162   static void PointsToEdge(const AltitudePoints& pnts, TopoDS_Edge& E );
163
164   //static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
165     //TopTools_DataMapOfShapeListOfShape* E2PE);
166
167   static bool GetPlanarFaceFromBanks(const TopoDS_Edge& LB, const TopoDS_Edge& RB, TopoDS_Face& outF,
168     TopTools_SequenceOfShape* Boundr);
169
170   static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
171                                                           const AltitudePoints& right,
172                                                           const std::vector<AltitudePoints>& main_profiles);
173
174   static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
175                              double theDDZ,
176                              double theSpatialStep,
177                              AltitudePoints& theOutLeft,
178                              AltitudePoints& theOutRight,
179                              AltitudePoints& theOutPoints,
180                              std::vector<AltitudePoints>& theOutMainProfiles,
181                              TopoDS_Shape& Out3dPres,
182                              TopoDS_Shape& Out2dPres,
183                              TopoDS_Shape& OutLeftB,
184                              TopoDS_Shape& OutRightB,
185                              TopoDS_Shape& OutInlet,
186                              TopoDS_Shape& OutOutlet,
187                              bool Create3dPres,
188                              bool Create2dPres,
189                              std::set<int>& InvInd,
190                              bool& ProjStat);
191
192   //static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF, 
193     //TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
194   
195   static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
196                                double theDDZ, double theSpatialStep );
197
198   void GetPresentationShapes( TopoDS_Shape& Out3dPres,
199                               TopoDS_Shape& Out2dPres,
200                               TopoDS_Shape& OutLeftB,
201                               TopoDS_Shape& OutRightB,
202                               TopoDS_Shape& OutInlet,
203                               TopoDS_Shape& OutOutlet );
204 public:
205
206   HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
207                                                        double ddz,
208                                                        double step, 
209                                                        AltitudePoints& points,
210                                                        TopoDS_Shape& Out3dPres,
211                                                        TopoDS_Shape& Out2dPres,
212                                                        TopoDS_Shape& OutLeftB,
213                                                        TopoDS_Shape& OutRightB,
214                                                        TopoDS_Shape& OutInlet,
215                                                        TopoDS_Shape& OutOutlet,
216                                                        bool Create3dPres,
217                                                        bool Create2dPres,
218                                                        std::set<int>& InvInd,
219                                                        int thePntsLimit,
220                                                        bool& WireIntersections);
221 };
222
223
224
225
226 #endif