[vtkusers] Writing a StructuredPointsSource subclass

Kevin Teich kteich at cortechs.net
Thu Feb 21 15:47:13 EST 2002


I'm writing a subclass of vtkStructuredPointsSource that will copy an
input SP and pass it along to output. Eventually it will have a SetValue
function, so it's not quite a SPToSPFilter. But anyway. It has a
vtkImageData as member data to hold the image. It has one function to copy
the input:

void vtkMutableStructuredPointsSource::CopyInput(vtkImageData *input)
{
  if (this->ImageData == NULL)
    {
      this->ImageData = vtkImageData::New();
    }

  this->ImageData->DeepCopy( input );

  // Just for good measure.
  this->ImageData->SetWholeExtent(input->GetWholeExtent());
  this->ImageData->SetSpacing(input->GetSpacing());
  this->ImageData->SetOrigin(input->GetOrigin());
}

I've ran checks to make sure the data is copied correctly by checking the
extent and grabbing a scalar pointer with GetScalarPointer, and it all
appears to be fine. Okay, so I've got the data.

In Execute(), I do this:

void vtkMutableStructuredPointsSource::Execute()
{
  output->SetWholeExtent(this->ImageData->GetWholeExtent());
  output->SetNumberOfScalarComponents
        (this->ImageData->GetNumberOfScalarComponents());
  output->SetSpacing(this->ImageData->GetSpacing());
  output->SetOrigin(this->ImageData->GetOrigin());

  output->GetPointData()->SetScalars
	(this->ImageData->GetPointData()->GetScalars() );
}

ExecuteInformation() does the same thing except it doesnt set the scalar
data at the end. This is very similar to the code I use for a custom
volume reader that works.

This doesn't work. When I hook it up as the source to a
VolumeRaycastMapper and then to a Volume, nothing gets rendered. When I
hook it up to an ImageReslice, I get this error:

vtkStructuredPoints (0x8137e58): GetScalarPointer: Pixel (0, 0, 0) not in
memory.
 Current extent= (0, -1, 0, -1, 0, -1)

I know I'm missing something obvious. Any pointers? Thanks.

-- 
Kevin Teich




More information about the vtkusers mailing list