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