# 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.0, 0.1, 0.2) sphere.SetRadius(0.75) # Extract points within sphere extract = vtk.vtkFitImplicitFunction() extract.SetInputConnection(points.GetOutputPort()) extract.SetImplicitFunction(sphere) extract.SetThreshold(0.005) extract.GenerateVerticesOn() # Clip out some of the points with a plane; requires vertices plane = vtk.vtkPlane() plane.SetOrigin(sphere.GetCenter()) plane.SetNormal(1, 1, 1) clipper = vtk.vtkClipPolyData() clipper.SetInputConnection(extract.GetOutputPort()) clipper.SetClipFunction(plane) # Generate density field from points
# 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,0,0) sphere.SetRadius(0.75) # Extract points along sphere surface extract = vtk.vtkFitImplicitFunction() extract.SetInputConnection(points.GetOutputPort()) extract.SetImplicitFunction(sphere) extract.SetThreshold(0.005) extract.Update() # Now generate normals from resulting points norms = vtk.vtkPCANormalEstimation() norms.SetInputConnection(extract.GetOutputPort()) norms.SetSampleSize(20) norms.FlipNormalsOn() norms.SetNormalOrientationToPoint() norms.SetOrientationPoint(0,0,0) # Time execution timer = vtk.vtkTimerLog()