Blender  V3.3
StrokeAdvancedIterators.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include "Stroke.h"
11 #include "StrokeIterators.h"
12 
13 namespace Freestyle {
14 
15 namespace StrokeInternal {
16 
17 class vertex_const_traits : public Const_traits<StrokeVertex *> {
18  public:
19  typedef std::deque<StrokeVertex *> vertex_container;
20  typedef vertex_container::const_iterator vertex_container_iterator;
21 };
22 
23 class vertex_nonconst_traits : public Nonconst_traits<StrokeVertex *> {
24  public:
25  typedef std::deque<StrokeVertex *> vertex_container;
26  typedef vertex_container::iterator vertex_container_iterator;
27 };
28 
29 template<class Traits>
30 class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_Traits> {
31  public:
33 
34  protected:
36  typedef typename Traits::vertex_container_iterator vertex_container_iterator;
39 
40  // protected:
41  public:
45 
46  public:
47  friend class Stroke;
48  // friend class vertex_iterator;
49 
51  {
52  }
53 
54  inline vertex_iterator_base(const iterator &iBrother) : parent_class()
55  {
56  _it = iBrother._it;
57  _begin = iBrother._begin;
58  _end = iBrother._end;
59  }
60 
61  inline vertex_iterator_base(const const_iterator &iBrother) : parent_class()
62  {
63  _it = iBrother._it;
64  _begin = iBrother._begin;
65  _end = iBrother._end;
66  }
67 
68  // protected: //FIXME
69  public:
73  : parent_class()
74  {
75  _it = it;
76  _begin = begin;
77  _end = end;
78  }
79 
80  public:
82  {
83  }
84 
85  virtual bool begin() const
86  {
87  return (_it == _begin) ? true : false;
88  }
89 
90  virtual bool end() const
91  {
92  return (_it == _end) ? true : false;
93  }
94 
95  // operators
96  inline Self &operator++() // operator corresponding to ++i
97  {
98  ++_it;
99  return *(this);
100  }
101 
102  /* Operator corresponding to i++, i.e. which returns the value *and then* increments.
103  * That's why we store the value in a temp.
104  */
105  inline Self operator++(int)
106  {
107  Self tmp = *this;
108  ++_it;
109  return tmp;
110  }
111 
112  inline Self &operator--() // operator corresponding to --i
113  {
114  --_it;
115  return *(this);
116  }
117 
118  inline Self operator--(int)
119  {
120  Self tmp = *this;
121  --_it;
122  return tmp;
123  }
124 
125  // comparibility
126  virtual bool operator!=(const Self &b) const
127  {
128  return (_it != b._it);
129  }
130 
131  virtual bool operator==(const Self &b) const
132  {
133  return !(*this != b);
134  }
135 
136  // dereferencing
137  virtual typename Traits::reference operator*() const
138  {
139  return *(_it);
140  }
141 
142  virtual typename Traits::pointer operator->() const
143  {
144  return &(operator*());
145  }
146 
149  {
150  return _it;
151  }
152 
154  {
155  return _begin;
156  }
157 
159  {
160  return _end;
161  }
162 };
163 
164 } // end of namespace StrokeInternal
165 
166 } /* 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:18
static const pxr::TfToken b("b", pxr::TfToken::Immortal)