Hello,
I have a situation which is probably quite common and
already addressed by boost.
So rather than write it my self, maybe someone can point me
to the answer.
I’ve got a geometry class that needs to expose iterators for the underling vertex components.
Example:
Class Vertex
{
positions_iterator PositionsBegin();
positions_iterator PositionsEnd();
normals_iterator NormalsBegin();
normals _iterator
NormalsEnd();
…
}
The first problem is depending on the format of the
underling vertices, the stride between the data elements will change.
Is there some easy way to implement this?
I think writing my own using the boost::iterator_adapter
is probably the way to go.
Second problem is more involved.
The texture data not only has a stride but a variable number
of elements.
Some vertices have 2 texture coordinates, some 3, some even
more.
Id love to define this iterator like
this:
stride_iterator<
pair<float_iterator, float_iterator>
> tex_coord_iterator;
then create the iterator:
stride_tupel_iterator<
pair<float_iterator, float_iterator>
>( pFirstTexCoord, texCoordStride, texCoordCount );
then use it:
stride_tupel_iterator<
pair<float_iterator, float_iterator>
> it;
for( it = vertex.PositionBegin() ; it != vertex.PositionEnd()
; ++it)
{
pair<float_iterator, float_iterator> coords;
float_iterator iCoord;
for(iCoord = coords.first
; iCoord != coords.last ;
++iCoord)
{
}
}
This will probably also require me to create my own highly special
iterator class or is there a better way.