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