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);
39 /**\class HYDROData_Stream
43 class HYDROData_Stream : public HYDROData_NaturalObject
51 TopoDS_Edge myLeftBank;
52 TopoDS_Edge myRightBank;
59 * Enumeration of tags corresponding to the persistent object parameters.
63 DataTag_First = HYDROData_NaturalObject::DataTag_First + 100, ///< first tag, to reserve
64 DataTag_HydraulicAxis, ///< reference hydraulic axis
65 DataTag_Profile, ///< reference profiles
66 DataTag_ParamsArray, ///< parameters array
67 DataTag_BottomPolyline ///< reference bottom polyline
72 DEFINE_STANDARD_RTTI(HYDROData_Stream);
77 * Creates the presentations(2D and 3D) by given hydraulic axis and profiles.
79 HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
80 const HYDROData_SequenceOfObjects& theProfiles,
81 PrsDefinition& thePrs );
84 * Creates the presentations(2D and 3D) by given first points, last points and profiles.
85 * If 2D profiles is null - they will not used in the presentation.
87 HYDRODATA_EXPORT static bool CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt,
88 const Handle(TColgp_HArray1OfPnt) theArrayOfLPnt,
89 const Handle(TopTools_HArray1OfShape) theArrOfProfiles,
90 const Handle(TopTools_HArray1OfShape) theArrOf2DProfiles,
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( MapOfTreatedObjects& theTreatedObjects ) const;
106 * Returns the list of all reference objects of this object.
108 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
111 * Returns the top shape of the object.
113 HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
116 * Returns the 3d shape of the object.
118 HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
121 * Update the profiles order and shape presentations of stream.
122 * Call this method whenever you made changes for stream data.
124 HYDRODATA_EXPORT virtual void Update();
127 * Checks that object has 2D presentation. Reimlemented to retun true.
129 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
132 * Update the shape presentations of stream.
134 HYDRODATA_EXPORT virtual void UpdatePrs();
139 HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination,
140 bool isGenerateNewName ) const;
144 * Returns default filling color for new stream.
146 HYDRODATA_EXPORT static QColor DefaultFillingColor();
149 * Returns default border color for new stream.
151 HYDRODATA_EXPORT static QColor DefaultBorderColor();
154 * Returns true if given polyline can be used as stream axis.
156 HYDRODATA_EXPORT static bool IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theAxis );
159 // Public methods to work with Stream presentation
162 * Returns the left edge of the stream.
164 HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const;
167 * Returns the right edge of the stream.
169 HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const;
172 * Returns the inlet edge of the stream.
174 HYDRODATA_EXPORT virtual TopoDS_Shape GetInletShape() const;
177 * Returns the outlet edge of the stream.
179 HYDRODATA_EXPORT virtual TopoDS_Shape GetOutletShape() const;
183 // Public methods to work with Stream data fields
186 * Sets reference hydraulic axis object for stream.
188 HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
191 * Returns reference hydraulic axis object of stream.
193 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
196 * Remove reference hydraulic axis object from stream.
198 HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
201 * Returns true if profile has the intersection with the given hydraulic axis.
202 * Returns the parameter of inresection point on axis if axis is presented by one curve,
203 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
205 HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis,
206 const Handle(HYDROData_Profile)& theProfile,
207 const TopoDS_Face& thePlane,
208 Standard_Real& theOutPar );
211 * Returns true if profile has the intersection with reference hydraulic axis.
212 * Returns the parameter of inresection point on axis if axis is presented by one curve,
213 * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point.
215 HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile,
216 const TopoDS_Face& thePlane,
217 Standard_Real& theOutPar ) const;
220 * Builds a planar face
222 HYDRODATA_EXPORT static bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
223 TopoDS_Face& thePlane );
226 * Add new one reference profile object for stream.
228 HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
231 * Add new one reference profile object for stream.
233 HYDRODATA_EXPORT virtual bool SetProfiles( const HYDROData_SequenceOfObjects& theProfiles,
234 const bool& theIsToOrder = true );
237 * Returns all reference profile objects of stream.
239 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
242 * Removes reference profile object from stream.
244 HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
247 * Removes all reference profile objects from stream.
249 HYDRODATA_EXPORT virtual void RemoveProfiles();
252 * Generates bottom polyline for stream or update the existing bottom polyline.
253 * \return true in case of success
255 HYDRODATA_EXPORT virtual bool GenerateBottomPolyline();
258 * Returns reference bottom polyline object of stream.
260 HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline3D) GetBottomPolyline() const;
263 * Sets reference bottom polyline object for stream.
264 * \param theBottom the polyline 3D
265 * \return true in case of success
267 HYDRODATA_EXPORT virtual bool SetBottomPolyline( const Handle(HYDROData_Polyline3D)& theBottom );
270 * Add interpolated profiles into the stream.
271 * \param theInterpolator the interpolator
272 * \return true in case of success
274 HYDRODATA_EXPORT virtual bool Interpolate( HYDROData_IProfilesInterpolator* theInterpolator );
279 * Insert one profile in to the stream profiles order.
281 void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
282 const int theBeforeIndex = -1 );
285 * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
286 * If hydraulic axis is not set all profiles will be removed from order.
288 void updateProfilesOrder();
291 * Returns the type of child altitude object.
292 * Reimplemented to create stream altitude object.
294 HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
297 * Builds b-spline using interpolation algorithm.
299 static Handle(Geom_BSplineCurve) buildInterpolationCurve(
300 const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt );
303 * Returns default filling color for new object.
305 HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
308 * Returns default border color for new object.
310 HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
314 void setParametersArray( const TColStd_Array1OfReal& theArray );
316 TColStd_Array1OfReal* getParametersArray() const;
318 void removeParametersArray();
320 int insertParameter( const Standard_Real& theParam );
322 void removeParameter( const int& theIndex );
326 friend class HYDROData_Iterator;
329 * Creates new object in the internal data structure. Use higher level objects
330 * to create objects with real content.
332 HYDRODATA_EXPORT HYDROData_Stream();
335 * Destructs properties of the object and object itself, removes it from the document.
337 virtual HYDRODATA_EXPORT ~HYDROData_Stream();