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"
23 #include "HYDROData_Profile.h"
25 #include <gp_Pnt2d.hxx>
27 #include<Geom2d_BSplineCurve.hxx>
28 #include<Geom2d_Curve.hxx>
29 #include<Geom_Plane.hxx>
31 #include <TopTools_DataMapOfShapeListOfShape.hxx>
32 #include <TopTools_IndexedMapOfOrientedShape.hxx>
33 #include <TopTools_SequenceOfShape.hxx>
43 class TopoDS_Compound;
46 /**\class HYDROData_DTM
47 * \brief Class that represents the Digital Terrain Model
49 class HYDROData_DTM : public HYDROData_Bathymetry
53 * Enumeration of tags corresponding to the persistent object parameters.
57 DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
61 DataTag_LeftBankShape,
62 DataTag_RightBankShape,
70 DEFINE_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry );
72 HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
73 HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
75 HYDRODATA_EXPORT double GetDDZ() const;
76 HYDRODATA_EXPORT void SetDDZ( double );
78 HYDRODATA_EXPORT double GetSpatialStep() const;
79 HYDRODATA_EXPORT void SetSpatialStep( double );
81 HYDRODATA_EXPORT virtual void Update();
86 PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
90 class CurveUZ : public std::vector<PointUZ>
93 CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir, double theDeltaZ );
97 gp_Vec2d ProfileDir() const;
98 double DeltaZ() const;
100 CurveUZ operator + ( const CurveUZ& ) const;
101 CurveUZ operator * ( double ) const;
105 gp_Vec2d myProfileDir;
110 friend class HYDROData_Stream;
111 friend class HYDROData_Iterator;
112 friend class test_HYDROData_DTM;
114 HYDRODATA_EXPORT HYDROData_DTM();
115 virtual HYDRODATA_EXPORT ~HYDROData_DTM();
117 static Handle(Geom2d_BSplineCurve) CreateHydraulicAxis(
118 const std::vector<Handle(HYDROData_Profile)>& theProfiles,
119 std::vector<double>& theDistances );
121 static std::vector<Handle(Geom2d_Curve)> ProfileToParametric( const Handle(HYDROData_Profile)& theProfile,
122 double& theUMin, double& theUMax,
125 static void GetProperties( const Handle(HYDROData_Profile)& theProfile,
126 gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
127 double& theZMin, double& theZMax );
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 );
136 static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
137 const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
138 AltitudePoints& thePoints );
140 static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB,
141 int theNbSteps, std::vector<CurveUZ>& theInterpolation,
144 static std::vector<AltitudePoints> Interpolate
145 ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
146 const Handle(HYDROData_Profile)& theProfileA,
148 const Handle(HYDROData_Profile)& theProfileB,
150 double theDDZ, int theNbSteps, bool isAddSecond,
151 int& inter_nb_1, int& inter_nb_2 );
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 );
160 static void PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
162 static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle(Geom_Plane)& RefPlane,
163 TopTools_DataMapOfShapeListOfShape* E2PE);
165 static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
166 const AltitudePoints& right,
167 const std::vector<AltitudePoints>& main_profiles);
169 static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
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,
184 std::set<int>& InvInd,
185 bool& WireIntersections);
187 static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF,
188 TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
190 static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
191 double theDDZ, double theSpatialStep );
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 );
201 HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
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,
213 std::set<int>& InvInd,
215 bool& WireIntersections);