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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROData_DTM_HeaderFile
20 #define HYDROData_DTM_HeaderFile
22 #include "HYDROData_Bathymetry.h"
25 #include <gp_Pnt2d.hxx>
27 class Handle_HYDROData_Profile;
28 class Handle_Geom2d_BSplineCurve;
29 class Handle_Geom2d_Curve;
35 class TopoDS_Compound;
36 class Handle_Geom_Plane;
37 class TopTools_IndexedMapOfOrientedShape;
39 DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
41 /**\class HYDROData_DTM
42 * \brief Class that represents the Digital Terrain Model
44 class HYDROData_DTM : public HYDROData_Bathymetry
48 * Enumeration of tags corresponding to the persistent object parameters.
52 DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
56 DataTag_LeftBankShape,
57 DataTag_RightBankShape,
65 DEFINE_STANDARD_RTTI( HYDROData_DTM );
67 HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
68 HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
70 HYDRODATA_EXPORT double GetDDZ() const;
71 HYDRODATA_EXPORT void SetDDZ( double );
73 HYDRODATA_EXPORT double GetSpatialStep() const;
74 HYDRODATA_EXPORT void SetSpatialStep( double );
76 HYDRODATA_EXPORT virtual void Update();
81 PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
85 class CurveUZ : public std::vector<PointUZ>
88 CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir = gp_Vec2d() );
92 gp_Vec2d ProfileDir() const;
94 CurveUZ operator + ( const CurveUZ& ) const;
95 CurveUZ operator * ( double ) const;
99 gp_Vec2d myProfileDir;
103 friend class HYDROData_Stream;
104 friend class HYDROData_Iterator;
105 friend class test_HYDROData_DTM;
107 HYDRODATA_EXPORT HYDROData_DTM();
108 virtual HYDRODATA_EXPORT ~HYDROData_DTM();
110 static Handle_Geom2d_BSplineCurve CreateHydraulicAxis(
111 const std::vector<Handle_HYDROData_Profile>& theProfiles,
112 std::vector<double>& theDistances );
114 static std::vector<Handle_Geom2d_Curve> ProfileToParametric( const Handle_HYDROData_Profile& theProfile,
115 double& theUMin, double& theUMax,
118 static void GetProperties( const Handle_HYDROData_Profile& theProfile,
119 gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
121 double& theZMin, double& theZMax );
123 static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
124 double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
125 CurveUZ& theMidPointCurve,
126 CurveUZ& theWidthCurve,
127 int& intersection_nb,
128 double theTolerance = 1E-6 );
130 static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
131 const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
132 AltitudePoints& thePoints, double dz );
134 static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB,
135 int theNbSteps, std::vector<CurveUZ>& theInterpolation,
138 static std::vector<AltitudePoints> Interpolate
139 ( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
140 const Handle_HYDROData_Profile& theProfileA,
142 const Handle_HYDROData_Profile& theProfileB,
144 double theDDZ, int theNbSteps, bool isAddSecond,
145 int& inter_nb_1, int& inter_nb_2 );
147 static AltitudePoints Interpolate( const std::vector<Handle_HYDROData_Profile>& theProfiles,
148 double theDDZ, double theSpatialStep,
149 AltitudePoints& theLeft,
150 AltitudePoints& theRight,
151 std::vector<AltitudePoints>& theMainProfiles,
152 std::set<int> invalInd );
154 static void PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
156 static void ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire);
158 static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
159 const AltitudePoints& right,
160 const std::vector<AltitudePoints>& main_profiles);
162 static void CreateProfiles(const std::vector<Handle_HYDROData_Profile>& theProfiles,
164 double theSpatialStep,
165 AltitudePoints& theOutLeft,
166 AltitudePoints& theOutRight,
167 AltitudePoints& theOutPoints,
168 std::vector<AltitudePoints>& theOutMainProfiles,
169 TopoDS_Shape& Out3dPres,
170 TopoDS_Shape& Out2dPres,
171 TopoDS_Shape& OutLeftB,
172 TopoDS_Shape& OutRightB,
173 TopoDS_Shape& OutInlet,
174 TopoDS_Shape& OutOutlet,
177 std::set<int> InvInd );
179 static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF );
181 void GetPresentationShapes( TopoDS_Shape& Out3dPres,
182 TopoDS_Shape& Out2dPres,
183 TopoDS_Shape& OutLeftB,
184 TopoDS_Shape& OutRightB,
185 TopoDS_Shape& OutInlet,
186 TopoDS_Shape& OutOutlet );
189 HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
192 AltitudePoints& points,
193 TopoDS_Shape& Out3dPres,
194 TopoDS_Shape& Out2dPres,
195 TopoDS_Shape& OutLeftB,
196 TopoDS_Shape& OutRightB,
197 TopoDS_Shape& OutInlet,
198 TopoDS_Shape& OutOutlet,
201 std::set<int> InvInd );