<DIV>I don't think you need any cast if instead of returning a vtkUnstructuredGrid * in your C++ code you return the PyObject * returned by vtkPythonGetObjectFromPointer( your_vtkUnstructuredGrid * ).<BR>Example :</DIV>
<DIV>C++ :</DIV>
<DIV> </DIV>
<DIV>#include <vtkPythonUtil.h><BR>PyObject * GetSubMesh( const int number = 1)<BR>{<BR> vtkUnstructuredGrid * grid = vtkUnstructuredGrid::New();<BR>// fill it<BR> return vtkPythonGetObjectFromPointer( grid );<BR>}</DIV>
<DIV> </DIV>
<DIV>SWIG Interface :</DIV>
<DIV><BR>PyObject * GetSubMesh( const int number = 1);</DIV>
<DIV> </DIV>
<DIV>Python :</DIV>
<DIV><BR>mygrid = GetSubMesh(2)mymapper = vtk.vtkDataSetMapper()mymapper.SetInput(mygrid)<BR></DIV>
<DIV>Aurélien<BR><BR><B><I>Mark Asbach <mark.asbach@post.rwth-aachen.de></I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi Ross,<BR><BR>> I have a set of C codes that manipulate a data structure, one<BR>> component of which is an array of doubles. I've managed to<BR>> wrap the C codes with SWIG so I have access to the structure<BR>> with the typical SWIG accessor functions, i.e. Sp4Array_data_get()<BR>> What do I have to do to get this data array into vtk?<BR><BR>The way I took for my code is to just write the conversion to vtk data <BR>structures in C, wrap them with SWIG and mix that with the vtk python <BR>stuff. There is a bug in the current SWIG adaptor code of VTK though, <BR>and I don't know, if David committed my fix to the repository already <BR>(David?).<BR><BR>Here it just looks like:<BR><BR>In C header and SWIG interface description.<BR>vtkUnstructuredGrid * GetSubMesh (const int <BR>number = 1);<BR><BR>Usage in Python:<BR>import vtk<BR>import
myStuff<BR><BR>mygrid=vtk.vtkUnstructuredGrid( GetSubMesh (2))<BR>mymapper=vtk.vtkDataSetMapper()<BR>mymapper.SetInput (mygrid)<BR><BR><BR>So you'll have to "cast" the SWIG returned data to the vtk data type. <BR>The other way 'round you can take the .__this__ member of any vtk data <BR>structure as a fully functional SWIG pointer.<BR><BR>Please remember that you'll need the SWIG fix applied on the vtk <BR>sources to have that working. Currently the SWIG mangling handles <BR>endianness differently than vtk's emulation of it.<BR><BR>Yours, Mark<BR><BR><BR>_______________________________________________<BR>This is the private VTK discussion list. <BR>Please keep messages on-topic. Check the FAQ at: <HTTP: vtkfaq cgi-bin public.kitware.com><BR>Follow this link to subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers</BLOCKQUOTE><p><br><hr size=1><font face=arial size=-1>Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<br>
<a href=http://fr.mail.yahoo.com>Testez le nouveau Yahoo! Mail</a></font>