[vtkusers] vtkCutter and vtkImplicitDataSet combined

Stein Erik Berthelsen zebern at hotmail.com
Sat Dec 19 17:09:57 EST 2009


The idea is the cut through a StructuredGrid with a curved surface (a surface interactively defined by the user).The curved surface will be vertical so it will look like a curvy carpet.
Working with vtkCutter and vtkImplicitDataSet. In theory it should work, but I cannot get it going!!! Unfortunately.I am able to create a cut surface using a vtkPlane or a vtkSphere as the ImplicitFunction cutFunction, but using vtkImplicitDataSet as the ImplicitFunction is playing games with me...
Rgds Stein Erik----------------------------------------------------------Parts os the code (Python):# Create Grid to be cutgridSource = vtk.vtkStructuredGrid()gridSource.SetDimensions(11,11,11)gridSource.SetPoints(points)gridSource.GetCellData().SetScalars(cells)gridSource.GetPointData().SetScalars(pointScalars)
gridMapper = vtk.vtkDataSetMapper()gridMapper.SetInput(gridSource)gridMapper.ScalarVisibilityOn()#gridMapper.SetScalarModeToUseCellData()gridMapper.SetScalarModeToUsePointData()
gridActor = vtk.vtkActor()gridActor.SetMapper(gridMapper)gridActor.GetProperty().SetColor(1.0, 1.0, 1.0)gridActor.GetProperty().SetRepresentationToWireframe()#gridActor.GetProperty().SetRepresentationToSurface()
# Create Cutting SurfacesgReader = vtk.vtkStructuredGridReader()sgReader.SetFileName("StructuredGrid_Test.vtk")sgReader.Update()
gridextractFilter = vtk.vtkStructuredGridGeometryFilter()gridextractFilter.SetInputConnection(sgReader.GetOutputPort())gridextractFilter.SetExtent(0,19,0,2,0,0)gridextractFilter.Update()
gridextractNormalsFilter = vtk.vtkPolyDataNormals()gridextractNormalsFilter.SetInputConnection(gridextractFilter.GetOutputPort())gridextractNormalsFilter.Update()
cutTriangles = vtk.vtkTriangleFilter()cutTriangles.SetInputConnection(gridextractNormalsFilter.GetOutputPort())
implicitFunc = vtk.vtkImplicitDataSet()implicitFunc.SetDataSet(gridextractNormalsFilter.GetOutput())
# Create Cuttercutter = vtk.vtkCutter()cutter.SetCutFunction(implicitFunc)cutter.SetInput(gridSource)
cutterMapper=vtk.vtkPolyDataMapper()cutterMapper.SetInputConnection(cutter.GetOutputPort())
cutterActor = vtk.vtkActor()cutterActor.SetMapper(cutterMapper)cutterActor.GetProperty().SetColor(1.0, 0.0, 1.0)#cutterActor.GetProperty().SetRepresentationToSurface()cutterActor.GetProperty().SetRepresentationToWireframe()
# Create the usual rendering stuffren = vtk.vtkRenderer()renWin = vtk.vtkRenderWindow()renWin.AddRenderer(ren)iren = vtk.vtkRenderWindowInteractor()iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and sizeren.AddActor(gridActor)ren.AddActor(cutterActor)renWin.SetSize(500, 500)iren.Initialize()renWin.Render()iren.Start()
 		 	   		  
_________________________________________________________________
Windows Live: Make it easier for your friends to see what you’re up to on Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091219/9f55c579/attachment.htm>


More information about the vtkusers mailing list