[vtkusers] Forcing an Update of a vtkSource

Kevin Teich kteich at cortechs.net
Tue Feb 19 16:34:46 EST 2002


I'm writing a viewer/editor for volume data. I wrote a custom
vtkVolumeReader that reads in my data. That works fine. Now, I want to be
able to change that data in the middle of the pipeline execution.

I wrote a SetValue(x,y,z,v) function for the Reader class and call it from
my Tcl app. However, I don't see the changes until I change the origin of
the vtkImageReslice object (i.e. in a pan or zoom). How can I tell the
Reader that its data is changed and it should update the rest of the
pipeline?

I tried calling Modified() from within the object and from the Tcl script
($volumeReader Modified) followed by an Update call, but that seems to
restore the data to its original state, probably from some hidden cache.
Any ideas?

I realize that my method for setting data this way is probably horribly
and offensively incorrect and unelegant. If anyone would like to offer
advice on how I should do this properly, I would appreciate it.

My SetValue(x,y,z,value), sans error checking, does this:

  vtkStructuredPoints *output = this->GetOutput();
  vtkDataArray *scalars = output->GetPointData()->GetScalars();
  int index = x +
    (y * this->DataDimensions[0]) +
    (z * this->DataDimensions[0] * this->DataDimensions[1]);
  scalars->SetComponent( index, 0, value );
  output->Modified();

Thanks in advance.

-- 
Kevin Teich




More information about the vtkusers mailing list