Boost logo

Boost Users :

From: Rodrigo de Salvo Braz (braz_at_[hidden])
Date: 2004-12-16 00:06:08


I think I may help you, but your problem is not clear to me yet.

On Wed, 15 Dec 2004, Eli Pulsifer wrote:

> The first problem is depending on the format of the underling vertices,
> the stride between the data elements will change.

I didn't understand this. What is a stride between data elements? Why does
it change? Why is that a problem?

> 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.

Can't you have an internal container and return iterators to this
container?

> 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)
> {
> }
> }

It looks like 'it' is not being used inside the loop, so I don't
understand this example.

Let me tell you why I think I may help you. I have written an iterator
adaptor that uses the elements through which the base iterator iterates in
order to determine a range to be recursively iterated. An example:

int[] a1 = {1,2,3};
int[] a2 = {4,5};

list<int> sublist1(a1, a1 + 3);
list<int> sublist2(a2, a2 + 2);

list<int*> l;
l.push_back(sublist1);
l.push_back(sublist2);

nested_iterator<list<int*>::iterator>, range_getter> ni;
for (ni = make_nested_iterator(l.begin(),l.end());
     ni != make_nested_iterator(l.end(),l.end());
     ni++)
{
    // ni points successively to 1, 2, 3, 4, 5
}

range_getter is an adaptable unary function class returning the
begin(),end() range of the container passed to it.

That is to say, a nested_iterator makes a bunch of ranges look as if they
are one. Would this be helpful to you?

Best,

Rodrigo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net