32 #ifndef TriangleIterator_INCLUDE_ONCE 33 #define TriangleIterator_INCLUDE_ONCE 50 virtual bool next() = 0;
51 virtual bool hasNext()
const = 0;
52 virtual int a()
const = 0;
53 virtual int b()
const = 0;
54 virtual int c()
const = 0;
60 template<
class TArray>
69 VL_DEBUG_SET_OBJECT_NAME()
76 mPrimRestartIndex = (
unsigned int)-1;
77 mPrimRestartOn =
false;
84 VL_DEBUG_SET_OBJECT_NAME()
91 mPrimRestartIndex = prim_restart_idx;
92 mPrimRestartOn = prim_restart_on;
93 mBaseVertex = base_vert;
94 mPrimType = prim_type;
97 bool hasNext()
const {
return mCurrentIndex != mEnd; }
99 virtual int a()
const {
return mA; }
100 virtual int b()
const {
return mB; }
101 virtual int c()
const {
return mC; }
106 VL_CHECK( end <= (
int)mArray->size() )
109 end = (int)mArray->size();
121 mCurrentIndex = start;
122 mA = mArray->at(start+0);
123 mB = mArray->at(start+1);
124 mC = mArray->at(start+2);
127 mCurrentIndex = start;
128 mA = mArray->at(start+0);
129 mB = mArray->at(start+2);
130 mC = mArray->at(start+4);
133 mCurrentIndex = start;
134 mA = mArray->at(start+0);
135 mB = mArray->at(start+1);
136 mC = mArray->at(start+2);
140 mCurrentIndex = start + 1;
141 mA = mArray->at(start+0);
142 mB = mArray->at(start+1);
143 mC = mArray->at(start+2);
147 mCurrentIndex = start;
148 mA = mArray->at(start+0);
149 mB = mArray->at(start+1);
150 mC = mArray->at(start+2);
154 mCurrentIndex = start;
155 mA = mArray->at(start+0);
156 mB = mArray->at(start+1);
157 mC = mArray->at(start+2);
160 Log::error(
Say(
"TriangleIteratorIndexed::initialize(): unsupported primitive type %n.\n") << mPrimType );
167 if ( mCurrentIndex != mEnd )
182 if ( mCurrentIndex == mEnd )
191 if ( mCurrentIndex >= mEnd )
192 mCurrentIndex = mEnd;
194 if ( isPrimRestart(mCurrentIndex) )
197 mA = mArray->at(mCurrentIndex + 0);
198 mB = mArray->at(mCurrentIndex + 1);
199 mC = mArray->at(mCurrentIndex + 2);
203 mA = mArray->at(mCurrentIndex + 0);
204 mB = mArray->at(mCurrentIndex + 1);
205 mC = mArray->at(mCurrentIndex + 2);
212 if ( mCurrentIndex >= mEnd )
213 mCurrentIndex = mEnd;
215 if ( isPrimRestart(mCurrentIndex) )
218 mA = mArray->at(mCurrentIndex + 0);
219 mB = mArray->at(mCurrentIndex + 2);
220 mC = mArray->at(mCurrentIndex + 4);
224 mA = mArray->at(mCurrentIndex + 0);
225 mB = mArray->at(mCurrentIndex + 2);
226 mC = mArray->at(mCurrentIndex + 4);
233 if ( mCurrentIndex + 2 >= mEnd )
234 mCurrentIndex = mEnd;
236 if ( isPrimRestart(mCurrentIndex + 2) )
240 mA = mArray->at(mCurrentIndex + 0);
241 mB = mArray->at(mCurrentIndex + 1);
242 mC = mArray->at(mCurrentIndex + 2);
249 mA = mArray->at(mCurrentIndex + 0);
250 mB = mArray->at(mCurrentIndex + 1);
251 mC = mArray->at(mCurrentIndex + 2);
255 mA = mArray->at(mCurrentIndex + 0);
256 mB = mArray->at(mCurrentIndex + 2);
257 mC = mArray->at(mCurrentIndex + 1);
265 if ( mCurrentIndex + 1 >= mEnd )
267 mCurrentIndex = mEnd;
270 if ( isPrimRestart(mCurrentIndex + 1) )
272 mIndex0 = mCurrentIndex + 2;
273 mCurrentIndex = mIndex0 + 1;
274 mA = mArray->at(mIndex0);
275 mB = mArray->at(mCurrentIndex + 0);
276 mC = mArray->at(mCurrentIndex + 1);
280 mA = mArray->at(mIndex0);
281 mB = mArray->at(mCurrentIndex + 0);
282 mC = mArray->at(mCurrentIndex + 1);
288 if ( mCurrentIndex >= mEnd )
290 mCurrentIndex = mEnd;
293 if ( isPrimRestart(mCurrentIndex) )
297 mA = mArray->at(mCurrentIndex+0);
298 mB = mArray->at(mCurrentIndex+1);
299 mC = mArray->at(mCurrentIndex+2);
306 mA = mArray->at(mCurrentIndex+0);
307 mB = mArray->at(mCurrentIndex+1);
308 mC = mArray->at(mCurrentIndex+2);
312 mA = mArray->at(mCurrentIndex+0);
313 mB = mArray->at(mCurrentIndex+1);
314 mC = mArray->at(mCurrentIndex-2);
325 if (mCurrentIndex != mEnd)
343 bool isPrimRestart(
int i)
const {
return mPrimRestartOn && mArray->at(i) == mPrimRestartIndex; }
346 const TArray* mArray;
353 unsigned int mPrimRestartIndex;
368 VL_DEBUG_SET_OBJECT_NAME()
369 mCurrentIndex = mStart = mEnd = 0;
371 mPrimType = prim_type;
375 bool hasNext()
const {
return mCurrentIndex != mEnd; }
377 virtual int a()
const {
return mA; }
378 virtual int b()
const {
return mB; }
379 virtual int c()
const {
return mC; }
385 mCurrentIndex = mEnd = end;
392 mCurrentIndex = start;
398 mCurrentIndex = start;
405 mCurrentIndex = start + 1;
412 mCurrentIndex = start;
419 mCurrentIndex = start;
432 if ( mCurrentIndex == mEnd )
441 if ( mCurrentIndex >= mEnd )
442 mCurrentIndex = mEnd;
445 mA = mCurrentIndex + 0;
446 mB = mCurrentIndex + 1;
447 mC = mCurrentIndex + 2;
454 if ( mCurrentIndex + 2 >= mEnd )
455 mCurrentIndex = mEnd;
461 mA = mCurrentIndex + 0;
462 mB = mCurrentIndex + 1;
463 mC = mCurrentIndex + 2;
467 mA = mCurrentIndex + 0;
468 mB = mCurrentIndex + 2;
469 mC = mCurrentIndex + 1;
477 if ( mCurrentIndex + 1 >= mEnd )
479 mCurrentIndex = mEnd;
484 mB = mCurrentIndex+0;
485 mC = mCurrentIndex+1;
491 if ( mCurrentIndex >= mEnd )
493 mCurrentIndex = mEnd;
500 mA = mCurrentIndex+0;
501 mB = mCurrentIndex+1;
502 mC = mCurrentIndex+2;
506 mA = mCurrentIndex+0;
507 mB = mCurrentIndex+1;
508 mC = mCurrentIndex-2;
519 if (mCurrentIndex == mEnd)
540 template<
class TArray>
546 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)
549 VL_DEBUG_SET_OBJECT_NAME()
550 mpBaseVertices = p_base_vertices;
551 mpCountVector = p_count_vector;
558 VL_CHECK( mpBaseVertices->size() == mpCountVector->size() )
559 if ( (*mpBaseVertices).size() )
561 int end = mStart + (*mpCountVector)[mCurPrim];
565 mCurPrim = (int)(*mpCountVector).size()-1;
573 if ( mCurPrim < (
int)(*mpCountVector).size()-1 )
575 mStart += (*mpCountVector)[mCurPrim];
610 bool next() {
return mIterator->next(); }
615 bool hasNext() {
return mIterator->hasNext(); }
618 int a()
const {
return mIterator->a(); }
621 int b()
const {
return mIterator->b(); }
624 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.