Blender  V2.93
StrokeAdvancedIterators.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
24 #include "Stroke.h"
25 #include "StrokeIterators.h"
26 
27 namespace Freestyle {
28 
29 namespace StrokeInternal {
30 
31 class vertex_const_traits : public Const_traits<StrokeVertex *> {
32  public:
33  typedef std::deque<StrokeVertex *> vertex_container;
34  typedef vertex_container::const_iterator vertex_container_iterator;
35 };
36 
37 class vertex_nonconst_traits : public Nonconst_traits<StrokeVertex *> {
38  public:
39  typedef std::deque<StrokeVertex *> vertex_container;
40  typedef vertex_container::iterator vertex_container_iterator;
41 };
42 
43 template<class Traits>
44 class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_Traits> {
45  public:
47 
48  protected:
50  typedef typename Traits::vertex_container_iterator vertex_container_iterator;
53 
54  // protected:
55  public:
59 
60  public:
61  friend class Stroke;
62  // friend class vertex_iterator;
63 
65  {
66  }
67 
68  inline vertex_iterator_base(const iterator &iBrother) : parent_class()
69  {
70  _it = iBrother._it;
71  _begin = iBrother._begin;
72  _end = iBrother._end;
73  }
74 
75  inline vertex_iterator_base(const const_iterator &iBrother) : parent_class()
76  {
77  _it = iBrother._it;
78  _begin = iBrother._begin;
79  _end = iBrother._end;
80  }
81 
82  // protected: //FIXME
83  public:
87  : parent_class()
88  {
89  _it = it;
90  _begin = begin;
91  _end = end;
92  }
93 
94  public:
96  {
97  }
98 
99  virtual bool begin() const
100  {
101  return (_it == _begin) ? true : false;
102  }
103 
104  virtual bool end() const
105  {
106  return (_it == _end) ? true : false;
107  }
108 
109  // operators
110  inline Self &operator++() // operator corresponding to ++i
111  {
112  ++_it;
113  return *(this);
114  }
115 
116  /* Operator corresponding to i++, i.e. which returns the value *and then* increments.
117  * That's why we store the value in a temp.
118  */
119  inline Self operator++(int)
120  {
121  Self tmp = *this;
122  ++_it;
123  return tmp;
124  }
125 
126  inline Self &operator--() // operator corresponding to --i
127  {
128  --_it;
129  return *(this);
130  }
131 
132  inline Self operator--(int)
133  {
134  Self tmp = *this;
135  --_it;
136  return tmp;
137  }
138 
139  // comparibility
140  virtual bool operator!=(const Self &b) const
141  {
142  return (_it != b._it);
143  }
144 
145  virtual bool operator==(const Self &b) const
146  {
147  return !(*this != b);
148  }
149 
150  // dereferencing
151  virtual typename Traits::reference operator*() const
152  {
153  return *(_it);
154  }
155 
156  virtual typename Traits::pointer operator->() const
157  {
158  return &(operator*());
159  }
160 
163  {
164  return _it;
165  }
166 
168  {
169  return _begin;
170  }
171 
173  {
174  return _end;
175  }
176 };
177 
178 } // end of namespace StrokeInternal
179 
180 } /* namespace Freestyle */
Iterators used to iterate over the elements of the Stroke.
Classes to define a stroke.
vertex_container::const_iterator vertex_container_iterator
IteratorBase< Traits, BidirectionalIteratorTag_Traits > parent_class
vertex_iterator_base(vertex_container_iterator it, vertex_container_iterator begin, vertex_container_iterator end)
vertex_iterator_base< vertex_const_traits > const_iterator
Traits::vertex_container_iterator vertex_container_iterator
vertex_iterator_base< vertex_nonconst_traits > iterator
vertex_container::iterator vertex_container_iterator
the vertices container
inherits from class Rep
Definition: AppCanvas.cpp:32