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;
38 class TopTools_DataMapOfShapeListOfShape;
39 class TopTools_SequenceOfShape;
41 DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
43 /**\class HYDROData_DTM
44 * \brief Class that represents the Digital Terrain Model
46 class HYDROData_DTM : public HYDROData_Bathymetry
50 * Enumeration of tags corresponding to the persistent object parameters.
54 DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
58 DataTag_LeftBankShape,
59 DataTag_RightBankShape,
67 DEFINE_STANDARD_RTTI( HYDROData_DTM );
69 HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
70 HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
72 HYDRODATA_EXPORT double GetDDZ() const;
73 HYDRODATA_EXPORT void SetDDZ( double );
75 HYDRODATA_EXPORT double GetSpatialStep() const;
76 HYDRODATA_EXPORT void SetSpatialStep( double );
78 HYDRODATA_EXPORT virtual void Update();
83 PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
87 class CurveUZ : public std::vector<PointUZ>
90 CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir, double theDeltaZ );
94 gp_Vec2d ProfileDir() const;
95 double DeltaZ() const;
97 CurveUZ operator + ( const CurveUZ& ) const;
98 CurveUZ operator * ( double ) const;
102 gp_Vec2d myProfileDir;
107 friend class HYDROData_Stream;
108 friend class HYDROData_Iterator;
109 friend class test_HYDROData_DTM;
111 HYDRODATA_EXPORT HYDROData_DTM();
112 virtual HYDRODATA_EXPORT ~HYDROData_DTM();
114 static Handle_Geom2d_BSplineCurve CreateHydraulicAxis(
115 const std::vector<Handle_HYDROData_Profile>& theProfiles,
116 std::vector<double>& theDistances );
118 static std::vector<Handle_Geom2d_Curve> ProfileToParametric( const Handle_HYDROData_Profile& theProfile,
119 double& theUMin, double& theUMax,
122 static void GetProperties( const Handle_HYDROData_Profile& theProfile,
123 gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
125 double& theZMin, double& theZMax );
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 );
134 static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
135 const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
136 AltitudePoints& thePoints );
138 static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB,
139 int theNbSteps, std::vector<CurveUZ>& theInterpolation,
142 static std::vector<AltitudePoints> Interpolate
143 ( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
144 const Handle_HYDROData_Profile& theProfileA,
146 const Handle_HYDROData_Profile& theProfileB,
148 double theDDZ, int theNbSteps, bool isAddSecond,
149 int& inter_nb_1, int& inter_nb_2 );
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 );
158 static void PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
160 static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
161 TopTools_DataMapOfShapeListOfShape* E2PE);
163 static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
164 const AltitudePoints& right,
165 const std::vector<AltitudePoints>& main_profiles);
167 static void CreateProfiles(const std::vector<Handle_HYDROData_Profile>& theProfiles,
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,
182 std::set<int>& InvInd,
183 bool& WireIntersections);
185 static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF,
186 TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
188 static int EstimateNbPoints( const std::vector<Handle_HYDROData_Profile>& theProfiles,
189 double theDDZ, double theSpatialStep );
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 );
199 HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
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,
211 std::set<int>& InvInd,
213 bool& WireIntersections);