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_Stream_HeaderFile
20 #define HYDROData_Stream_HeaderFile
22 #include "HYDROData_NaturalObject.h"
24 #include <TopoDS_Face.hxx>
25 #include <TopoDS_Edge.hxx>
26 #include <TopoDS_Wire.hxx>
28 #include <Geom_BSplineCurve.hxx>
30 #include <NCollection_DataMap.hxx>
35 class HYDROData_PolylineXY;
36 class HYDROData_Polyline3D;
37 class HYDROData_Profile;
38 class HYDROData_IProfilesInterpolator;
39 class TopTools_HArray1OfShape;
42 /**\class HYDROData_Stream
46 class HYDROData_Stream : public HYDROData_NaturalObject
54 TopoDS_Shape myLeftBank; // 3d curve of the left bank
55 TopoDS_Shape myRightBank; // 3d curve of the right bank
56 TopoDS_Shape myInlet; // first (inlet) 2d profile
57 TopoDS_Shape myOutlet; // last (inlet) 2d profile
62 * Enumeration of tags corresponding to the persistent object parameters.
66 DataTag_First = HYDROData_NaturalObject::DataTag_First + 100, ///< first tag, to reserve
67 DataTag_HydraulicAxis, ///< reference hydraulic axis
68 DataTag_Profile, ///< reference profiles
69 DataTag_ParamsArray, ///< parameters array
70 DataTag_BottomPolyline, ///< reference bottom polyline
71 DataTag_InterpMethod ///< interpolation method (via DTM(0) or LISM(1))
75 DEFINE_STANDARD_RTTIEXT(HYDROData_Stream, HYDROData_NaturalObject);
80 * Creates the presentations(2D and 3D) by given hydraulic axis and profiles.
82 HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_DTM)& theDTM,
83 PrsDefinition& thePrs );
85 HYDRODATA_EXPORT static void CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt,
86 const Handle(TColgp_HArray1OfPnt) theArrayOfLPnt,
87 const Handle(TopTools_HArray1OfShape) theArrOfProfiles,
88 PrsDefinition& thePrs );
93 * Returns the kind of this object. Must be redefined in all objects of known type.
95 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_STREAM;}
98 * Dump object to Python script representation.
100 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
101 MapOfTreatedObjects& theTreatedObjects ) const;
104 * Returns the list of all reference objects of this object.
106 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
109 * Update the profiles order and shape presentations of stream.
110 * Call this method whenever you made changes for stream data.
112 HYDRODATA_EXPORT virtual void Update();
115 * Checks that object has 2D presentation. Reimlemented to retun true.
117 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
120 * Update the shape presentations of stream.
122 HYDRODATA_EXPORT void UpdatePrs( const Handle(HYDROData_DTM)& );
124 HYDRODATA_EXPORT void UpdatePrs( const Handle(HYDROData_LISM)& theLISM );
129 HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination,
130 bool isGenerateNewName ) const;
134 * Returns default filling color for new stream.
136 HYDRODATA_EXPORT virtual QColor DefaultFillingColor() const;
139 * Returns default border color for new stream.
141 HYDRODATA_EXPORT virtual QColor DefaultBorderColor() const;
144 * Returns true if given polyline can be used as stream axis.
146 HYDRODATA_EXPORT static bool IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theAxis );
149 // Public methods to work with Stream presentation
152 * Returns the left edge of the stream.
154 HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const;
157 * Returns the right edge of the stream.
159 HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const;
162 * Returns the inlet edge of the stream.
164 HYDRODATA_EXPORT virtual TopoDS_Shape GetInletShape() const;
167 * Returns the outlet edge of the stream.
169 HYDRODATA_EXPORT virtual TopoDS_Shape GetOutletShape() const;
173 // Public methods to work with Stream data fields
176 * Sets reference hydraulic axis object for stream.
178 HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
181 * Returns reference hydraulic axis object of stream.
183 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
186 * Remove reference hydraulic axis object from stream.
188 HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
190 HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) GetLeftBank() const;
192 HYDRODATA_EXPORT void SetLeftBank( const Handle(HYDROData_PolylineXY)& theBank );
194 HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) GetRightBank() const;
196 HYDRODATA_EXPORT void SetRightBank( const Handle(HYDROData_PolylineXY)& theBank );
198 * Returns true if profile has the intersection with the given hydraulic axis.
199 * Returns the parameter of inresection point on axis if axis is presented by one curve,
200 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
202 HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis,
203 const Handle(HYDROData_Profile)& theProfile,
204 const TopoDS_Face& thePlane,
205 Standard_Real& theOutPar );
208 * Returns true if profile has the intersection with reference hydraulic axis.
209 * Returns the parameter of inresection point on axis if axis is presented by one curve,
210 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
212 HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile,
213 const TopoDS_Face& thePlane,
214 Standard_Real& theOutPar ) const;
217 * Builds a planar face
219 HYDRODATA_EXPORT static void BuildRefFace( TopoDS_Face& thePlane );
222 * Add new one reference profile object for stream.
224 HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
227 * Add new one reference profile object for stream.
229 HYDRODATA_EXPORT virtual bool SetProfiles( const HYDROData_SequenceOfObjects& theProfiles,
230 const bool& theIsToOrder = true );
233 * Returns all reference profile objects of stream.
235 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
238 * Removes reference profile object from stream.
240 HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
243 * Removes all reference profile objects from stream.
245 HYDRODATA_EXPORT virtual void RemoveProfiles();
248 * Generates bottom polyline for stream or update the existing bottom polyline.
249 * \return true in case of success
251 HYDRODATA_EXPORT virtual bool GenerateBottomPolyline();
254 * Returns reference bottom polyline object of stream.
256 HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline3D) GetBottomPolyline() const;
259 * Sets reference bottom polyline object for stream.
260 * \param theBottom the polyline 3D
261 * \return true in case of success
263 HYDRODATA_EXPORT virtual bool SetBottomPolyline( const Handle(HYDROData_Polyline3D)& theBottom );
266 * Add interpolated profiles into the stream.
267 * \param theInterpolator the interpolator
268 * \return true in case of success
270 HYDRODATA_EXPORT virtual bool Interpolate( HYDROData_IProfilesInterpolator* theInterpolator );
273 HYDRODATA_EXPORT double GetDDZ() const;
274 HYDRODATA_EXPORT void SetDDZ( double theDDZ );
276 HYDRODATA_EXPORT int GetInterpolationMethod() const;
277 HYDRODATA_EXPORT void SetInterpolationMethod( int theDDZ );
279 HYDRODATA_EXPORT double GetSpatialStep() const;
280 HYDRODATA_EXPORT void SetSpatialStep( double theSpatialStep );
282 HYDRODATA_EXPORT double GetHaxStep() const;
283 HYDRODATA_EXPORT void SetHaxStep( double theHaxStep );
285 HYDRODATA_EXPORT int GetNbProfilePoints() const;
286 HYDRODATA_EXPORT void SetNbProfilePoints( int theNbPoints );
288 HYDRODATA_EXPORT void GetWarnings(NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings);
294 * Insert one profile in to the stream profiles order.
296 void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
297 const int theBeforeIndex = -1 );
300 * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
301 * If hydraulic axis is not set all profiles will be removed from order.
303 void updateProfilesOrder();
306 * Returns the type of child altitude object.
307 * Reimplemented to create stream altitude object.
309 HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
312 * Builds b-spline using interpolation algorithm.
314 static Handle(Geom_BSplineCurve) buildInterpolationCurve(
315 const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt );
319 void setParametersArray( const QVector<double>& theArray );
321 TColStd_Array1OfReal* getParametersArray() const;
323 void removeParametersArray();
325 int insertParameter( const Standard_Real& theParam );
327 void removeParameter( const int& theIndex );
329 Handle(HYDROData_DTM) DTM() const;
331 Handle(HYDROData_LISM) LISM() const;
333 void internalUpdatePrs( const PrsDefinition& aResultPrs );
337 friend class HYDROData_Iterator;
338 friend class test_HYDROData_Stream;
341 * Creates new object in the internal data structure. Use higher level objects
342 * to create objects with real content.
344 HYDRODATA_EXPORT HYDROData_Stream();
347 * Destructs properties of the object and object itself, removes it from the document.
349 virtual HYDRODATA_EXPORT ~HYDROData_Stream();
352 NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>> myWarnings;