Salome HOME
3ebc441ab6bb2810e5d110a3bb1eac6e4d28a347
[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 public:      
68   // Public methods to work with Stream
69   
70   /**
71    * Sets reference hydraulic axis object for stream.
72    */
73   HYDRODATA_EXPORT virtual bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis );
74
75   /**
76    * Returns reference hydraulic axis object of stream.
77    */
78   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetHydraulicAxis() const;
79
80   /**
81    * Remove reference hydraulic axis object from stream.
82    */
83   HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
84
85
86   /**
87    * Returns true if profile has the intersection with reference hydraulic axis.
88    * Returns the parameter of inresection point on axis if axis is presented by one curve,
89    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
90    */
91   HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
92                                                                                                 Standard_Real& outPar) const;
93
94    /**
95    * Builds a planar face
96    */
97   HYDRODATA_EXPORT virtual bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, TopoDS_Face& thePlane) const;
98
99   /**
100    * Add new one reference profile object for stream.
101    */
102   HYDRODATA_EXPORT virtual bool AddProfile( const Handle(HYDROData_Profile)& theProfile );
103
104   /**
105    * Returns all reference profile objects of stream.
106    */
107   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetProfiles() const;
108
109   /**
110    * Removes reference profile object from stream.
111    */
112   HYDRODATA_EXPORT virtual bool RemoveProfile( const Handle(HYDROData_Profile)& theProfile );
113
114   /**
115    * Removes all reference profile objects from stream.
116    */
117   HYDRODATA_EXPORT virtual void RemoveProfiles();
118   
119 protected:
120
121   /**
122    * Insert one profile in to the stream profiles order.
123    */
124   void insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
125                                const int                        theBeforeIndex = -1 );
126
127   /**
128    * Fully recompute the order of all profiles in accordance with reference hydraulic axis.
129    * If hydraulic axis is not set all profiles will be removed from order.
130    */
131   void updateProfilesOrder();
132   
133   /**
134    * Builds b-spline using interpolation algorithm.
135    */
136   Handle(Geom_BSplineCurve) buildInterpolationCurve(const   Handle(TColgp_HArray1OfPnt)& theArrayOfPnt);
137
138 private:
139   
140   void setParametersArray( const TColStd_Array1OfReal& theArray );
141
142   TColStd_Array1OfReal* getParametersArray() const;
143
144   void removeParametersArray();
145
146   int insertParameter( const Standard_Real& theParam );
147
148   void removeParameter( const int& theIndex );
149
150 protected:
151
152   friend class HYDROData_Iterator;
153
154   /**
155    * Creates new object in the internal data structure. Use higher level objects 
156    * to create objects with real content.
157    */
158   HYDRODATA_EXPORT HYDROData_Stream();
159
160   /**
161    * Destructs properties of the object and object itself, removes it from the document.
162    */
163   virtual HYDRODATA_EXPORT ~HYDROData_Stream();
164 };
165
166 #endif