Blender V4.3
StrokeAdvancedIterators.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
12#include "Stroke.h"
13#include "StrokeIterators.h"
14
15namespace Freestyle {
16
17namespace StrokeInternal {
18
19class vertex_const_traits : public Const_traits<StrokeVertex *> {
20 public:
21 typedef std::deque<StrokeVertex *> vertex_container;
22 typedef vertex_container::const_iterator vertex_container_iterator;
23};
24
25class vertex_nonconst_traits : public Nonconst_traits<StrokeVertex *> {
26 public:
27 typedef std::deque<StrokeVertex *> vertex_container;
28 typedef vertex_container::iterator vertex_container_iterator;
29};
30
31template<class Traits>
32class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_Traits> {
33 public:
35
36 protected:
38 typedef typename Traits::vertex_container_iterator vertex_container_iterator;
41
42 // protected:
43 public:
47
48 public:
49 friend class Stroke;
50 // friend class vertex_iterator;
51
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
62 {
63 _it = iBrother._it;
64 _begin = iBrother._begin;
65 _end = iBrother._end;
66 }
67
68 // protected: //FIXME
69 public:
79
80 public:
82
83 virtual bool begin() const
84 {
85 return (_it == _begin) ? true : false;
86 }
87
88 virtual bool end() const
89 {
90 return (_it == _end) ? true : false;
91 }
92
93 // operators
94 inline Self &operator++() // operator corresponding to ++i
95 {
96 ++_it;
97 return *(this);
98 }
99
100 /* Operator corresponding to i++, i.e. which returns the value *and then* increments.
101 * That's why we store the value in a temp.
102 */
103 inline Self operator++(int)
104 {
105 Self tmp = *this;
106 ++_it;
107 return tmp;
108 }
109
110 inline Self &operator--() // operator corresponding to --i
111 {
112 --_it;
113 return *(this);
114 }
115
116 inline Self operator--(int)
117 {
118 Self tmp = *this;
119 --_it;
120 return tmp;
121 }
122
123 // comparibility
124 virtual bool operator!=(const Self &b) const
125 {
126 return (_it != b._it);
127 }
128
129 virtual bool operator==(const Self &b) const
130 {
131 return !(*this != b);
132 }
133
134 // dereferencing
135 virtual typename Traits::reference operator*() const
136 {
137 return *(_it);
138 }
139
140 virtual typename Traits::pointer operator->() const
141 {
142 return &(operator*());
143 }
144
147 {
148 return _it;
149 }
150
152 {
153 return _begin;
154 }
155
157 {
158 return _end;
159 }
160};
161
162} // end of namespace StrokeInternal
163
164} /* 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
local_group_size(16, 16) .push_constant(Type b
inherits from class Rep
Definition AppCanvas.cpp:20