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