h o m e | d o c u m e n t a t i o n | c l a s s h i e r a r c h y |
00001 // 00002 // Filename : StrokeIterators.h 00003 // Author(s) : Stephane Grabli 00004 // Purpose : Iterators used to iterate over the elements of the Stroke 00005 // Date of creation : 01/07/2003 00006 // 00008 00009 00010 // 00011 // Copyright (C) : Please refer to the COPYRIGHT file distributed 00012 // with this source distribution. 00013 // 00014 // This program is free software; you can redistribute it and/or 00015 // modify it under the terms of the GNU General Public License 00016 // as published by the Free Software Foundation; either version 2 00017 // of the License, or (at your option) any later version. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 // 00029 00030 #ifndef STROKEITERATORS_H 00031 # define STROKEITERATORS_H 00032 00033 # include "Stroke.h" 00034 00035 namespace StrokeInternal { 00036 00037 // 00038 // StrokeVertexIterator 00039 // 00041 00060 class StrokeVertexIterator : public Interface0DIteratorNested 00061 { 00062 public: 00063 00065 StrokeVertexIterator() {} 00066 00068 StrokeVertexIterator(const StrokeVertexIterator& vi) { 00069 _it = vi._it; 00070 _begin = vi._begin; 00071 _end = vi._end; 00072 } 00073 00074 StrokeVertexIterator(const ::Stroke::vertex_container::iterator& it, 00075 const ::Stroke::vertex_container::iterator& begin, 00076 const ::Stroke::vertex_container::iterator& end) { 00077 _it = it; 00078 _begin = begin; 00079 _end = end; 00080 } 00081 00082 virtual ~StrokeVertexIterator() {} 00083 00087 inline Interface0DIterator castToInterface0DIterator() const { 00088 Interface0DIterator ret(new StrokeVertexIterator(*this)); 00089 return ret; 00090 } 00099 StrokeVertexIterator& operator=(const StrokeVertexIterator& vi) { 00100 _it = vi._it; 00101 _begin = vi._begin; 00102 _end = vi._end; 00103 return *this; 00104 } 00105 00107 virtual string getExactTypeName() const { 00108 return "StrokeVertexIterator"; 00109 } 00110 00115 virtual StrokeVertex& operator*() { 00116 return **_it; 00117 } 00118 00122 virtual StrokeVertex* operator->() { 00123 return &(operator*()); 00124 } 00125 00129 virtual StrokeVertexIterator& operator++() { 00130 increment(); 00131 return *this; 00132 } 00133 00137 virtual StrokeVertexIterator operator++(int) { 00138 StrokeVertexIterator ret(*this); 00139 increment(); 00140 return ret; 00141 } 00142 00146 virtual StrokeVertexIterator& operator--() { 00147 decrement(); 00148 return *this; 00149 } 00150 00154 virtual StrokeVertexIterator operator--(int) { 00155 StrokeVertexIterator ret(*this); 00156 decrement(); 00157 return ret; 00158 } 00159 00161 virtual void increment() { 00162 ++_it; 00163 } 00164 00166 virtual void decrement() { 00167 --_it; 00168 } 00169 00173 bool isBegin() const { 00174 return _it == _begin; 00175 } 00176 00180 bool isEnd() const { 00181 return _it == _end; 00182 } 00183 00185 virtual bool operator==(const Interface0DIteratorNested& it) const { 00186 const StrokeVertexIterator* it_exact = dynamic_cast<const StrokeVertexIterator*>(&it); 00187 if (!it_exact) 00188 return false; 00189 return (_it == it_exact->_it); 00190 } 00191 00193 virtual float t() const{ 00194 return (*_it)->curvilinearAbscissa(); 00195 } 00197 virtual float u() const{ 00198 return (*_it)->u(); 00199 } 00200 00202 virtual StrokeVertexIterator* copy() const { 00203 return new StrokeVertexIterator(*this); 00204 } 00205 00206 // 00207 // Not exported in Python 00208 // 00210 00211 const ::Stroke::vertex_container::iterator& getIt() { 00212 return _it; 00213 } 00214 00215 private: 00216 00217 ::Stroke::vertex_container::iterator _it; 00218 ::Stroke::vertex_container::iterator _begin; 00219 ::Stroke::vertex_container::iterator _end; 00220 }; 00221 00222 } // end of namespace StrokeInternal 00223 00224 00225 #endif // STROKEITERATORS_H 00226 00227