Hi John,<div><br></div><div>Thanks for the comments, it sounds like this project is going to be even more useful that I originally guessed that it would be.</div><div><br></div><div>About the names, though, I'm a fan of succinct names so how about the following:</div>

<div><br></div><div>vtkAbstractInterpolator (base class, interface only)</div><div>  vtkDataInterpolator (uses FindCell and optional locator, works on any data set)</div><div>  vtk(whichever)Interpolator (various accelerated interpolators)</div>

<div><br></div><div>  vtkAbstractImageInterpolator (base class for image interpolators)</div><div>    vtkImageInterpolator (the basic image interpolator)</div><div>    vtkImageSincInterpolator (my sinc interpolator)</div>

<div>    vtkImageBSplineInterpolator (my b-spline interpolator)</div><div><br></div><div>But I wish that someone would comment on the interface that I proposed in my first email, or look at the header files in the gerrit repository.  My main concern before I ready this for submission is that the interface is satisfactory to other VTK developers.</div>

<div><br></div><div> - David</div><div><br></div><div><br><div class="gmail_quote">On Wed, Jul 6, 2011 at 12:41 AM, Biddiscombe, John A. <span dir="ltr"><<a href="mailto:biddisco@cscs.ch">biddisco@cscs.ch</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">





<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">The streamline and particle tracer algorithms could indeed benefit from specialzed InterpolationStrategies. When creating the Particle tracer, I found the findcell
 method to be far too slow for real use and made changes to the various filters to use locator classes internally (using code which is in vtkModifiedBSPTree), this allowed much faster interpolation than the default method (I still have somewhere uncommitted
 changes to probefilter etc which have locators enabled). I began the process of making change to the streamline filter to also make use of this, but as I didn’t need it directly, I didn’t complete the work.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Allowing an InterpolationStrategy class which (let’s say – names not important here) is<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-size:11.0pt;color:#1F497D">vtkDefaultUnstructuredInterpolationStrategy (uses FindCell by default),
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-size:11.0pt;color:#1F497D">vtkAcceleratedUnstructuredInterpolationStrategy (uses locator, option OctTree, BSP, Other, but takes more memory and has slower startup
 time – tree construction so not good for small datasets)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-size:11.0pt;color:#1F497D">etc etc<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">would benefit the streamline type filters I’m sure. I suspect quite a lot of work might be involved in getting them upgraded.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">For certain specialized cases (particle tracer), I made extensive use of caching of locators over time when grids were static (but scalars were varying). This
 produced very significant speedups but the interface was quite nasty – I cached individual cellIds and locator+dataset refs for multiblock traversal (see vtkCachingInterpolatedVelocityField for a quick overview and in particular the caching struct IVFDataSetInfo
 in the header). <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">If some of this functionality were exposed via the InterpolationStrategy, then it could be shoehorned into the streamline/particle tracer code.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">JB<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Caution : Writing from memory and it’s been a while since I worked on this code. NB. I have a new particle tracer now which is even nastier and has InjectionStrategies
 and TerminationStrategies which have their own pipeline inputs and are similar to the InterpolationStrategy in terms of abstraction.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt">From:</span></b><span lang="EN-US" style="font-size:10.0pt"> <a href="mailto:vtk-developers-bounces@vtk.org" target="_blank">vtk-developers-bounces@vtk.org</a> [mailto:<a href="mailto:vtk-developers-bounces@vtk.org" target="_blank">vtk-developers-bounces@vtk.org</a>]
<b>On Behalf Of </b>Will Schroeder<br>
<b>Sent:</b> 05 July 2011 20:24<br>
<b>To:</b> David Gobbi</span></p><div class="im"><br>
<b>Cc:</b> VTK Developers<br>
<b>Subject:</b> Re: [vtk-developers] A vtkDataSampler and image interpolation<u></u><u></u></div><p></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Okay thanks, assuming we document this in some manner (wiki or VTK Journal article) let's put a placeholder for some other potential algorithms. I know in DTI and other medical applications they are computing "streamlines" so this could
 be very useful for medical image analysis.<u></u><u></u></p><div><div></div><div class="h5">
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">W<u></u><u></u></p>
<div>
<p class="MsoNormal">On Tue, Jul 5, 2011 at 12:51 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Hi Will,<br>
<br>
So far I've only considered the filters that I use, mainly vtkProbeFilter and<br>
the implicit functions vtkImplicitDataSet and vtkImplicitVolume.  And I've<br>
also considered the possibility of a volume mapper that uses it, so that<br>
people can provide their own specialized interpolation algorithms when they<br>
are volume rendering their data.  However, my experience with VTK's more<br>
sophisticated graphics algorithms like streamlines is close to nil... I would<br>
have to rely on other people's expertise to make a full list.<br>
<br>
 - David<br>
<br>
<br>
On Tue, Jul 5, 2011 at 10:27 AM, Will Schroeder<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a>> wrote:<br>
> Pretty cool idea David, thanks for the explanation.<br>
> There are other potential filter applications that come to mind (as I'm sure<br>
> you're aware of) such as streamlines, etc. Have you  created a list, or<br>
> thought about, which filters might benefit from this capability?<br>
> W<br>
><br>
> On Tue, Jul 5, 2011 at 8:26 AM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:<br>
>><br>
>> Hi Will,<br>
>><br>
>> If I modified the vtkProbeFilter to use the vtkDataSampler, it would<br>
>> allow people to customize the way that vtkProbeFilter interpolates the<br>
>> data.<br>
>><br>
>> The interface would look like this: a SetDataSampler() method would be<br>
>> added to vtkProbeFilter<br>
>><br>
>> void vtkProbeFilter::SetDataSampler(vtkDataSampler *);<br>
>><br>
>> The probe filter would have a default vtkDataSampler object which<br>
>> would use FindCell to interpolate the data (much like the way<br>
>> vtkProbeFilter works now).  But here is where the magic comes.  The<br>
>> user would be able to provide a different data sampler:<br>
>><br>
>> vtkImageSampler *isample = vtkImageSampler::New();<br>
>> probeFilter->SetDataSampler(isample);<br>
>><br>
>> The vtkImageSampler is for image data, it has interpolation code that<br>
>> is specifically written for structured data and is orders of magnitude<br>
>> faster than using FindCell to interpolate the data.  Also, it provides<br>
>> the option of choosing different interpolation modes: nearest, linear,<br>
>> and cubic.<br>
>><br>
>> So, in a nutshell, adding a SetDataSampler() method would make it<br>
>> possible for users to customize the way that vtkProbeFilter<br>
>> interpolates values from its Input.  The use of vtkImageSampler here<br>
>> is just one example, if a person needs to use vtkProbeFilter on an FEM<br>
>> data set and knows of an efficient way to interpolate their FEM, then<br>
>> they could write a vtkDataSampler class specifically for their FEM.<br>
>><br>
>> Another way to describe my goal is as follows: I have a whole bunch of<br>
>> image interpolation code that I've written and tweaked over the past<br>
>> 10+ years, and I want to be able to use this interpolation code with<br>
>> the VTK graphics pipeline.  The vtkDataSampler class is how I hope to<br>
>> achieve this.<br>
>><br>
>>  - David<br>
>><br>
>><br>
>> On Tue, Jul 5, 2011 at 3:49 AM, Will Schroeder<br>
>> <<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a>> wrote:<br>
>> > David-<br>
>> > What's the relationship of this vtkDataSampler class to the<br>
>> > vtkProbeFilter?<br>
>> > W<br>
>> ><br>
>> > On Mon, Jul 4, 2011 at 1:23 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Hi All,<br>
>> >><br>
>> >> I've written some new interpolation classes for VTK, both for images<br>
>> >> and for other data sets.  One thing that I want to ensure is that the<br>
>> >> abstract interface is something that people will be satisfied with.<br>
>> >> I use the same ScalarMode constants as vtkMapper, but there might<br>
>> >> be a better way of selecting arrays that I am not aware of:<br>
>> >><br>
>> >> class vtkDataSampler : public vtkObject<br>
>> >> {<br>
>> >>  // set the data to interpolate (does not establish pipeline<br>
>> >> connection)<br>
>> >>  void SetInput(vtkDataObject *);<br>
>> >><br>
>> >>  // update any internal state variables prior to commencing<br>
>> >> interpolation<br>
>> >>  void Update();<br>
>> >><br>
>> >>  // get an interpolated value, return "false" if out of bounds<br>
>> >>  bool GetSample(const double point[3], double *value);<br>
>> >><br>
>> >>  // get an interpolated value (meant for use by wrapper languages)<br>
>> >>  double GetSample(double x, double y, double z, int component);<br>
>> >><br>
>> >>  // set the scalar mode (same as vtkMapper scalar modes)<br>
>> >>  void SetScalarMode(int mode);<br>
>> >>  void SetScalarModeToDefault();<br>
>> >>  void SetScalarModeToUsePointData();<br>
>> >>  void SetScalarModeToUseCellData();<br>
>> >>  void SetScalarModeToUsePointFieldData();<br>
>> >>  void SetScalarModeToUseCellFieldData();<br>
>> >><br>
>> >>  // set the array, if chosen scalar mode is field data<br>
>> >>  void SetArrayName(const char *name);<br>
>> >><br>
>> >>  void SetTolerance(double);<br>
>> >>  void SetLocator(vtkLocator *locator);<br>
>> >> };<br>
>> >><br>
>> >> The changes are on gerrit, if people want to see the full<br>
>> >> implementation:<br>
>> >> <a href="http://review.source.kitware.com/2004" target="_blank">http://review.source.kitware.com/2004</a><br>
>> >><br>
>> >>  - David<br>
><br>
><br>
><br>
> --<br>
> William J. Schroeder, PhD<br>
> Kitware, Inc.<br>
> 28 Corporate Drive<br>
> Clifton Park, NY 12065<br>
> <a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a><br>
> <a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br>
> <a href="tel:%28518%29%20881-4902" target="_blank">(518) 881-4902</a><br>
><u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<br>
-- <br>
William J. Schroeder, PhD<br>
Kitware, Inc.<br>
28 Corporate Drive<br>
Clifton Park, NY 12065<br>
<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a><br>
<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br>
<a href="tel:%28518%29%20881-4902" value="+15188814902" target="_blank">(518) 881-4902</a><u></u><u></u></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>