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>
37 #include <NCollection_DataMap.hxx>
44 class TopoDS_Compound;
47 /**\class HYDROData_DTM
48 * \brief Class that represents the Digital Terrain Model
50 class HYDROData_DTM : public HYDROData_Bathymetry
54 * Enumeration of tags corresponding to the persistent object parameters.
58 DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
62 DataTag_LeftBankShape,
63 DataTag_RightBankShape,
71 DEFINE_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry );
73 HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
74 HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
76 HYDRODATA_EXPORT double GetDDZ() const;
77 HYDRODATA_EXPORT void SetDDZ( double );
79 HYDRODATA_EXPORT double GetSpatialStep() const;
80 HYDRODATA_EXPORT void SetSpatialStep( double );
82 HYDRODATA_EXPORT virtual void Update();
87 PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
91 class CurveUZ : public std::vector<PointUZ>
94 CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir, double theDeltaZ, double theMaxZ );
98 gp_Vec2d ProfileDir() const;
99 double DeltaZ() const;
102 CurveUZ operator + ( const CurveUZ& ) const;
103 CurveUZ operator * ( double ) const;
107 gp_Vec2d myProfileDir;
113 friend class HYDROData_Stream;
114 friend class HYDROData_Iterator;
115 friend class test_HYDROData_DTM;
117 HYDRODATA_EXPORT HYDROData_DTM();
118 virtual HYDRODATA_EXPORT ~HYDROData_DTM();
120 static Handle(Geom2d_BSplineCurve) CreateHydraulicAxis(
121 const std::vector<Handle(HYDROData_Profile)>& theProfiles,
122 std::vector<double>& theDistances );
124 static std::vector<Handle(Geom2d_Curve)> ProfileToParametric( const Handle(HYDROData_Profile)& theProfile,
125 double& theUMin, double& theUMax,
128 static void GetProperties( const Handle(HYDROData_Profile)& theProfile,
129 gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
130 double& theZMin, double& theZMax );
132 static void ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile,
133 double theXCurv, double theMinZ, double theMaxZ, double theTopZ, double theDDZ,
134 CurveUZ& theMidPointCurve,
135 CurveUZ& theWidthCurve,
136 int& intersection_nb,
138 QSet<QString>& warnings);
140 static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
141 const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
142 AltitudePoints& thePoints );
144 static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB,
145 int theNbSteps, std::vector<CurveUZ>& theInterpolation,
148 static std::vector<AltitudePoints> Interpolate
149 ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
150 const Handle(HYDROData_Profile)& theProfileA,
152 const Handle(HYDROData_Profile)& theProfileB,
154 double theDDZ, int theNbSteps, bool isAddSecond,
155 int& inter_nb_1, int& inter_nb_2,
156 NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
157 bool ToEstimateWarningsOnly);
159 static AltitudePoints Interpolate( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
160 double theDDZ, double theSpatialStep,
161 AltitudePoints& theLeft,
162 AltitudePoints& theRight,
163 std::vector<AltitudePoints>& theMainProfiles,
164 std::set<int>& invalInd,
165 NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
166 bool ToEstimateWarningsOnly);
168 static void PointsToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
170 static void PointsToEdge(const AltitudePoints& pnts, TopoDS_Edge& E );
172 //static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
173 //TopTools_DataMapOfShapeListOfShape* E2PE);
175 static bool GetPlanarFaceFromBanks(const TopoDS_Edge& LB, const TopoDS_Edge& RB, TopoDS_Face& outF,
176 TopTools_SequenceOfShape* Boundr);
178 static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
179 const AltitudePoints& right,
180 const std::vector<AltitudePoints>& main_profiles);
182 static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
184 double theSpatialStep,
185 AltitudePoints& theOutLeft,
186 AltitudePoints& theOutRight,
187 AltitudePoints& theOutPoints,
188 std::vector<AltitudePoints>& theOutMainProfiles,
189 TopoDS_Shape& Out3dPres,
190 TopoDS_Shape& Out2dPres,
191 TopoDS_Shape& OutLeftB,
192 TopoDS_Shape& OutRightB,
193 TopoDS_Shape& OutInlet,
194 TopoDS_Shape& OutOutlet,
197 std::set<int>& InvInd,
199 NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
200 bool ToEstimateWarningsOnly);
202 //static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF,
203 //TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
205 static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
206 double theDDZ, double theSpatialStep );
208 void GetPresentationShapes( TopoDS_Shape& Out3dPres,
209 TopoDS_Shape& Out2dPres,
210 TopoDS_Shape& OutLeftB,
211 TopoDS_Shape& OutRightB,
212 TopoDS_Shape& OutInlet,
213 TopoDS_Shape& OutOutlet );
216 HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
219 AltitudePoints& points,
220 TopoDS_Shape& Out3dPres,
221 TopoDS_Shape& Out2dPres,
222 TopoDS_Shape& OutLeftB,
223 TopoDS_Shape& OutRightB,
224 TopoDS_Shape& OutInlet,
225 TopoDS_Shape& OutOutlet,
228 std::set<int>& InvInd,
230 bool& WireIntersections,
231 NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
232 bool& ToEstimateWarnings);
234 HYDRODATA_EXPORT void GetWarnings(NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings);
237 NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>> myWarnings;