[vtkusers] Bug + fix: vtkVolumeTextureMapper2D

Jorrit Schaap jorrit at lkeb.azl.nl
Thu Jun 15 06:11:10 EDT 2000


Hi Lisa and vtkusers,

I found a bug in the vtkVolumeTextureMapper2D. (I'm using nightly
06/13/00)

In the templated functions that calculate the rectangles and the
textures, the size of the rectangles is to big. More specificaly: the
array of floats, v, isn't set right. For example in the
VolumeTextureMapper2D_XMajorDirection function it says:

  v[1] = origin[1];
  v[2] = origin[2];

  v[4] = origin[1];
  v[5] = spacing[2] * size[2] + origin[2];

  v[7] = spacing[1] * size[1] + origin[1];
  v[8] = spacing[2] * size[2] + origin[2];

  v[10] = spacing[1] * size[1]  + origin[1];
  v[11] = origin[2];

I think this should be:

  v[1] = origin[1];
  v[2] = origin[2];

  v[4] = origin[1];
  v[5] = spacing[2] * (size[2] - 1) + origin[2];

  v[7] = spacing[1] * (size[1] - 1) + origin[1];
  v[8] = spacing[2] * (size[2] - 1) + origin[2];

  v[10] = spacing[1] * (size[1] - 1) + origin[1];
  v[11] = origin[2];

the same goes for the functions VolumeTextureMapper2D_YMajorDirection
and VolumeTextureMapper2D_ZMajorDirection: replace size[..] by (size[..]
-1)

This way the rendered volume is exactly the same size as its bounds are
(for example shown by an outline).

So far the bug and the fix. Furthermore I noticed something strange in
the computation of the texturecoordinates t[..], but i'm not sure if its
a bug.
it says (just above the coputation of the v[..] values):

  float offset[2];
  offset[0] = 0.5 / (float)tsize[0];
  offset[1] = 0.5 / (float)tsize[1];
  t[0] = offset[0];
  t[1] = offset[1];
  t[2] = offset[0];
  t[3] = ((float)size[2] / (float)tsize[1]) - offset[1];
  t[4] = ((float)size[1] / (float)tsize[0]) - offset[0];
  t[5] = ((float)size[2] / (float)tsize[1]) - offset[1];
  t[6] = ((float)size[1] / (float)tsize[0]) - offset[0];
  t[7] = offset[1];

the offset values are 0.5 / 2^n with n >= 5  ( tsize[..] is always >=32
)
this means that offset[..] <= 0.015625
then take a look at the computation of t[..], these values are always
between offset and 1 - offset
although offset is a very small value, t will never cover the entire
interval between 0 and 1, which is the way to go if you want to see the
entire texture on your rectangle.

I'm puzzled by this, and maybe Lisa can explain why the offset is
there...

Kind regards,

Jorrit





More information about the vtkusers mailing list