Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / lineconn2d / LineConn2d_SegmentIterator.h
1 // File:      LineConn2d_SegmentIterator.h
2 // Created:   04.08.05 22:47:27
3 // Author:    Alexander GRIGORIEV
4 // Copyright: Open Cascade 2005
5
6
7 #ifndef LineConn2d_SegmentIterator_HeaderFile
8 #define LineConn2d_SegmentIterator_HeaderFile
9
10 #include <LineConn2d_Segment.h>
11 #include <LineConn2d_Object.h>
12
13 /**
14  * Iterator that is invoked on LineConn2d_Object and returns contour
15  * segments starting from the one between the last point and the first point
16  * of the contour.
17  */
18
19 class LineConn2d_SegmentIterator
20 {
21  public:
22   // ---------- PUBLIC METHODS ----------
23
24   /// Empty constructor
25   inline LineConn2d_SegmentIterator ()
26     : myIsSeg (Standard_False) {}
27
28   /// Constructor
29   inline LineConn2d_SegmentIterator (const LineConn2d_Object& theObject)
30     : myListIter (theObject.PointsIterator()),
31       myIsSeg    (Standard_False)
32   {
33     if (theObject.NbPoints() > 1) {
34       mySeg.SetOrigin    (theObject.LastPoint());
35       mySeg.SetExtremity (myListIter.Value());
36       myIsSeg = Standard_True;
37     }
38   }
39
40   /// Method More()
41   inline Standard_Boolean More() const
42   { return myIsSeg; }
43
44   /// Iterator increment
45   inline void Next ()
46   {
47     if (myIsSeg) {
48       myListIter.Next();
49       if (myListIter.More()) {
50         mySeg.SetOrigin    (mySeg.Extremity());
51         mySeg.SetExtremity (myListIter.Value());
52       } else
53         myIsSeg = Standard_False;
54     }
55   }
56
57   /// Query the currently iterated segment
58   inline const LineConn2d_Segment& Value () const
59   { return mySeg; }
60
61  private:
62   // ---------- PRIVATE FIELDS ----------
63
64   NCollection_List <gp_XY>::Iterator    myListIter;
65   LineConn2d_Segment                    mySeg;
66   Standard_Boolean                      myIsSeg;
67 };
68
69 #endif