32 #ifndef TriangleIterator_INCLUDE_ONCE 33 #define TriangleIterator_INCLUDE_ONCE 49 virtual bool next() = 0;
50 virtual bool hasNext()
const = 0;
51 virtual int a()
const = 0;
52 virtual int b()
const = 0;
53 virtual int c()
const = 0;
59 template<
class TArray>
68 VL_DEBUG_SET_OBJECT_NAME()
75 mPrimRestartIndex = (
unsigned int)-1;
76 mPrimRestartOn =
false;
83 VL_DEBUG_SET_OBJECT_NAME()
90 mPrimRestartIndex = prim_restart_idx;
91 mPrimRestartOn = prim_restart_on;
92 mBaseVertex = base_vert;
93 mPrimType = prim_type;
96 bool hasNext()
const {
return mCurrentIndex != mEnd; }
98 virtual int a()
const {
return mA; }
99 virtual int b()
const {
return mB; }
100 virtual int c()
const {
return mC; }
105 VL_CHECK( end <= (
int)mArray->size() )
108 end = (int)mArray->size();
120 mCurrentIndex = start;
121 mA = mArray->at(start+0);
122 mB = mArray->at(start+1);
123 mC = mArray->at(start+2);
126 mCurrentIndex = start;
127 mA = mArray->at(start+0);
128 mB = mArray->at(start+2);
129 mC = mArray->at(start+4);
132 mCurrentIndex = start;
133 mA = mArray->at(start+0);
134 mB = mArray->at(start+1);
135 mC = mArray->at(start+2);
139 mCurrentIndex = start + 1;
140 mA = mArray->at(start+0);
141 mB = mArray->at(start+1);
142 mC = mArray->at(start+2);
146 mCurrentIndex = start;
147 mA = mArray->at(start+0);
148 mB = mArray->at(start+1);
149 mC = mArray->at(start+2);
153 mCurrentIndex = start;
154 mA = mArray->at(start+0);
155 mB = mArray->at(start+1);
156 mC = mArray->at(start+2);
159 Log::error(
Say(
"TriangleIteratorIndexed::initialize(): unsupported primitive type %n.\n") << mPrimType );
166 if ( mCurrentIndex != mEnd )
181 if ( mCurrentIndex == mEnd )
190 if ( mCurrentIndex >= mEnd )
191 mCurrentIndex = mEnd;
193 if ( isPrimRestart(mCurrentIndex) )
196 mA = mArray->at(mCurrentIndex + 0);
197 mB = mArray->at(mCurrentIndex + 1);
198 mC = mArray->at(mCurrentIndex + 2);
202 mA = mArray->at(mCurrentIndex + 0);
203 mB = mArray->at(mCurrentIndex + 1);
204 mC = mArray->at(mCurrentIndex + 2);
211 if ( mCurrentIndex >= mEnd )
212 mCurrentIndex = mEnd;
214 if ( isPrimRestart(mCurrentIndex) )
217 mA = mArray->at(mCurrentIndex + 0);
218 mB = mArray->at(mCurrentIndex + 2);
219 mC = mArray->at(mCurrentIndex + 4);
223 mA = mArray->at(mCurrentIndex + 0);
224 mB = mArray->at(mCurrentIndex + 2);
225 mC = mArray->at(mCurrentIndex + 4);
232 if ( mCurrentIndex + 2 >= mEnd )
233 mCurrentIndex = mEnd;
235 if ( isPrimRestart(mCurrentIndex + 2) )
239 mA = mArray->at(mCurrentIndex + 0);
240 mB = mArray->at(mCurrentIndex + 1);
241 mC = mArray->at(mCurrentIndex + 2);
248 mA = mArray->at(mCurrentIndex + 0);
249 mB = mArray->at(mCurrentIndex + 1);
250 mC = mArray->at(mCurrentIndex + 2);
254 mA = mArray->at(mCurrentIndex + 0);
255 mB = mArray->at(mCurrentIndex + 2);
256 mC = mArray->at(mCurrentIndex + 1);
264 if ( mCurrentIndex + 1 >= mEnd )
266 mCurrentIndex = mEnd;
269 if ( isPrimRestart(mCurrentIndex + 1) )
271 mIndex0 = mCurrentIndex + 2;
272 mCurrentIndex = mIndex0 + 1;
273 mA = mArray->at(mIndex0);
274 mB = mArray->at(mCurrentIndex + 0);
275 mC = mArray->at(mCurrentIndex + 1);
279 mA = mArray->at(mIndex0);
280 mB = mArray->at(mCurrentIndex + 0);
281 mC = mArray->at(mCurrentIndex + 1);
287 if ( mCurrentIndex >= mEnd )
289 mCurrentIndex = mEnd;
292 if ( isPrimRestart(mCurrentIndex) )
296 mA = mArray->at(mCurrentIndex+0);
297 mB = mArray->at(mCurrentIndex+1);
298 mC = mArray->at(mCurrentIndex+2);
305 mA = mArray->at(mCurrentIndex+0);
306 mB = mArray->at(mCurrentIndex+1);
307 mC = mArray->at(mCurrentIndex+2);
311 mA = mArray->at(mCurrentIndex+0);
312 mB = mArray->at(mCurrentIndex+1);
313 mC = mArray->at(mCurrentIndex-2);
324 if (mCurrentIndex != mEnd)
342 bool isPrimRestart(
int i)
const {
return mPrimRestartOn && mArray->at(i) == mPrimRestartIndex; }
345 const TArray* mArray;
352 unsigned int mPrimRestartIndex;
367 VL_DEBUG_SET_OBJECT_NAME()
368 mCurrentIndex = mStart = mEnd = 0;
370 mPrimType = prim_type;
374 bool hasNext()
const {
return mCurrentIndex != mEnd; }
376 virtual int a()
const {
return mA; }
377 virtual int b()
const {
return mB; }
378 virtual int c()
const {
return mC; }
384 mCurrentIndex = mEnd = end;
391 mCurrentIndex = start;
397 mCurrentIndex = start;
404 mCurrentIndex = start + 1;
411 mCurrentIndex = start;
418 mCurrentIndex = start;
431 if ( mCurrentIndex == mEnd )
440 if ( mCurrentIndex >= mEnd )
441 mCurrentIndex = mEnd;
444 mA = mCurrentIndex + 0;
445 mB = mCurrentIndex + 1;
446 mC = mCurrentIndex + 2;
453 if ( mCurrentIndex + 2 >= mEnd )
454 mCurrentIndex = mEnd;
460 mA = mCurrentIndex + 0;
461 mB = mCurrentIndex + 1;
462 mC = mCurrentIndex + 2;
466 mA = mCurrentIndex + 0;
467 mB = mCurrentIndex + 2;
468 mC = mCurrentIndex + 1;
476 if ( mCurrentIndex + 1 >= mEnd )
478 mCurrentIndex = mEnd;
483 mB = mCurrentIndex+0;
484 mC = mCurrentIndex+1;
490 if ( mCurrentIndex >= mEnd )
492 mCurrentIndex = mEnd;
499 mA = mCurrentIndex+0;
500 mB = mCurrentIndex+1;
501 mC = mCurrentIndex+2;
505 mA = mCurrentIndex+0;
506 mB = mCurrentIndex+1;
507 mC = mCurrentIndex-2;
518 if (mCurrentIndex == mEnd)
539 template<
class TArray>
545 TriangleIteratorMulti(
const std::vector<GLint>* p_base_vertices,
const std::vector<GLsizei>* p_count_vector,
const TArray* idx_array,
EPrimitiveType prim_type,
bool prim_restart_on,
int prim_restart_idx)
548 VL_DEBUG_SET_OBJECT_NAME()
549 mpBaseVertices = p_base_vertices;
550 mpCountVector = p_count_vector;
557 VL_CHECK( mpBaseVertices->size() == mpCountVector->size() )
558 if ( (*mpBaseVertices).size() )
560 int end = mStart + (*mpCountVector)[mCurPrim];
564 mCurPrim = (int)(*mpCountVector).size()-1;
572 if ( mCurPrim < (
int)(*mpCountVector).size()-1 )
574 mStart += (*mpCountVector)[mCurPrim];
609 bool next() {
return mIterator->next(); }
614 bool hasNext() {
return mIterator->hasNext(); }
617 int a()
const {
return mIterator->a(); }
620 int b()
const {
return mIterator->b(); }
623 int c()
const {
return mIterator->c(); }
bool hasNext()
Returns false if the iterator has reached the end of the triangle list.
const std::vector< GLint > * mpBaseVertices
A simple String formatting class.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
TriangleIteratorMulti(const std::vector< GLint > *p_base_vertices, const std::vector< GLsizei > *p_count_vector, const TArray *idx_array, EPrimitiveType prim_type, bool prim_restart_on, int prim_restart_idx)
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
ref< TriangleIteratorAbstract > mIterator
Visualization Library main namespace.
TriangleIteratorIndexed()
The base class for all the reference counted objects.
bool next()
Requires the next triangle.
Iterator used to extract the indices of every single triangle of a DrawCall regardless of the primiti...
TriangleIteratorIndexed(const TArray *idx_array, EPrimitiveType prim_type, int base_vert, bool prim_restart_on, unsigned int prim_restart_idx)
virtual bool hasNext() const =0
void setBaseVertex(int base_vert)
void initialize(int start, int end)
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
void initialize(int start=0, int end=-1)
The ref<> class is used to reference-count an Object.
int c() const
First index of the triangle.
int a() const
First index of the triangle.
TriangleIterator(TriangleIteratorAbstract *it)
TriangleIteratorDirect(EPrimitiveType prim_type=PT_UNKNOWN)
Visualization Library's enums in the 'vl' namespace.
const std::vector< GLsizei > * mpCountVector
int b() const
First index of the triangle.