Пример #1
0
bounds = output.GetBounds()
length = output.GetLength()

plane = vtk.vtkPlaneSource()
plane.SetResolution(res,res)
plane.SetOrigin(bounds[0],bounds[2],bounds[4])
plane.SetPoint1(bounds[1],bounds[2],bounds[4])
plane.SetPoint2(bounds[0],bounds[3],bounds[4])
plane.SetCenter(center)
plane.SetNormal(0,0,1)
plane.Update()

timer = vtk.vtkTimerLog()

# SPH kernel------------------------------------------------
sphKernel = vtk.vtkSPHQuinticKernel()
sphKernel.SetSpatialStep(0.00002)
sphKernel.SetDimension(2)

interpolator = vtk.vtkSPHInterpolator()
interpolator.SetInputConnection(plane.GetOutputPort())
interpolator.SetSourceConnection(reader.GetOutputPort())
interpolator.SetKernel(sphKernel)
interpolator.Update()

# Time execution
timer.StartTimer()
interpolator.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Interpolate Points (SPH): {0}".format(time))
bounds = output.GetBounds()
length = output.GetLength()

plane = vtk.vtkPlaneSource()
plane.SetResolution(res, res)
plane.SetOrigin(bounds[0], bounds[2], bounds[4])
plane.SetPoint1(bounds[1], bounds[2], bounds[4])
plane.SetPoint2(bounds[0], bounds[3], bounds[4])
plane.SetCenter(center)
plane.SetNormal(0, 0, 1)
plane.Update()

timer = vtk.vtkTimerLog()

# SPH kernel------------------------------------------------
sphKernel = vtk.vtkSPHQuinticKernel()
sphKernel.SetSpatialStep(0.00002)
sphKernel.SetDimension(2)

interpolator = vtk.vtkSPHInterpolator()
interpolator.SetInputConnection(plane.GetOutputPort())
interpolator.SetSourceConnection(reader.GetOutputPort())
interpolator.SetKernel(sphKernel)
interpolator.Update()

# Time execution
timer.StartTimer()
interpolator.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Interpolate Points (SPH): {0}".format(time))