[vtk-developers] vtkImageIterator: please...
Lisa Avila
lisa.avila at kitware.com
Tue May 20 10:30:20 EDT 2003
Hello Mathieu,
I am not entirely sure what you are doing in your NextSpan method, but
maybe this explanation will help.
The increments are how to get from one pixel (voxel) to its neighbor in X,
Y, and Z.
The continuous increments are how to get from the end of one row of pixels
to the beginning of the next row, or the end of one slice of voxels to the
beginning of the next slice. The first element in the continuous increments
array is always zero (how to get from the last component of one pixel to
the first component of the next pixel) All of these continuous increments
assume that you've already incremented your pointer by one at the end of
your inner loop (over components).
Your loop to traverse your data would be like this:
ptr = scalar pointer at location (updateExtent[0], updateExtent[2],
updateExtent[4]);
for ( z = updateExtent[4]; z <= updateExtent[5]; z++ )
{
for ( y = updateExtent[2]; y <= updateExtent[3]; y++ )
{
for ( x = updateExtent[0]; x <= updateExtent[1]; x++ )
{
for ( c = 0; c < numComponents; c++ )
{
/* do processing here */
ptr++;
}
ptr+= continuousIncrements[0]; // not necessary - always 0
}
ptr += continuousIncrements[1];
}
ptr += continuousIncrements[2];
}
Lisa
At 09:34 AM 5/20/2003, Mathieu Malaterre wrote:
>Hi all,
>
> I am very sorry to bug you with such a simple problem, but I
> really don't understand what's wrong. This is my last attempt, I promised
> not to bug any of you again with this problem.
>
> As I didn't get no answer from my mails (*), I assume there is
> something I am doing wrong. Could someone told me why the segmentation
> fault I had with my program could not be fixed with the code I proposed
> by adding:
>
> this->SpanEndPointer += this->ContinuousIncrements[2];
>
> And the complete version is:
>
>template <class DType>
>void vtkImageIterator<DType>::NextSpan()
>{
> this->Pointer += this->Increments[1];
> this->SpanEndPointer += this->Increments[1];
> if (this->Pointer >= this->SliceEndPointer)
> {
> this->Pointer += this->ContinuousIncrements[2];
> this->SpanEndPointer += this->ContinuousIncrements[2]; //<- here
> this->SliceEndPointer += this->Increments[2];
> }
>}
>
> If you don't have time to answer, could you just point me out
> some documentations about how 'extents' are handle internally in VTK
> (showing that I don't need to update SpanEndPointer).
>
>
>Thanks a lot,
>
>(*)
>http://vtk.org/pipermail/vtkusers/2003-May/017865.html
>http://vtk.org/pipermail/vtkusers/2003-May/017902.html
>
>_______________________________________________
>vtk-developers mailing list
>vtk-developers at public.kitware.com
>http://public.kitware.com/mailman/listinfo/vtk-developers
More information about the vtk-developers
mailing list