]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_DTM.h
Salome HOME
Merge remote-tracking branch 'remotes/origin/BR_PORTING_OCCT_7' into BR_PORTING_OCCT_7
[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 PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
161
162   static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle(Geom_Plane)& RefPlane,
163     TopTools_DataMapOfShapeListOfShape* E2PE);
164
165   static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
166                                                           const AltitudePoints& right,
167                                                           const std::vector<AltitudePoints>& main_profiles);
168
169   static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
170                              double theDDZ,
171                              double theSpatialStep,
172                              AltitudePoints& theOutLeft,
173                              AltitudePoints& theOutRight,
174                              AltitudePoints& theOutPoints,
175                              std::vector<AltitudePoints>& theOutMainProfiles,
176                              TopoDS_Shape& Out3dPres,
177                              TopoDS_Shape& Out2dPres,
178                              TopoDS_Shape& OutLeftB,
179                              TopoDS_Shape& OutRightB,
180                              TopoDS_Shape& OutInlet,
181                              TopoDS_Shape& OutOutlet,
182                              bool Create3dPres,
183                              bool Create2dPres,
184                              std::set<int>& InvInd,
185                              bool& WireIntersections);
186
187   static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF, 
188     TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
189   
190   static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
191                                double theDDZ, double theSpatialStep );
192
193   void GetPresentationShapes( TopoDS_Shape& Out3dPres,
194                               TopoDS_Shape& Out2dPres,
195                               TopoDS_Shape& OutLeftB,
196                               TopoDS_Shape& OutRightB,
197                               TopoDS_Shape& OutInlet,
198                               TopoDS_Shape& OutOutlet );
199 public:
200
201   HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
202                                                        double ddz,
203                                                        double step, 
204                                                        AltitudePoints& points,
205                                                        TopoDS_Shape& Out3dPres,
206                                                        TopoDS_Shape& Out2dPres,
207                                                        TopoDS_Shape& OutLeftB,
208                                                        TopoDS_Shape& OutRightB,
209                                                        TopoDS_Shape& OutInlet,
210                                                        TopoDS_Shape& OutOutlet,
211                                                        bool Create3dPres,
212                                                        bool Create2dPres,
213                                                        std::set<int>& InvInd,
214                                                        int thePntsLimit,
215                                                        bool& WireIntersections);
216 };
217
218
219
220
221 #endif