Commit 39b30715 authored by Will Schroeder's avatar Will Schroeder

Move vtkPointCloud remote to Filters/Points

Added a number of filters for processing point clouds. The files
originally came from the vtkPointCloud remote module.
parent a4931b98
Pipeline #27428 passed with stage
set(Module_SRCS
vtkBoundedPointSource.cxx
vtkEllipsoidalGaussianKernel.cxx
vtkEuclideanClusterExtraction.cxx
vtkExtractHierarchicalBins.cxx
vtkExtractPointCloudPiece.cxx
vtkExtractPoints.cxx
vtkExtractSurface.cxx
vtkFitImplicitFunction.cxx
vtkGaussianKernel.cxx
vtkGeneralizedKernel.cxx
vtkHierarchicalBinningFilter.cxx
vtkInterpolationKernel.cxx
vtkLinearKernel.cxx
vtkPCACurvatureEstimation.cxx
vtkPCANormalEstimation.cxx
vtkPointCloudFilter.cxx
vtkPointInterpolator.cxx
vtkPointInterpolator2D.cxx
vtkProbabilisticVoronoiKernel.cxx
vtkRadiusOutlierRemoval.cxx
vtkSPHInterpolator.cxx
vtkSPHCubicKernel.cxx
vtkSPHKernel.cxx
vtkSPHQuarticKernel.cxx
vtkSPHQuinticKernel.cxx
vtkShepardKernel.cxx
vtkWendlandQuinticKernel.cxx
vtkSignedDistance.cxx
vtkStatisticalOutlierRemoval.cxx
vtkVoxelGrid.cxx
vtkVoronoiKernel.cxx
vtkWendlandQuinticKernel.cxx
)
set_source_files_properties(
vtkGeneralizedKernel.cxx
vtkInterpolationKernel
vtkPointCloudFilter
ABSTRACT
)
......
......@@ -7,3 +7,21 @@ vtk_add_test_python(
TestSPHInterpolator.py
TestSPHInterpolator2D.py
)
if ("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
vtk_add_test_python(
TestEuclideanClusterExtraction.py
TestEuclideanClusterExtraction2.py
TestExtractPoints.py
TestFitImplicitFunction.py
TestHierarchicalBinningFilter.py
TestPCACurvatureEstimation.py
TestPCACurvatureEstimation2.py
TestPCANormalEstimation.py
TestPCANormalEstimation2.py
TestRadiusOutlierRemoval.py
TestSignedDistanceFilter.py
TestStatisticalOutlierRemoval.py
TestVoxelGridFilter.py
)
endif ()
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# create pipeline
#
# Create a cylinder
cyl = vtk.vtkCylinderSource()
cyl.SetCenter(-2,0,0)
cyl.SetRadius(0.02)
cyl.SetHeight(1.8)
cyl.SetResolution(24)
# Create a (thin) box implicit function
plane = vtk.vtkPlaneSource()
plane.SetOrigin(-1, -0.5, 0)
plane.SetPoint1(0.5, -0.5, 0)
plane.SetPoint2(-1, 0.5, 0)
# Create a sphere implicit function
sphere = vtk.vtkSphereSource()
sphere.SetCenter(2,0,0)
sphere.SetRadius(0.8)
sphere.SetThetaResolution(96)
sphere.SetPhiResolution(48)
# Boolean (union) these together
append = vtk.vtkAppendPolyData()
append.AddInputConnection(cyl.GetOutputPort())
append.AddInputConnection(plane.GetOutputPort())
append.AddInputConnection(sphere.GetOutputPort())
# Extract points along sphere surface
pts = vtk.vtkPolyDataPointSampler()
pts.SetInputConnection(append.GetOutputPort())
pts.SetDistance(0.025)
pts.Update()
# Now see if we can extract the three objects as separate clusters.
extr = vtk.vtkEuclideanClusterExtraction()
extr.SetInputConnection(pts.GetOutputPort())
extr.SetRadius(0.1)
extr.ColorClustersOn()
extr.SetExtractionModeToAllClusters()
# Time execution
timer = vtk.vtkTimerLog()
timer.StartTimer()
extr.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Points processed: {0}".format(pts.GetOutput().GetNumberOfPoints()))
print(" Time to segment objects: {0}".format(time))
print(" Number of clusters: {0}".format(extr.GetNumberOfExtractedClusters()))
# Three different outputs for different curvatures
subMapper = vtk.vtkPointGaussianMapper()
subMapper.SetInputConnection(extr.GetOutputPort(0))
subMapper.EmissiveOff()
subMapper.SetScaleFactor(0.0)
subMapper.SetScalarRange(0,2)
subActor = vtk.vtkActor()
subActor.SetMapper(subMapper)
subActor.AddPosition(0,2.25,0)
# Create the RenderWindow, Renderer and both Actors
#
ren0 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren0.AddActor(subActor)
ren0.SetBackground(0.1, 0.2, 0.4)
renWin.SetSize(250,250)
cam = ren0.GetActiveCamera()
cam.SetFocalPoint(0,0,-1)
cam.SetPosition(0,0,0)
ren0.ResetCamera()
iren.Initialize()
# render the image
#
renWin.Render()
#iren.Start()
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Parameters for debugging
NPts = 100000
math = vtk.vtkMath()
math.RandomSeed(31415)
# create pipeline
#
points = vtk.vtkBoundedPointSource()
points.SetNumberOfPoints(NPts)
points.SetBounds(-3,3, -1,1, -1,1)
points.ProduceRandomScalarsOff()
points.ProduceCellOutputOff()
# create some scalars based on implicit function
# Create a cylinder
cyl = vtk.vtkCylinder()
cyl.SetCenter(-2,0,0)
cyl.SetRadius(0.02)
# Create a (thin) box implicit function
box = vtk.vtkBox()
box.SetBounds(-1,0.5, -0.5,0.5, -0.0005, 0.0005)
# Create a sphere implicit function
sphere = vtk.vtkSphere()
sphere.SetCenter(2,0,0)
sphere.SetRadius(0.8)
# Boolean (union) these together
imp = vtk.vtkImplicitBoolean()
imp.SetOperationTypeToUnion()
imp.AddFunction(cyl)
imp.AddFunction(box)
imp.AddFunction(sphere)
# Generate scalars and vector
sample = vtk.vtkSampleImplicitFunctionFilter()
sample.SetInputConnection(points.GetOutputPort())
sample.SetImplicitFunction(imp)
sample.Update()
print(sample.GetOutput().GetScalarRange())
# Now see if we can extract the three objects as separate clusters.
extr = vtk.vtkEuclideanClusterExtraction()
extr.SetInputConnection(sample.GetOutputPort())
extr.SetRadius(0.15)
#extr.ColorClustersOn()
#extr.SetExtractionModeToAllClusters()
extr.SetExtractionModeToLargestCluster()
extr.ScalarConnectivityOn()
extr.SetScalarRange(-0.64,-.3)
# Time execution
timer = vtk.vtkTimerLog()
timer.StartTimer()
extr.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Points processed: {0}".format(points.GetOutput().GetNumberOfPoints()))
print(" Time to segment objects: {0}".format(time))
print(" Number of clusters: {0}".format(extr.GetNumberOfExtractedClusters()))
# Draw the points
subMapper = vtk.vtkPointGaussianMapper()
subMapper.SetInputConnection(extr.GetOutputPort(0))
#subMapper.SetInputConnection(sample.GetOutputPort(0))
subMapper.EmissiveOff()
subMapper.SetScaleFactor(0.0)
subMapper.SetScalarRange(-0.64,2.25)
subActor = vtk.vtkActor()
subActor.SetMapper(subMapper)
# Create an outline
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(sample.GetOutputPort())
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# Create the RenderWindow, Renderer and both Actors
#
ren0 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren0.AddActor(subActor)
ren0.AddActor(outlineActor)
ren0.SetBackground(0.1, 0.2, 0.4)
renWin.SetSize(250,250)
cam = ren0.GetActiveCamera()
cam.SetFocalPoint(0,0,-1)
cam.SetPosition(0,0,0)
ren0.ResetCamera()
iren.Initialize()
# render the image
#
renWin.Render()
#iren.Start()
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Interpolate onto a volume
# Parameters for debugging
NPts = 1000000
math = vtk.vtkMath()
math.RandomSeed(31415)
# create pipeline
#
points = vtk.vtkBoundedPointSource()
points.SetNumberOfPoints(NPts)
points.ProduceRandomScalarsOn()
points.ProduceCellOutputOff()
points.Update()
# Create a sphere implicit function
sphere = vtk.vtkSphere()
sphere.SetCenter(0.9,0.1,0.1)
sphere.SetRadius(0.33)
# Extract points within sphere
extract = vtk.vtkExtractPoints()
extract.SetInputConnection(points.GetOutputPort())
extract.SetImplicitFunction(sphere)
# Time execution
timer = vtk.vtkTimerLog()
timer.StartTimer()
extract.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Time to remove points: {0}".format(time))
print(" Number removed: {0}".format(extract.GetNumberOfPointsRemoved()),
" (out of: {}".format(NPts))
# First output are the non-outliers
extMapper = vtk.vtkPointGaussianMapper()
extMapper.SetInputConnection(extract.GetOutputPort())
extMapper.EmissiveOff()
extMapper.SetScaleFactor(0.0)
extActor = vtk.vtkActor()
extActor.SetMapper(extMapper)
# Create an outline
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(points.GetOutputPort())
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# Create the RenderWindow, Renderer and both Actors
#
ren0 = vtk.vtkRenderer()
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren0.AddActor(extActor)
ren0.AddActor(outlineActor)
ren0.SetBackground(0.1, 0.2, 0.4)
renWin.SetSize(250,250)
cam = ren0.GetActiveCamera()
cam.SetFocalPoint(1,1,1)
cam.SetPosition(0,0,0)
ren0.ResetCamera()
ren1.SetActiveCamera(cam)
iren.Initialize()
# render the image
#
renWin.Render()
#iren.Start()
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Interpolate onto a volume
# Parameters for debugging
NPts = 1000000
math = vtk.vtkMath()
math.RandomSeed(31415)
# create pipeline
#
points = vtk.vtkBoundedPointSource()
points.SetNumberOfPoints(NPts)
points.ProduceRandomScalarsOn()
points.ProduceCellOutputOff()
points.Update()
# Create a sphere implicit function
sphere = vtk.vtkSphere()
sphere.SetCenter(0.9,0.1,0.1)
sphere.SetRadius(0.33)
# Extract points within sphere
extract = vtk.vtkFitImplicitFunction()
extract.SetInputConnection(points.GetOutputPort())
extract.SetImplicitFunction(sphere)
extract.SetThreshold(0.005)
# Time execution
timer = vtk.vtkTimerLog()
timer.StartTimer()
extract.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Time to extract points: {0}".format(time))
print(" Number removed: {0}".format(extract.GetNumberOfPointsRemoved()),
" (out of: {}".format(NPts))
# First output are the non-outliers
extMapper = vtk.vtkPointGaussianMapper()
extMapper.SetInputConnection(extract.GetOutputPort())
extMapper.EmissiveOff()
extMapper.SetScaleFactor(0.0)
extActor = vtk.vtkActor()
extActor.SetMapper(extMapper)
# Create an outline
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(points.GetOutputPort())
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# Create the RenderWindow, Renderer and both Actors
#
ren0 = vtk.vtkRenderer()
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren0.AddActor(extActor)
ren0.AddActor(outlineActor)
ren0.SetBackground(0.1, 0.2, 0.4)
renWin.SetSize(250,250)
cam = ren0.GetActiveCamera()
cam.SetFocalPoint(1,1,1)
cam.SetPosition(0,0,0)
ren0.ResetCamera()
ren1.SetActiveCamera(cam)
iren.Initialize()
# render the image
#
renWin.Render()
#iren.Start()
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Interpolate onto a volume
# Parameters for debugging
NPts = 1000000
binNum = 16
math = vtk.vtkMath()
math.RandomSeed(31415)
# create pipeline
#
points = vtk.vtkBoundedPointSource()
points.SetNumberOfPoints(NPts)
points.ProduceRandomScalarsOn()
points.ProduceCellOutputOff()
points.Update()
# Bin the points
hBin = vtk.vtkHierarchicalBinningFilter()
hBin.SetInputConnection(points.GetOutputPort())
#hBin.AutomaticOn()
hBin.AutomaticOff()
hBin.SetDivisions(2,2,2)
hBin.SetBounds(points.GetOutput().GetBounds())
# Time execution
timer = vtk.vtkTimerLog()
timer.StartTimer()
hBin.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Points processed: {0}".format(NPts))
print(" Time to bin: {0}".format(time))
#print(hBin)
#print(hBin.GetOutput())
# write stuff out
w = vtk.vtkXMLPolyDataWriter()
w.SetFileName("binPoints.vtp")
w.SetInputConnection(hBin.GetOutputPort())
#w.SetDataModeToAscii()
#w.Write()
# Output a selected bin of points
extBin = vtk.vtkExtractHierarchicalBins()
extBin.SetInputConnection(hBin.GetOutputPort())
extBin.SetBinningFilter(hBin)
#extBin.SetLevel(0)
extBin.SetLevel(-1)
extBin.SetBin(binNum)
subMapper = vtk.vtkPointGaussianMapper()
subMapper.SetInputConnection(extBin.GetOutputPort())
subMapper.EmissiveOff()
subMapper.SetScaleFactor(0.0)
subActor = vtk.vtkActor()
subActor.SetMapper(subMapper)
# Create an outline
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(points.GetOutputPort())
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# Create another outline
bds = [0,0,0,0,0,0]
hBin.GetBinBounds(binNum,bds)
binOutline = vtk.vtkOutlineSource()
binOutline.SetBounds(bds)
binOutlineMapper = vtk.vtkPolyDataMapper()
binOutlineMapper.SetInputConnection(binOutline.GetOutputPort())
binOutlineActor = vtk.vtkActor()
binOutlineActor.SetMapper(binOutlineMapper)
# Create the RenderWindow, Renderer and both Actors
#
ren0 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren0.AddActor(subActor)
ren0.AddActor(outlineActor)
ren0.AddActor(binOutlineActor)
ren0.SetBackground(0.1, 0.2, 0.4)
renWin.SetSize(250,250)
cam = ren0.GetActiveCamera()
cam.SetFocalPoint(1,1,1)
cam.SetPosition(0,0,0)
ren0.ResetCamera()
iren.Initialize()
# render the image
#
renWin.Render()
#iren.Start()
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# create pipeline
#