[vtk-developers] A vtkDataSampler and image interpolation

David Gobbi david.gobbi at gmail.com
Tue Jul 5 08:26:40 EDT 2011


Hi Will,

If I modified the vtkProbeFilter to use the vtkDataSampler, it would
allow people to customize the way that vtkProbeFilter interpolates the
data.

The interface would look like this: a SetDataSampler() method would be
added to vtkProbeFilter

void vtkProbeFilter::SetDataSampler(vtkDataSampler *);

The probe filter would have a default vtkDataSampler object which
would use FindCell to interpolate the data (much like the way
vtkProbeFilter works now).  But here is where the magic comes.  The
user would be able to provide a different data sampler:

vtkImageSampler *isample = vtkImageSampler::New();
probeFilter->SetDataSampler(isample);

The vtkImageSampler is for image data, it has interpolation code that
is specifically written for structured data and is orders of magnitude
faster than using FindCell to interpolate the data.  Also, it provides
the option of choosing different interpolation modes: nearest, linear,
and cubic.

So, in a nutshell, adding a SetDataSampler() method would make it
possible for users to customize the way that vtkProbeFilter
interpolates values from its Input.  The use of vtkImageSampler here
is just one example, if a person needs to use vtkProbeFilter on an FEM
data set and knows of an efficient way to interpolate their FEM, then
they could write a vtkDataSampler class specifically for their FEM.

Another way to describe my goal is as follows: I have a whole bunch of
image interpolation code that I've written and tweaked over the past
10+ years, and I want to be able to use this interpolation code with
the VTK graphics pipeline.  The vtkDataSampler class is how I hope to
achieve this.

 - David


On Tue, Jul 5, 2011 at 3:49 AM, Will Schroeder
<will.schroeder at kitware.com> wrote:
> David-
> What's the relationship of this vtkDataSampler class to the vtkProbeFilter?
> W
>
> On Mon, Jul 4, 2011 at 1:23 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi All,
>>
>> I've written some new interpolation classes for VTK, both for images
>> and for other data sets.  One thing that I want to ensure is that the
>> abstract interface is something that people will be satisfied with.
>> I use the same ScalarMode constants as vtkMapper, but there might
>> be a better way of selecting arrays that I am not aware of:
>>
>> class vtkDataSampler : public vtkObject
>> {
>>  // set the data to interpolate (does not establish pipeline connection)
>>  void SetInput(vtkDataObject *);
>>
>>  // update any internal state variables prior to commencing interpolation
>>  void Update();
>>
>>  // get an interpolated value, return "false" if out of bounds
>>  bool GetSample(const double point[3], double *value);
>>
>>  // get an interpolated value (meant for use by wrapper languages)
>>  double GetSample(double x, double y, double z, int component);
>>
>>  // set the scalar mode (same as vtkMapper scalar modes)
>>  void SetScalarMode(int mode);
>>  void SetScalarModeToDefault();
>>  void SetScalarModeToUsePointData();
>>  void SetScalarModeToUseCellData();
>>  void SetScalarModeToUsePointFieldData();
>>  void SetScalarModeToUseCellFieldData();
>>
>>  // set the array, if chosen scalar mode is field data
>>  void SetArrayName(const char *name);
>>
>>  void SetTolerance(double);
>>  void SetLocator(vtkLocator *locator);
>> };
>>
>> The changes are on gerrit, if people want to see the full implementation:
>> http://review.source.kitware.com/2004
>>
>>  - David



More information about the vtk-developers mailing list