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>
27 #include <Geom_BSplineCurve.hxx>
29 DEFINE_STANDARD_HANDLE(HYDROData_Stream, HYDROData_NaturalObject)
31 class Handle(HYDROData_PolylineXY);
32 class Handle(HYDROData_Polyline3D);
33 class Handle(HYDROData_Profile);
34 class HYDROData_IProfilesInterpolator;
35 class TColStd_Array1OfReal;
36 class Handle(TopTools_HArray1OfShape);
37 class Handle_HYDROData_DTM;
38 class TopTools_ListOfShape;
41 /**\class HYDROData_Stream
45 class HYDROData_Stream : public HYDROData_NaturalObject
53 TopoDS_Edge myLeftBank; // 3d curve of the left bank
54 TopoDS_Edge myRightBank; // 3d curve of the right bank
55 TopoDS_Edge myInlet; // first (inlet) 2d profile
56 TopoDS_Edge myOutlet; // last (inlet) 2d profile
61 * Enumeration of tags corresponding to the persistent object parameters.
65 DataTag_First = HYDROData_NaturalObject::DataTag_First + 100, ///< first tag, to reserve
66 DataTag_HydraulicAxis, ///< reference hydraulic axis
67 DataTag_Profile, ///< reference profiles
68 DataTag_ParamsArray, ///< parameters array
69 DataTag_BottomPolyline ///< reference bottom polyline
74 DEFINE_STANDARD_RTTI(HYDROData_Stream);
79 * Creates the presentations(2D and 3D) by given hydraulic axis and profiles.
81 HYDRODATA_EXPORT static bool CreatePresentations( const Handle_HYDROData_DTM& theDTM,
82 PrsDefinition& thePrs );
85 * Creates the presentations(2D and 3D) by given first points, last points and profiles.
86 * If 2D profiles is null - they will not used in the presentation.
88 HYDRODATA_EXPORT static bool CreatePresentations( const TopoDS_Edge& theLeftBank,
89 const TopoDS_Edge& theRightBank,
90 const TopTools_ListOfShape& theProfiles3d,
91 PrsDefinition& thePrs );
96 * Returns the kind of this object. Must be redefined in all objects of known type.
98 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_STREAM;}
101 * Dump object to Python script representation.
103 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
104 MapOfTreatedObjects& theTreatedObjects ) const;
107 * Returns the list of all reference objects of this object.
109 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
112 * Update the profiles order and shape presentations of stream.
113 * Call this method whenever you made changes for stream data.
115 HYDRODATA_EXPORT virtual void Update();
118 * Checks that object has 2D presentation. Reimlemented to retun true.
120 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
123 * Update the shape presentations of stream.
125 HYDRODATA_EXPORT void UpdatePrs( const Handle_HYDROData_DTM& );
130 HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination,
131 bool isGenerateNewName ) const;
135 * Returns default filling color for new stream.
137 HYDRODATA_EXPORT virtual QColor DefaultFillingColor() const;
140 * Returns default border color for new stream.
142 HYDRODATA_EXPORT virtual QColor DefaultBorderColor() const;
145 * Returns true if given polyline can be used as stream axis.
147 HYDRODATA_EXPORT static bool IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theAxis );
150 // Public methods to work with Stream presentation
153 * Returns the left edge of the stream.
155 HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const;
158 * Returns the right edge of the stream.
160 HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const;
163 * Returns the inlet edge of the stream.
165 HYDRODATA_EXPORT virtual TopoDS_Shape GetInletShape() const;
168 * Returns the outlet edge of the stream.
170 HYDRODATA_EXPORT virtual TopoDS_Shape GetOutletShape() const;
174 // Public methods to work with Stream data fields
177 * Sets reference hydraulic axis object for stream.
179 HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
182 * Returns reference hydraulic axis object of stream.
184 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
187 * Remove reference hydraulic axis object from stream.
189 HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
192 * Returns true if profile has the intersection with the given hydraulic axis.
193 * Returns the parameter of inresection point on axis if axis is presented by one curve,
194 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
196 HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis,
197 const Handle(HYDROData_Profile)& theProfile,
198 const TopoDS_Face& thePlane,
199 Standard_Real& theOutPar );
202 * Returns true if profile has the intersection with reference hydraulic axis.
203 * Returns the parameter of inresection point on axis if axis is presented by one curve,
204 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
206 HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile,
207 const TopoDS_Face& thePlane,
208 Standard_Real& theOutPar ) const;
211 * Builds a planar face
213 HYDRODATA_EXPORT static bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
214 TopoDS_Face& thePlane );
217 * Add new one reference profile object for stream.
219 HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
222 * Add new one reference profile object for stream.
224 HYDRODATA_EXPORT virtual bool SetProfiles( const HYDROData_SequenceOfObjects& theProfiles,
225 const bool& theIsToOrder = true );
228 * Returns all reference profile objects of stream.
230 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
233 * Removes reference profile object from stream.
235 HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
238 * Removes all reference profile objects from stream.
240 HYDRODATA_EXPORT virtual void RemoveProfiles();
243 * Generates bottom polyline for stream or update the existing bottom polyline.
244 * \return true in case of success
246 HYDRODATA_EXPORT virtual bool GenerateBottomPolyline();
249 * Returns reference bottom polyline object of stream.
251 HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline3D) GetBottomPolyline() const;
254 * Sets reference bottom polyline object for stream.
255 * \param theBottom the polyline 3D
256 * \return true in case of success
258 HYDRODATA_EXPORT virtual bool SetBottomPolyline( const Handle(HYDROData_Polyline3D)& theBottom );
261 * Add interpolated profiles into the stream.
262 * \param theInterpolator the interpolator
263 * \return true in case of success
265 HYDRODATA_EXPORT virtual bool Interpolate( HYDROData_IProfilesInterpolator* theInterpolator );
268 HYDRODATA_EXPORT double GetDDZ() const;
269 HYDRODATA_EXPORT void SetDDZ( double theDDZ );
271 HYDRODATA_EXPORT double GetSpatialStep() const;
272 HYDRODATA_EXPORT void SetSpatialStep( double theSpatialStep );
277 * Insert one profile in to the stream profiles order.
279 void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
280 const int theBeforeIndex = -1 );
283 * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
284 * If hydraulic axis is not set all profiles will be removed from order.
286 void updateProfilesOrder();
289 * Returns the type of child altitude object.
290 * Reimplemented to create stream altitude object.
292 HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
295 * Builds b-spline using interpolation algorithm.
297 static Handle(Geom_BSplineCurve) buildInterpolationCurve(
298 const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt );
302 void setParametersArray( const TColStd_Array1OfReal& theArray );
304 TColStd_Array1OfReal* getParametersArray() const;
306 void removeParametersArray();
308 int insertParameter( const Standard_Real& theParam );
310 void removeParameter( const int& theIndex );
312 Handle_HYDROData_DTM DTM() const;
316 friend class HYDROData_Iterator;
317 friend class test_HYDROData_Stream;
320 * Creates new object in the internal data structure. Use higher level objects
321 * to create objects with real content.
323 HYDRODATA_EXPORT HYDROData_Stream();
326 * Destructs properties of the object and object itself, removes it from the document.
328 virtual HYDRODATA_EXPORT ~HYDROData_Stream();