[vtkusers] Re: ValueError: method requires a VTK object
Lise Angell
lise.angell at gmail.com
Wed Oct 19 05:01:13 EDT 2005
Seems like the error was correct after all (surprise...), I didn't
send a VTK object to the InsertNextCell-method.
Now I would like to use
vtkUnstructuredGrid::InsertNextCell( int type,vtkIdType npts,vtkIdType
*pts), not vtkUnstructuredGrid::InsertNextCell( int type,vtkIdList *
ptIds).
But then I get the error:
File "readxdr.py", line 456, in mount_vtk_structures
vtk_u_grid.InsertNextCell(vtk_cell_type, npt, pt_list)
TypeError: function takes exactly 2 arguments (3 given)
vtk_cell_type: int, npt: int, pt_list: list of ints
Any ideas how I can reach this method (assuming it's not deprecated)?
Lise
---------- Forwarded message ----------
From: Lise Angell <lise.angell at gmail.com>
Date: Oct 18, 2005 2:29 PM
Subject: ValueError: method requires a VTK object
To: vtkusers at vtk.org
I'm building a vtkUnstructuredGrid from values read from a binary file.
When I want to insert info about the element topology in the grid, I
get the following error:
Traceback (most recent call last):
File "readxdr.py", line 606, in ?
u_grid = mount_vtk_structures(grid, fields)
File "readxdr.py", line 462, in mount_vtk_structures
vtk_u_grid.InsertNextCell(vtk_cell_type, pt_list)
ValueError: method requires a VTK object
I have read the vtk-list postings concerning this (and the FAQ), but I
don't have two conflicting vtk versions, so I don't see why I should
get this error...
I'm running python2.3 (got some problems compiling VTK with python2.4
because of gcc4.0 on Tiger) and VTK from CVS (from Oct.11 2005) on OSX
Tiger (iBookG4).
Hope someone can help me...
Regards,
Lise
Code snippet:
#------------------------------------------------------------------------------------------------------
nsd = grid.nsd; nno = grid.nno; nel = grid.nel # grid: GridFE class
# allocate VTK structures
vtk_u_grid = vtk.vtkUnstructuredGrid()
pts = vtk.vtkPoints()
pts.SetNumberOfPoints(nno)
data = vtk.vtkDoubleArray()
data.SetNumberOfValues(nno)
for i in range (0,nno):
x = grid.coords[i]
s = [... get value from file...]
data.SetValue(i,s) # put
field value in VTK object
pts.SetPoint(i,x) # put
points in VTK object
vtk_u_grid.Allocate(nel, 0)
vtk_u_grid.SetPoints(pts)
vtk_u_grid.GetPointData().SetScalars(data)
# tell the VTK grid structure about the element topology
for e in range (1, nel):
< getting cell type (int) and point list (array of ints)>
vtk_u_grid.InsertNextCell(vtk_cell_type, pt_list)
#------------------------------------------------------------------------------------------------------
--
"Je forme une entreprise qui n'eut jamais d'exemple,
et dont l'exécution n'aura point d'imitateur." J-J Rousseau
More information about the vtkusers
mailing list