Salome HOME
SIP: HYDROData_Stream is included.
[modules/hydro.git] / src / HYDROData / HYDROData_Stream.h
1
2 #ifndef HYDROData_Stream_HeaderFile
3 #define HYDROData_Stream_HeaderFile
4
5 #include "HYDROData_NaturalObject.h"
6 #include <TopoDS_Face.hxx>
7 #include <Geom_BSplineCurve.hxx>
8 DEFINE_STANDARD_HANDLE(HYDROData_Stream, HYDROData_NaturalObject)
9
10 class Handle(HYDROData_PolylineXY);
11 class Handle(HYDROData_Profile);
12 class TColStd_Array1OfReal;
13
14 /**\class HYDROData_Stream
15  * \brief 
16  *
17  */
18 class HYDROData_Stream : public HYDROData_NaturalObject
19 {
20 protected:
21   /**
22    * Enumeration of tags corresponding to the persistent object parameters.
23    */
24   enum DataTag
25   {
26     DataTag_First = HYDROData_NaturalObject::DataTag_First + 100, ///< first tag, to reserve
27     DataTag_HydraulicAxis,     ///< reference hydraulic axis
28     DataTag_Profile,           ///< reference profiles
29     DataTag_ParamsArray        ///< parameters array
30   };
31
32 public:
33   DEFINE_STANDARD_RTTI(HYDROData_Stream);
34
35   /**
36    * Returns the kind of this object. Must be redefined in all objects of known type.
37    */
38   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_STREAM;}
39
40   /**
41    * Dump object to Python script representation.
42    */
43   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
44
45   /**
46    * Returns the list of all reference objects of this object.
47    */
48   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
49
50   /**
51    * Returns the top shape of the object.
52    */
53   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
54
55   /**
56    * Returns the 3d shape of the object.
57    */
58   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
59
60   /**
61    * Update the profiles order and shape presentations of stream.
62    * Call this method whenever you made changes for stream data.
63    */
64   HYDRODATA_EXPORT virtual void Update();
65
66   /**
67    * Update the shape presentations of stream.
68    */
69   HYDRODATA_EXPORT virtual void UpdatePrs();
70
71   /**
72    * Returns default filling color for new stream.
73    */
74   HYDRODATA_EXPORT static QColor DefaultFillingColor();
75
76   /**
77    * Returns default border color for new stream.
78    */
79   HYDRODATA_EXPORT static QColor DefaultBorderColor();
80
81   /**
82    * Returns true if given polyline can be used as stream axis.
83    */
84   HYDRODATA_EXPORT static bool IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theAxis );
85
86 public:      
87   // Public methods to work with Stream presentation
88   
89   /**
90    * Returns the left edge of the stream.
91    */
92   HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const;
93
94   /**
95    * Returns the right edge of the stream.
96    */
97   HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const;
98
99   /**
100    * Returns the inlet edge of the stream.
101    */
102   HYDRODATA_EXPORT virtual TopoDS_Shape GetInletShape() const;
103
104   /**
105    * Returns the outlet edge of the stream.
106    */
107   HYDRODATA_EXPORT virtual TopoDS_Shape GetOutletShape() const;
108
109
110 public:      
111   // Public methods to work with Stream data fields
112
113   /**
114    * Sets reference hydraulic axis object for stream.
115    */
116   HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
117
118   /**
119    * Returns reference hydraulic axis object of stream.
120    */
121   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
122
123   /**
124    * Remove reference hydraulic axis object from stream.
125    */
126   HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
127
128   /**
129    * Returns true if profile has the intersection with the given hydraulic axis.
130    * Returns the parameter of inresection point on axis if axis is presented by one curve,
131    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
132    */
133   HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis, 
134                                                 const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
135                                                                                                                         Standard_Real& outPar);
136
137   /**
138    * Returns true if profile has the intersection with reference hydraulic axis.
139    * Returns the parameter of inresection point on axis if axis is presented by one curve,
140    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
141    */
142   HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
143                                                                                                                          Standard_Real& outPar) const;
144
145    /**
146    * Builds a planar face
147    */
148   HYDRODATA_EXPORT virtual bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, TopoDS_Face& thePlane) const;
149
150   /**
151    * Add new one reference profile object for stream.
152    */
153   HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
154
155   /**
156    * Returns all reference profile objects of stream.
157    */
158   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
159
160   /**
161    * Removes reference profile object from stream.
162    */
163   HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
164
165   /**
166    * Removes all reference profile objects from stream.
167    */
168   HYDRODATA_EXPORT virtual void RemoveProfiles();
169   
170 protected:
171
172   /**
173    * Insert one profile in to the stream profiles order.
174    */
175   void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
176                                const int                        theBeforeIndex = -1 );
177
178   /**
179    * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
180    * If hydraulic axis is not set all profiles will be removed from order.
181    */
182   void updateProfilesOrder();
183   
184   /**
185    * Returns the type of child altitude object.
186    * Reimplemented to create stream altitude object.
187    */
188   HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
189
190   /**
191    * Builds b-spline using interpolation algorithm.
192    */
193   Handle(Geom_BSplineCurve) buildInterpolationCurve(const   Handle(TColgp_HArray1OfPnt)& theArrayOfPnt);
194
195   /**
196    * Returns default filling color for new object.
197    */
198   HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
199
200   /**
201    * Returns default border color for new object.
202    */
203   HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
204
205 private:
206   
207   void setParametersArray( const TColStd_Array1OfReal& theArray );
208
209   TColStd_Array1OfReal* getParametersArray() const;
210
211   void removeParametersArray();
212
213   int insertParameter( const Standard_Real& theParam );
214
215   void removeParameter( const int& theIndex );
216
217 protected:
218
219   friend class HYDROData_Iterator;
220
221   /**
222    * Creates new object in the internal data structure. Use higher level objects 
223    * to create objects with real content.
224    */
225   HYDRODATA_EXPORT HYDROData_Stream();
226
227   /**
228    * Destructs properties of the object and object itself, removes it from the document.
229    */
230   virtual HYDRODATA_EXPORT ~HYDROData_Stream();
231 };
232
233 #endif