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