[vtkusers] vtkImageData::ComputeStructuredCoordinates

Adam D. Burry aburry at igotechnologies.com
Thu Dec 20 16:40:52 EST 2001


Hi:

I just fixed a problem with the way I was using
vtkImageData::ComputeStructuredCoordinates and I thought I would share
it since other people may make the same mistake.

The method in question allows you to turn a position in space into ijk
indices into your image data.

I was writing:

	// ...
	float* pos = getPosition();
	int indices[] = { 0, 0, 0 };
	float pcoords[] = { 0.0f, 0.0f, 0.0f };
	int inside = pVolume->ComputeStructuredCoordinates( pos, indices,
pcoords );
	if ( !inside )
	{
		// use indices as though they are relatively right
		// although outside the volume
	}


The problem is with the if-block. It turns out that
ComputeStructuredCoordinates returns early if it detects that pos is
outside the volume.

In my case I can fix my code by initialising indices to be outside the
volume.

I think it would be better if either (in order of preference):
	1. ComputeStructuredCoordinates did not return early.
	2. The method initialised indices to be outside the volume.
	3. The method was documented to decribe the state of indices in all
cases.


Thanks.

Adam

--
Mr. Adam D. Burry, Software Developer
aburry at igotechnologies.com



More information about the vtkusers mailing list