Salome HOME
231bf6c385ad22f7e978d78dc4bd1fec36ca443a
[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
88   
89   /**
90    * Sets reference hydraulic axis object for stream.
91    */
92   HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
93
94   /**
95    * Returns reference hydraulic axis object of stream.
96    */
97   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
98
99   /**
100    * Remove reference hydraulic axis object from stream.
101    */
102   HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
103
104   /**
105    * Returns true if profile has the intersection with the given hydraulic axis.
106    * Returns the parameter of inresection point on axis if axis is presented by one curve,
107    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
108    */
109   HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis, 
110                                                 const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
111                                                                                                                         Standard_Real& outPar);
112
113   /**
114    * Returns true if profile has the intersection with reference hydraulic axis.
115    * Returns the parameter of inresection point on axis if axis is presented by one curve,
116    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
117    */
118   HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
119                                                                                                                          Standard_Real& outPar) const;
120
121    /**
122    * Builds a planar face
123    */
124   HYDRODATA_EXPORT virtual bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, TopoDS_Face& thePlane) const;
125
126   /**
127    * Add new one reference profile object for stream.
128    */
129   HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
130
131   /**
132    * Returns all reference profile objects of stream.
133    */
134   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
135
136   /**
137    * Removes reference profile object from stream.
138    */
139   HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
140
141   /**
142    * Removes all reference profile objects from stream.
143    */
144   HYDRODATA_EXPORT virtual void RemoveProfiles();
145   
146 protected:
147
148   /**
149    * Insert one profile in to the stream profiles order.
150    */
151   void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
152                                const int                        theBeforeIndex = -1 );
153
154   /**
155    * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
156    * If hydraulic axis is not set all profiles will be removed from order.
157    */
158   void updateProfilesOrder();
159   
160   /**
161    * Create all necessary child group objects.
162    */
163   virtual void createGroupObjects();
164
165   /**
166    * Returns the type of child altitude object.
167    * Reimplemented to create stream altitude object.
168    */
169   virtual ObjectKind getAltitudeObjectType() const;
170
171   /**
172    * Builds b-spline using interpolation algorithm.
173    */
174   Handle(Geom_BSplineCurve) buildInterpolationCurve(const   Handle(TColgp_HArray1OfPnt)& theArrayOfPnt);
175
176   /**
177    * Returns default filling color for new object.
178    */
179   virtual QColor getDefaultFillingColor() const;
180
181   /**
182    * Returns default border color for new object.
183    */
184   virtual QColor getDefaultBorderColor() const;
185
186 private:
187   
188   void setParametersArray( const TColStd_Array1OfReal& theArray );
189
190   TColStd_Array1OfReal* getParametersArray() const;
191
192   void removeParametersArray();
193
194   int insertParameter( const Standard_Real& theParam );
195
196   void removeParameter( const int& theIndex );
197
198 protected:
199
200   friend class HYDROData_Iterator;
201
202   /**
203    * Creates new object in the internal data structure. Use higher level objects 
204    * to create objects with real content.
205    */
206   HYDRODATA_EXPORT HYDROData_Stream();
207
208   /**
209    * Destructs properties of the object and object itself, removes it from the document.
210    */
211   virtual HYDRODATA_EXPORT ~HYDROData_Stream();
212 };
213
214 #endif