[vtkusers] cutting a 4D set of points

John Biddiscombe biddisco at cscs.ch
Fri Jul 31 03:31:15 EDT 2009


Lorenzo

If you have a look at pv-meshless
https://twiki.cscs.ch/twiki/bin/view/ParaViewMeshless
you'll see there are a number of custom filters which are intended to 
operate on point based data.
The web page descriptions are a little out of date, and you should have 
a look at the "SPHERIC 2009 Tutorial Material" on the page - in 
particular a powerpoint presentation located here 
https://twiki.cscs.ch/twiki/pub/ParaViewMeshless/WebHome/pv-meshless-particle-data.ppt

I am very busy at the moment and so cannot answer any questions for the 
time being, but hidden amongst the SPH interpolation routines is a 
shepard method interpolation, which uses only the distances and does not 
use SPH kernels. If you want simple interpolation between points - this 
is the one. (Custom probe/mesh/meshless filter).

If you try the filters and have problems, please ask, but be patient 
waiting for answers.

JB

> Dear All,
>
>   I have a 4D set of points (3 space coordinates x,y,z and a value k ) 
> which are unstructured that is I just have the position and not the 
> connectivity.  I would like to represent 2D cuts of this set. This 2D 
> cut should be represented as 3d plot or maybe as a contour plot.
>
> I managed to see something with ContourFilter and ProbeFilter but it 
> looks that there is no interpolation between points. I mean the value 
> seems to exist only a the defined points and is zero everywhere else.
>
> Can someone explain me how to make a 3d plot of a cut with an 
> interpolation between points or using vtkPolyData is not a good choice.
>
> Or if someone has a piece of code for visualizing a 4D cloud of points 
> I'll be interested in since I'm not sure cut is the best way to 
> visualize the data. The value at each point  is the wavefunction.
>
> Thanks in advance
>
> L.
>
> an example code greatly inspired by probecomp.py.
>
> #!/usr/bin/python
> # visualization of field described by a cloud of points
>
> import vtk
> import math
>
> #creating the set of points (they are regular but I create it just as
> # a set of points) and the value associated with
>
> Vpoints=vtk.vtkPoints()
> Vcell=vtk.vtkCellArray()
>
> Vvalue=vtk.vtkDoubleArray()
> Vvalue.SetName("values")
>
> index=0
> for i in range(10):
>    for j in range(10):
>        for k in range(10):
>            Vpoints.InsertPoint(index,i,j,k)
>            Vvalue.InsertNextValue(math.cos(i)*math.cos(j)*math.cos(k))
>            Vcell.InsertNextCell(1)
>            Vcell.InsertCellPoint(index)
>            index+=1
>          Vpolydata=vtk.vtkPolyData()
> Vpolydata.SetPoints(Vpoints)
> Vpolydata.SetVerts(Vcell)
> Vpolydata.GetPointData().SetScalars(Vvalue)
>
> print "Scalar Range: ",Vpolydata.GetScalarRange()
> print "Bounds: ",Vpolydata.GetBounds()
>
> # first visualisation of the points
> Vmapper = vtk.vtkPolyDataMapper()
> Vmapper.SetInput(Vpolydata)
> Vmapper.SetScalarRange(-0.5, 1)
>
> # Create an actor.
> Vactor = vtk.vtkActor()
> Vactor.SetMapper(Vmapper)
>
>
> # creating the plane for the cut
> plane = vtk.vtkPlaneSource()
> plane.SetResolution(50, 50)
>
> transP1 = vtk.vtkTransform()
> transP1.Translate(5., 5.0, 5.0)
> transP1.Scale(5, 5, 5)
> transP1.RotateY(90)
>
> tpd1 = vtk.vtkTransformPolyDataFilter()
> tpd1.SetInputConnection(plane.GetOutputPort())
> tpd1.SetTransform(transP1)
>
> outTpd1 = vtk.vtkOutlineFilter()
> outTpd1.SetInputConnection(tpd1.GetOutputPort())
>
> mapTpd1 = vtk.vtkPolyDataMapper()
> mapTpd1.SetInputConnection(outTpd1.GetOutputPort())
>
> tpd1Actor = vtk.vtkActor()
> tpd1Actor.SetMapper(mapTpd1)
> tpd1Actor.GetProperty().SetColor(0, 0, 0)
>
> probe = vtk.vtkProbeFilter()
> probe.SetInputConnection(tpd1.GetOutputPort())
> probe.SetSource(Vpolydata)
>
> contour = vtk.vtkContourFilter()
> contour.SetInputConnection(probe.GetOutputPort())
> contour.GenerateValues(50, Vpolydata.GetScalarRange())
>
> contourMapper = vtk.vtkPolyDataMapper()
> contourMapper.SetInputConnection(contour.GetOutputPort())
> contourMapper.SetScalarRange(Vpolydata.GetScalarRange())
>
> planeActor = vtk.vtkActor()
> planeActor.SetMapper(contourMapper)
>
> # Create the rendering objects.
> ren = vtk.vtkRenderer()
> ren.AddActor(Vactor)
> ren.AddActor(tpd1Actor)
> ren.AddActor(planeActor)
>
> ren.SetBackground(1, 1, 1)
>
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren)
>
> 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


-- 
John Biddiscombe,                            email:biddisco @ cscs.ch
http://www.cscs.ch/
CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82




More information about the vtkusers mailing list