[vtkusers] Strucutred Grid and blanking

da xu remywendy at gmail.com
Mon Aug 3 13:45:27 EDT 2009


Hey Lorenzo,
http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Graphics/Testing/Tcl/blankGrid.tcl?root=VTK&content-type=text/plain
might
help.


On Sun, Aug 2, 2009 at 2:24 PM, Lorenzo Bernardi <
lorenzo.bernardi at lpn.cnrs.fr> wrote:

> Dear all,
>
>  I'd like to blank sites from a structure grid and use warpscalar. I'm
> using the BlankPoint method of the vtkStructuredGrid class but it doesn't
> work. I'm missing something obvious?
>
> My use of blanking on the structured grid is to represent the data on the
> Cubic centered lattice. Is blanking made for this kind of things?
>
>  Does someone have and example of how to use vtkBlankStructuredGrid with a
> StructuredGrid object?
>
> my code is given below. If I comment the blanking part I have a plane
> otherwise I have nothing
>
> sincerely
>
> L.
>
>
>
>
>
> #!/usr/bin/python
>
> import vtk
> import math
>
>
> Vpoints=vtk.vtkPoints()
> Vdata=vtk.vtkFloatArray()
> Vblank=vtk.vtkUnsignedCharArray()
>
>
> imax=10
> jmax=10
> kmax=10
>
> Vsg=vtk.vtkStructuredGrid()
> Vsg.SetDimensions(imax,jmax,kmax)
>
> l=0
> for k in range(kmax):
>   for j in range(jmax):
>       for i in range(imax):
>           if (i+j+k)%2 == 1:
>               Vsg.BlankPoint(l)
>
>           Vpoints.InsertPoint(l,i,j,k)
>           Vdata.InsertValue(l,2.+math.cos(i)*math.cos(j)*math.cos(k))
>
>           l+=1
>
> Vsg.SetPoints(Vpoints)
> Vsg.GetPointData().SetScalars(Vdata)
>
>
> plane = vtk.vtkStructuredGridGeometryFilter()
> plane.SetInputConnection(Vsg.GetProducerPort())
> plane.SetExtent(0, 40, 0, 40, 1, 1)
>
>
> warp = vtk.vtkWarpScalar()
> warp.SetInputConnection(plane.GetOutputPort())
> warp.UseNormalOn()
> warp.SetNormal(.0, 0.0, 1.0)
> warp.SetScaleFactor(2.5)
>
> normals = vtk.vtkPolyDataNormals()
> normals.SetInput(warp.GetPolyDataOutput())
> normals.SetFeatureAngle(60)
>
> planeMapper = vtk.vtkPolyDataMapper()
> planeMapper.SetInputConnection(normals.GetOutputPort())
> planeMapper.SetScalarRange(Vsg.GetScalarRange())
>
> planeActor = vtk.vtkActor()
> planeActor.SetMapper(planeMapper)
>
> outline = vtk.vtkStructuredGridOutlineFilter()
> outline.SetInputConnection(Vsg.GetProducerPort())
> outlineMapper = vtk.vtkPolyDataMapper()
> outlineMapper.SetInputConnection(outline.GetOutputPort())
> outlineActor = vtk.vtkActor()
> outlineActor.SetMapper(outlineMapper)
> outlineActor.GetProperty().SetColor(0, 0, 0)
>
>
> ren = vtk.vtkRenderer()
> ren.AddActor(outlineActor)
> ren.AddActor(planeActor)
>
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren)
> ren.SetBackground(1, 1, 1)
>
>
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> iren.Initialize()
> renWin.Render()
> iren.Start()
>
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090803/55465127/attachment.htm>


More information about the vtkusers mailing list