[Paraview] Python scripting/Grid geometry transformation

Nikolaos Beratlis nikos.beratlis at gmail.com
Tue Apr 2 22:55:24 EDT 2013


Hi,

I am reading the following xmf file (attached as var3d.xmf) into Paraview:

<?xml version="1.0" ?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
<Xdmf Version="2.2">
<Domain>
<Grid GridType="Uniform">
<Topology TopologyType="3DRectMesh" Dimensions="     2     4     3"/>
<Geometry GeometryType="VXVYVZ">
<DataItem Dimensions="    3" NumberType="Float" Precision="4" Format="XML">
   0.0000   1.0000   2.0000
</DataItem>
<DataItem Dimensions="    4" NumberType="Float" Precision="4" Format="XML">
   0.0000   2.0944   4.1888   6.2832
</DataItem>
<DataItem Dimensions="    2" NumberType="Float" Precision="4" Format="XML">
   1.0000   2.0000
</DataItem>
</Geometry>
<Attribute Name="var" AttributeType="Scalar" Center="Node">
<DataItem Dimensions="24" NumberType="Float" Precision="4" Format="XML">
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
</DataItem>
</Attribute>
</Grid>
</Domain>
</Xdmf>

The grid is a 3D orthogonal grid read in cartesian coordinates (see
attached image showing grid and contours of variable). I then want to
transform the grid from cartesian to cylindrical coordinates. I tried using
the following Python script:

pdi = self.GetPolyDataInput()

pdo = self.GetPolyDataOutput()

newPoints = vtk.vtkPoints()

numPoints = pdi.GetNumberOfPoints()

for i in range(0, numPoints):

coord = pdi.GetPoint(i)

x, y, z = coord[:3]

r = x * sin(y)

t = x * cos(y)

newPoints.InsertPoint(i, r, t, z)

pdo.SetPoints(newPoints)


with Output Data Set Type chosen to be the Same as Input, but I get this
error:


Traceback (most recent call last):
File "<string>", line 26, in <module>
File "<string>", line 12, in RequestData
AttributeError: 'NoneType' object has no attribute 'SetPoints'

I have no experience with Python scripting. What am I doing wrong?

Thank you,

Nikos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20130402/3359cc4a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grid_var_contours.png
Type: image/png
Size: 20382 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20130402/3359cc4a/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: var3d.xmf
Type: application/octet-stream
Size: 824 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20130402/3359cc4a/attachment-0001.obj>


More information about the ParaView mailing list