Commit 0584cc63 authored by Will Schroeder's avatar Will Schroeder

Threaded and implemented power parameter

vtkShepardMethod has been threaded with vtkSMPTools. Also added
is the power parameter to control the interpolation basis.
Finally, a serious bug when distance==0 (between sample and
interpolated point) was fixed. Additional documentation was also
added into the mix.
parent 91cd5140
Pipeline #2732 passed with stage
......@@ -4,4 +4,5 @@ vtk_add_test_python(
shepards.py
triangularTexture.py
TestCheckerboardSplatter.py
TestShepardsMethod.py
)
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
ren1.SetViewport(0,0,.3333,1)
ren2 = vtk.vtkRenderer()
ren2.SetViewport(0.3333,0,.6667,1)
ren3 = vtk.vtkRenderer()
ren3.SetViewport(.6667,0,1,1)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.AddRenderer(ren2)
renWin.AddRenderer(ren3)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Create some points and scalars. Make sure that some
# of the points lie precisely on the volume points. This
# tests special interpolation cases.
#
points = vtk.vtkPoints()
points.InsertPoint(0, -1, -1, -1)
points.InsertPoint(1, 1, -1, -1)
points.InsertPoint(2, 0, 0, -1)
points.InsertPoint(3, -1, 1, -1)
points.InsertPoint(4, 1, 1, -1)
points.InsertPoint(5, -1, -1, 0)
points.InsertPoint(6, 1, -1, 0)
points.InsertPoint(7, 0, 0, 0)
points.InsertPoint(8, -1, 1, 0)
points.InsertPoint(9, 1, 1, 0)
points.InsertPoint(10, -1, -1, 1)
points.InsertPoint(11, 1, -1, 1)
points.InsertPoint(12, 0, 0, 1)
points.InsertPoint(13, -1, 1, 1)
points.InsertPoint(14, 1, 1, 1)
scalars = vtk.vtkFloatArray()
scalars.InsertValue(0, 5)
scalars.InsertValue(1, 5)
scalars.InsertValue(2, 10)
scalars.InsertValue(3, 5)
scalars.InsertValue(4, 5)
scalars.InsertValue(5, 10)
scalars.InsertValue(6, 10)
scalars.InsertValue(7, 20)
scalars.InsertValue(8, 10)
scalars.InsertValue(9, 10)
scalars.InsertValue(10, 20)
scalars.InsertValue(11, 20)
scalars.InsertValue(12, 40)
scalars.InsertValue(13, 20)
scalars.InsertValue(14, 20)
profile = vtk.vtkPolyData()
profile.SetPoints(points)
profile.GetPointData().SetScalars(scalars)
# Interpolate the points across the volume.
#
dim = 501
dim = 51
shepard1 = vtk.vtkShepardMethod()
shepard1.SetInputData(profile)
shepard1.SetModelBounds(-2,2, -2,2, -1,1)
shepard1.SetSampleDimensions(dim,dim,dim)
shepard1.SetNullValue(0)
shepard1.SetMaximumDistance(1)
shepard1.SetPowerParameter(1)
timer = vtk.vtkExecutionTimer()
timer.SetFilter(shepard1)
shepard1.Update()
wallClock = timer.GetElapsedWallClockTime()
print ("Shephard (P=1):", wallClock)
mapper1 = vtk.vtkDataSetMapper()
mapper1.SetInputConnection(shepard1.GetOutputPort())
mapper1.SetScalarRange(0,40)
block1 = vtk.vtkActor()
block1.SetMapper(mapper1)
shepard2 = vtk.vtkShepardMethod()
shepard2.SetInputData(profile)
shepard2.SetModelBounds(-2,2, -2,2, -1,1)
shepard2.SetSampleDimensions(dim,dim,dim)
shepard2.SetNullValue(0)
shepard2.SetMaximumDistance(1)
timer = vtk.vtkExecutionTimer()
timer.SetFilter(shepard2)
shepard2.Update()
wallClock = timer.GetElapsedWallClockTime()
print ("Shephard (P=2):", wallClock)
mapper2 = vtk.vtkDataSetMapper()
mapper2.SetInputConnection(shepard2.GetOutputPort())
mapper2.SetScalarRange(0,40)
block2 = vtk.vtkActor()
block2.SetMapper(mapper2)
shepard3 = vtk.vtkShepardMethod()
shepard3.SetInputData(profile)
shepard3.SetModelBounds(-2,2, -2,2, -1,1)
shepard3.SetSampleDimensions(dim,dim,dim)
shepard3.SetNullValue(0)
shepard3.SetMaximumDistance(1)
shepard3.SetPowerParameter(3)
timer = vtk.vtkExecutionTimer()
timer.SetFilter(shepard3)
shepard3.Update()
wallClock = timer.GetElapsedWallClockTime()
print ("Shephard (P=3):", wallClock)
mapper3 = vtk.vtkDataSetMapper()
mapper3.SetInputConnection(shepard3.GetOutputPort())
mapper3.SetScalarRange(0,40)
block3 = vtk.vtkActor()
block3.SetMapper(mapper3)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(block1)
ren1.SetBackground(1,1,1)
ren2.AddActor(block2)
ren2.SetBackground(1,1,1)
ren3.AddActor(block3)
ren3.SetBackground(1,1,1)
renWin.SetSize(900,300)
cam = ren1.GetActiveCamera()
cam.SetPosition(1,1,1)
ren1.ResetCamera()
ren2.SetActiveCamera(cam)
ren3.SetActiveCamera(cam)
renWin.Render()
# render the image
#
renWin.Render()
# --- end of script --
#iren.Start()
......@@ -61,3 +61,4 @@ renWin.Render()
# prevent the tk window from showing up then start the event loop
threshold = 15
# --- end of script --
#iren.Start()
......@@ -57,9 +57,13 @@
// Some voxels may never receive a contribution during the splatting process.
// The final value of these points can be specified with the "NullValue"
// instance variable.
//
// This class has been threaded with vtkSMPTools. Using TBB or other
// non-sequential type (set in the CMake variable
// VTK_SMP_IMPLEMENTATION_TYPE) may improve performance significantly.
// .SECTION See Also
// vtkShepardMethod
// vtkShepardMethod vtkCheckerboardSplatter
#ifndef vtkGaussianSplatter_h
#define vtkGaussianSplatter_h
......
This diff is collapsed.
......@@ -16,13 +16,13 @@
// using the method of Shepard
// .SECTION Description
// vtkShepardMethod is a filter used to interpolate point data and associated
// scalar values using Shepard's method. The method works by resampling the
// scalars associated with points defined on an arbitrary dataset onto a
// volume (i.e., structured points) dataset. The influence functions are
// described as "inverse distance weighted". Once the interpolation is
// performed across the volume, the usual volume visualization techniques
// (e.g., iso-contouring or volume rendering) can be used.
// vtkShepardMethod is a filter used to interpolate point scalar values using
// Shepard's method. The method works by resampling the scalars associated
// with points defined on an arbitrary dataset onto a volume (i.e.,
// structured points) dataset. The influence functions are described as
// "inverse distance weighted". Once the interpolation is performed across
// the volume, the usual volume visualization techniques (e.g.,
// iso-contouring or volume rendering) can be used.
//
// Note that this implementation also provides the ability to specify the
// power parameter p. Given the generalized Inverse Distance Weighting (IDW)
......@@ -44,8 +44,8 @@
// Strictly speaking, this is a modified Shepard's methodsince only points
// within the MaxiumDistance are used for interpolation. By setting the
// maximum distance to include the entire bounding box and therefore all
// points, the class executes much slower but incoproates all points into the
// interpolation process (true pure Shepard method).
// points, the class executes much slower but incorporates all points into
// the interpolation process (i.e., a pure Shepard method).
//
// The input to this filter is any dataset type. This filter can be used to
// resample the points of any type of dataset onto the output volume; i.e.,
......@@ -55,7 +55,7 @@
// The bounds of the data (i.e., the sample space) is automatically computed
// if not set by the user.
//
// If you use a maximum distance less than 1.0 (i.e., use a modified
// If you use a maximum distance less than 1.0 (i.e., using a modified
// Shephard's method), some output points may never receive a
// contribution. The final value of these points can be specified with the
// "NullValue" instance variable.
......@@ -83,14 +83,10 @@ public:
// Description:
// Construct with sample dimensions=(50,50,50) and so that model bounds are
// automatically computed from the input. Null value for each unvisited output
// point is 0.0. Maximum distance is 0.25. Power parameter p=2.
// automatically computed from the input. The null value for each unvisited
// output point is 0.0. Maximum distance is 0.25. Power parameter p=2.
static vtkShepardMethod *New();
// Description:
// Specify i-j-k dimensions on which to interpolate the input points.
vtkGetVectorMacro(SampleDimensions,int,3);
// Description:
// Set the i-j-k dimensions on which to interpolate the input points.
void SetSampleDimensions(int i, int j, int k);
......@@ -100,24 +96,30 @@ public:
void SetSampleDimensions(int dim[3]);
// Description:
// Specify maximum influence distance of each input point. This distance is
// a fraction of the length of the diagonal of the sample space. Thus,
// values of 1.0 will cause each input point to influence all points in the
// volume dataset. Values less than 1.0 can improve performance
// significantly. By default the maximum distance is 0.25.
// Retrieve the i-j-k dimensions on which to interpolate the input points.
vtkGetVectorMacro(SampleDimensions,int,3);
// Description:
// Specify the maximum influence distance of each input point. This
// distance is a fraction of the length of the diagonal of the sample
// space. Thus, values of 1.0 will cause each input point to influence all
// points in the volume dataset. Values less than 1.0 can improve
// performance significantly. By default the maximum distance is 0.25.
vtkSetClampMacro(MaximumDistance,double,0.0,1.0);
vtkGetMacro(MaximumDistance,double);
// Description:
// Set the value for output points not receiving a contribution from the
// input points. Output points may not receive a contribution when the
// Set the value for output points not receiving a contribution from any
// input point(s). Output points may not receive a contribution when the
// MaximumDistance < 1.
vtkSetMacro(NullValue,double);
vtkGetMacro(NullValue,double);
// Description:
// Specify the position in space to perform the sampling. The ModelBounds
// and SampleDimensions together define the output volume.
// and SampleDimensions together define the output volume. (Note: if the
// ModelBounds are set to an invalid state [zero or negative volume] then
// the bounds are computed automatically.)
vtkSetVector6Macro(ModelBounds,double);
vtkGetVectorMacro(ModelBounds,double,6);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment