Salome HOME
Separate action "Find bottom" for context menu.
[modules/hydro.git] / src / HYDROData / HYDROData_Stream.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROData_Stream_HeaderFile
24 #define HYDROData_Stream_HeaderFile
25
26 #include "HYDROData_NaturalObject.h"
27
28 #include <TopoDS_Face.hxx>
29 #include <TopoDS_Edge.hxx>
30
31 #include <Geom_BSplineCurve.hxx>
32
33 DEFINE_STANDARD_HANDLE(HYDROData_Stream, HYDROData_NaturalObject)
34
35 class Handle(HYDROData_PolylineXY);
36 class Handle(HYDROData_Polyline3D);
37 class Handle(HYDROData_Profile);
38 class HYDROData_IProfilesInterpolator;
39 class TColStd_Array1OfReal;
40
41
42 /**\class HYDROData_Stream
43  * \brief 
44  *
45  */
46 class HYDROData_Stream : public HYDROData_NaturalObject
47 {
48 public:
49
50   struct PrsDefinition
51   {
52     TopoDS_Shape myPrs3D;
53     TopoDS_Shape myPrs2D;
54     TopoDS_Edge  myLeftBank;
55     TopoDS_Edge  myRightBank;
56     TopoDS_Edge  myInlet;
57     TopoDS_Edge  myOutlet;
58   };
59
60 protected:
61   /**
62    * Enumeration of tags corresponding to the persistent object parameters.
63    */
64   enum DataTag
65   {
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   };
72
73 public:
74
75   DEFINE_STANDARD_RTTI(HYDROData_Stream);
76
77 public:
78
79   /**
80    * Creates the presentations(2D and 3D) by given hydraulic axis and profiles.
81    */
82   HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
83                                                     const HYDROData_SequenceOfObjects&  theProfiles,
84                                                     PrsDefinition&                      thePrs );
85
86 public:
87
88   /**
89    * Returns the kind of this object. Must be redefined in all objects of known type.
90    */
91   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_STREAM;}
92
93   /**
94    * Dump object to Python script representation.
95    */
96   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
97
98   /**
99    * Returns the list of all reference objects of this object.
100    */
101   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
102
103   /**
104    * Returns the top shape of the object.
105    */
106   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
107
108   /**
109    * Returns the 3d shape of the object.
110    */
111   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
112
113   /**
114    * Update the profiles order and shape presentations of stream.
115    * Call this method whenever you made changes for stream data.
116    */
117   HYDRODATA_EXPORT virtual void Update();
118
119   /**
120    * Checks that object has 2D presentation. Reimlemented to retun true.
121    */
122   HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
123
124   /**
125    * Update the shape presentations of stream.
126    */
127   HYDRODATA_EXPORT virtual void UpdatePrs();
128
129   /**
130    * Returns default filling color for new stream.
131    */
132   HYDRODATA_EXPORT static QColor DefaultFillingColor();
133
134   /**
135    * Returns default border color for new stream.
136    */
137   HYDRODATA_EXPORT static QColor DefaultBorderColor();
138
139   /**
140    * Returns true if given polyline can be used as stream axis.
141    */
142   HYDRODATA_EXPORT static bool IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theAxis );
143
144 public:      
145   // Public methods to work with Stream presentation
146   
147   /**
148    * Returns the left edge of the stream.
149    */
150   HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const;
151
152   /**
153    * Returns the right edge of the stream.
154    */
155   HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const;
156
157   /**
158    * Returns the inlet edge of the stream.
159    */
160   HYDRODATA_EXPORT virtual TopoDS_Shape GetInletShape() const;
161
162   /**
163    * Returns the outlet edge of the stream.
164    */
165   HYDRODATA_EXPORT virtual TopoDS_Shape GetOutletShape() const;
166
167
168 public:      
169   // Public methods to work with Stream data fields
170
171   /**
172    * Sets reference hydraulic axis object for stream.
173    */
174   HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
175
176   /**
177    * Returns reference hydraulic axis object of stream.
178    */
179   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
180
181   /**
182    * Remove reference hydraulic axis object from stream.
183    */
184   HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
185
186   /**
187    * Returns true if profile has the intersection with the given hydraulic axis.
188    * Returns the parameter of inresection point on axis if axis is presented by one curve,
189    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
190    */
191   HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis, 
192                                                 const Handle(HYDROData_Profile)&    theProfile,
193                                                 const TopoDS_Face&                  thePlane,
194                                                 Standard_Real&                      theOutPar );
195
196   /**
197    * Returns true if profile has the intersection with reference hydraulic axis.
198    * Returns the parameter of inresection point on axis if axis is presented by one curve,
199    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
200    */
201   HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile,
202                                                  const TopoDS_Face&               thePlane,
203                                                  Standard_Real&                   theOutPar ) const;
204
205   /**
206   * Builds a planar face
207   */
208   HYDRODATA_EXPORT static bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
209                                           TopoDS_Face&                        thePlane );
210
211   /**
212    * Add new one reference profile object for stream.
213    */
214   HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
215
216   /**
217    * Add new one reference profile object for stream.
218    */
219   HYDRODATA_EXPORT virtual bool SetProfiles( const HYDROData_SequenceOfObjects& theProfiles,
220                                              const bool&                        theIsToOrder = true );
221
222   /**
223    * Returns all reference profile objects of stream.
224    */
225   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
226
227   /**
228    * Removes reference profile object from stream.
229    */
230   HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
231
232   /**
233    * Removes all reference profile objects from stream.
234    */
235   HYDRODATA_EXPORT virtual void RemoveProfiles();
236
237   /**
238    * Generates bottom polyline for stream or update the existing bottom polyline.
239    * \return true in case of success
240    */
241   HYDRODATA_EXPORT virtual bool GenerateBottomPolyline();
242
243   /**
244    * Returns reference bottom polyline object of stream.
245    */
246   HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline3D) GetBottomPolyline() const;
247
248   /**
249    * Add interpolated profiles into the stream.
250    * \param theInterpolator the interpolator
251    * \return true in case of success
252    */
253   HYDRODATA_EXPORT virtual bool Interpolate( HYDROData_IProfilesInterpolator* theInterpolator );
254   
255 protected:
256
257   /**
258    * Insert one profile in to the stream profiles order.
259    */
260   void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
261                                const int                        theBeforeIndex = -1 );
262
263   /**
264    * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
265    * If hydraulic axis is not set all profiles will be removed from order.
266    */
267   void updateProfilesOrder();
268   
269   /**
270    * Returns the type of child altitude object.
271    * Reimplemented to create stream altitude object.
272    */
273   HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
274
275   /**
276    * Builds b-spline using interpolation algorithm.
277    */
278   static Handle(Geom_BSplineCurve) buildInterpolationCurve(
279     const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt );
280
281   /**
282    * Returns default filling color for new object.
283    */
284   HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
285
286   /**
287    * Returns default border color for new object.
288    */
289   HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
290
291 private:
292   
293   void setParametersArray( const TColStd_Array1OfReal& theArray );
294
295   TColStd_Array1OfReal* getParametersArray() const;
296
297   void removeParametersArray();
298
299   int insertParameter( const Standard_Real& theParam );
300
301   void removeParameter( const int& theIndex );
302
303 protected:
304
305   friend class HYDROData_Iterator;
306
307   /**
308    * Creates new object in the internal data structure. Use higher level objects 
309    * to create objects with real content.
310    */
311   HYDRODATA_EXPORT HYDROData_Stream();
312
313   /**
314    * Destructs properties of the object and object itself, removes it from the document.
315    */
316   virtual HYDRODATA_EXPORT ~HYDROData_Stream();
317 };
318
319 #endif
320
321