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