Salome HOME
6.12.2013.Fix of HasIntersection method.
[modules/hydro.git] / src / HYDROData / HYDROData_IPolyline.h
1
2 #ifndef HYDROData_IPolyline_HeaderFile
3 #define HYDROData_IPolyline_HeaderFile
4
5 #include "HYDROData_Entity.h"
6
7
8 DEFINE_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
9
10 class gp_XY;
11 class TopoDS_Shape;
12 class Handle(TDataStd_RealList);
13 class Handle(TDataStd_ExtStringList);
14 class Handle(TDataStd_BooleanList);
15 class Handle(TDataStd_IntegerList);
16
17
18 /**\class HYDROData_IPolyline
19  * \brief Base class that stores/retreives information about the 2D points.
20  */
21 class HYDROData_IPolyline : public HYDROData_Entity
22 {
23 public:
24
25   enum SectionType{ SECTION_POLYLINE = 0, SECTION_SPLINE = 1 };
26
27   typedef gp_XY                       Point;
28   typedef NCollection_Sequence<Point> PointsList;
29
30 protected:
31   /**
32    * Enumeration of tags corresponding to the persistent object parameters.
33    */
34   enum DataTag
35   {
36     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
37     DataTag_Points,
38     DataTag_Sections,
39     DataTag_PolylineShape,
40   };
41
42 public:
43   DEFINE_STANDARD_RTTI(HYDROData_IPolyline);
44
45   /**
46    * Returns the 3D presentation of all points.
47    */
48   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() = 0;
49
50
51   /**
52    * Returns number of sections.
53    */
54   HYDRODATA_EXPORT virtual int NbSections() const = 0;
55
56   /**
57    * Adds new one section.
58    * \param theSectName name of the section
59    * \param theSectionType type of section
60    * \param theIsClosed flag indicates closures of section
61    */
62   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
63                                             const SectionType              theSectionType,
64                                             const bool                     theIsClosed ) = 0;
65
66   /**
67    * Returns name of section with given index.
68    * \param theSectionIndex index of section
69    */
70   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const = 0;
71
72   /**
73    * Set name for section with given index.
74    * \param theSectionIndex index of section
75    * \param theSectionName new section name
76    */
77   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
78                                                 const TCollection_AsciiString& theSectionName ) = 0;
79
80   /**
81    * Returns type of section with given index.
82    * \param theSectionIndex index of section
83    */
84   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const = 0;
85
86   /**
87    * Set type for section with given index.
88    * \param theSectionIndex index of section
89    * \param theSectionType new section type
90    */
91   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
92                                                 const SectionType theSectionType ) = 0;
93
94   /**
95    * Returns true if section with given index is closed.
96    * \param theSectionIndex index of section
97    */
98   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const = 0;
99
100   /**
101    * Set closed flag for section with given index.
102    * \param theSectionIndex index of section
103    * \param theIsClosed new closures state
104    */
105   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
106                                                   const bool theIsClosed ) = 0;
107
108   /**
109    * Removes section with given index.
110    * \param theSectionIndex index of section
111    */
112   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex ) = 0;
113
114   /**
115    * Removes all sections.
116    */
117   HYDRODATA_EXPORT virtual void RemoveSections() = 0;
118
119
120   /**
121    * Return number of profile points.
122    * \return number of points
123    */
124   HYDRODATA_EXPORT int NbPoints( const int theSectionIndex = -1 ) const;
125
126   /**
127    * Adds new point for section with index "theSectionIndex".
128    * \param theSectionIndex index of section
129    * \param thePoint point to add
130    * \param theBeforeIndex if not equal -1 then insert point before this index
131    */
132   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
133                                           const Point& thePoint,
134                                           const int    theBeforeIndex = -1 ) = 0;
135
136   /**
137    * Replaces point for section with index "theSectionIndex".
138    * \param theSectionIndex index of section
139    * \param thePoint new point
140    * \param thePointIndex index of point to replace
141    */
142   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
143                                           const Point& thePoint,
144                                           const int    thePointIndex ) = 0;
145
146   /**
147    * Removes point from section with index "theSectionIndex".
148    * \param theSectionIndex index of section
149    * \param thePointIndex index of point
150    */
151   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
152                                              const int thePointIndex ) = 0;
153
154
155   /**
156    * Returns list of points.
157    * \param theSectionIndex if not equal -1 then list of points returned
158    *                        only for section with this index
159    * \return list of points
160    */
161   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const = 0;
162
163 protected:
164
165   TopoDS_Shape getPolylineShape() const;
166
167   void setPolylineShape( const TopoDS_Shape& theShape );
168
169   void removePolylineShape();
170
171
172   void getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
173                          Handle(TDataStd_IntegerList)&   theTypesList,
174                          Handle(TDataStd_BooleanList)&   theClosuresList,
175                          const bool                      theIsCreate = true ) const;
176
177   void removeSectionsLists();
178
179   void getPointsLists( const int                  theSectionIndex,
180                        Handle(TDataStd_RealList)& theListX,
181                        Handle(TDataStd_RealList)& theListY,
182                        const bool                 theIsCreate = true ) const;
183
184   void removePointsLists( const int theSectionIndex = -1 ) const;
185
186 protected:
187
188   /**
189    * Creates new object in the internal data structure. Use higher level objects 
190    * to create objects with real content.
191    */
192   HYDRODATA_EXPORT HYDROData_IPolyline();
193
194   /**
195    * Destructs properties of the object and object itself, removes it from the document.
196    */
197   HYDRODATA_EXPORT ~HYDROData_IPolyline();
198 };
199
200 #endif