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 PointsToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
162 static void PointsToEdge(const AltitudePoints& pnts, TopoDS_Edge& E );
164 //static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
165 //TopTools_DataMapOfShapeListOfShape* E2PE);
167 static bool GetPlanarFaceFromBanks(const TopoDS_Edge& LB, const TopoDS_Edge& RB, TopoDS_Face& outF,
168 TopTools_SequenceOfShape* Boundr);
170 static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
171 const AltitudePoints& right,
172 const std::vector<AltitudePoints>& main_profiles);
174 static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
176 double theSpatialStep,
177 AltitudePoints& theOutLeft,
178 AltitudePoints& theOutRight,
179 AltitudePoints& theOutPoints,
180 std::vector<AltitudePoints>& theOutMainProfiles,
181 TopoDS_Shape& Out3dPres,
182 TopoDS_Shape& Out2dPres,
183 TopoDS_Shape& OutLeftB,
184 TopoDS_Shape& OutRightB,
185 TopoDS_Shape& OutInlet,
186 TopoDS_Shape& OutOutlet,
189 std::set<int>& InvInd,
192 //static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF,
193 //TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
195 static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
196 double theDDZ, double theSpatialStep );
198 void GetPresentationShapes( TopoDS_Shape& Out3dPres,
199 TopoDS_Shape& Out2dPres,
200 TopoDS_Shape& OutLeftB,
201 TopoDS_Shape& OutRightB,
202 TopoDS_Shape& OutInlet,
203 TopoDS_Shape& OutOutlet );
206 HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
209 AltitudePoints& points,
210 TopoDS_Shape& Out3dPres,
211 TopoDS_Shape& Out2dPres,
212 TopoDS_Shape& OutLeftB,
213 TopoDS_Shape& OutRightB,
214 TopoDS_Shape& OutInlet,
215 TopoDS_Shape& OutOutlet,
218 std::set<int>& InvInd,
220 bool& WireIntersections);