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