1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_Stream_HeaderFile
24 #define HYDROData_Stream_HeaderFile
26 #include "HYDROData_NaturalObject.h"
28 #include <TopoDS_Face.hxx>
29 #include <TopoDS_Edge.hxx>
31 #include <Geom_BSplineCurve.hxx>
33 DEFINE_STANDARD_HANDLE(HYDROData_Stream, HYDROData_NaturalObject)
35 class Handle(HYDROData_PolylineXY);
36 class Handle(HYDROData_Polyline3D);
37 class Handle(HYDROData_Profile);
38 class HYDROData_IProfilesInterpolator;
39 class TColStd_Array1OfReal;
42 /**\class HYDROData_Stream
46 class HYDROData_Stream : public HYDROData_NaturalObject
54 TopoDS_Edge myLeftBank;
55 TopoDS_Edge myRightBank;
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
75 DEFINE_STANDARD_RTTI(HYDROData_Stream);
80 * Creates the presentations(2D and 3D) by given hydraulic axis and profiles.
82 HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
83 const HYDROData_SequenceOfObjects& theProfiles,
84 PrsDefinition& thePrs );
89 * Returns the kind of this object. Must be redefined in all objects of known type.
91 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_STREAM;}
94 * Dump object to Python script representation.
96 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
99 * Returns the list of all reference objects of this object.
101 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
104 * Returns the top shape of the object.
106 HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
109 * Returns the 3d shape of the object.
111 HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
114 * Update the profiles order and shape presentations of stream.
115 * Call this method whenever you made changes for stream data.
117 HYDRODATA_EXPORT virtual void Update();
120 * Checks that object has 2D presentation. Reimlemented to retun true.
122 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
125 * Update the shape presentations of stream.
127 HYDRODATA_EXPORT virtual void UpdatePrs();
132 HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
136 * Returns default filling color for new stream.
138 HYDRODATA_EXPORT static QColor DefaultFillingColor();
141 * Returns default border color for new stream.
143 HYDRODATA_EXPORT static QColor DefaultBorderColor();
146 * Returns true if given polyline can be used as stream axis.
148 HYDRODATA_EXPORT static bool IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theAxis );
151 // Public methods to work with Stream presentation
154 * Returns the left edge of the stream.
156 HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const;
159 * Returns the right edge of the stream.
161 HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const;
164 * Returns the inlet edge of the stream.
166 HYDRODATA_EXPORT virtual TopoDS_Shape GetInletShape() const;
169 * Returns the outlet edge of the stream.
171 HYDRODATA_EXPORT virtual TopoDS_Shape GetOutletShape() const;
175 // Public methods to work with Stream data fields
178 * Sets reference hydraulic axis object for stream.
180 HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
183 * Returns reference hydraulic axis object of stream.
185 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
188 * Remove reference hydraulic axis object from stream.
190 HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
193 * Returns true if profile has the intersection with the given hydraulic axis.
194 * Returns the parameter of inresection point on axis if axis is presented by one curve,
195 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
197 HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis,
198 const Handle(HYDROData_Profile)& theProfile,
199 const TopoDS_Face& thePlane,
200 Standard_Real& theOutPar );
203 * Returns true if profile has the intersection with reference hydraulic axis.
204 * Returns the parameter of inresection point on axis if axis is presented by one curve,
205 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
207 HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile,
208 const TopoDS_Face& thePlane,
209 Standard_Real& theOutPar ) const;
212 * Builds a planar face
214 HYDRODATA_EXPORT static bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
215 TopoDS_Face& thePlane );
218 * Add new one reference profile object for stream.
220 HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
223 * Add new one reference profile object for stream.
225 HYDRODATA_EXPORT virtual bool SetProfiles( const HYDROData_SequenceOfObjects& theProfiles,
226 const bool& theIsToOrder = true );
229 * Returns all reference profile objects of stream.
231 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
234 * Removes reference profile object from stream.
236 HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
239 * Removes all reference profile objects from stream.
241 HYDRODATA_EXPORT virtual void RemoveProfiles();
244 * Generates bottom polyline for stream or update the existing bottom polyline.
245 * \return true in case of success
247 HYDRODATA_EXPORT virtual bool GenerateBottomPolyline();
250 * Returns reference bottom polyline object of stream.
252 HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline3D) GetBottomPolyline() const;
255 * Sets reference bottom polyline object for stream.
256 * \param theBottom the polyline 3D
257 * \return true in case of success
259 HYDRODATA_EXPORT virtual bool SetBottomPolyline( const Handle(HYDROData_Polyline3D)& theBottom );
262 * Add interpolated profiles into the stream.
263 * \param theInterpolator the interpolator
264 * \return true in case of success
266 HYDRODATA_EXPORT virtual bool Interpolate( HYDROData_IProfilesInterpolator* theInterpolator );
271 * Insert one profile in to the stream profiles order.
273 void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
274 const int theBeforeIndex = -1 );
277 * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
278 * If hydraulic axis is not set all profiles will be removed from order.
280 void updateProfilesOrder();
283 * Returns the type of child altitude object.
284 * Reimplemented to create stream altitude object.
286 HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
289 * Builds b-spline using interpolation algorithm.
291 static Handle(Geom_BSplineCurve) buildInterpolationCurve(
292 const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt );
295 * Returns default filling color for new object.
297 HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
300 * Returns default border color for new object.
302 HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
306 void setParametersArray( const TColStd_Array1OfReal& theArray );
308 TColStd_Array1OfReal* getParametersArray() const;
310 void removeParametersArray();
312 int insertParameter( const Standard_Real& theParam );
314 void removeParameter( const int& theIndex );
318 friend class HYDROData_Iterator;
321 * Creates new object in the internal data structure. Use higher level objects
322 * to create objects with real content.
324 HYDRODATA_EXPORT HYDROData_Stream();
327 * Destructs properties of the object and object itself, removes it from the document.
329 virtual HYDRODATA_EXPORT ~HYDROData_Stream();