<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Cory,<br>
<br>
Thank you for the answer. Yes, I know that vtk is coded in C++ and
that python-vtk is only a binding. I thought that maybe there was a
way to avoid some of the expensive calls. For example, I have this
loop in a cython file:<br>
<br>
<tt><big># streamline is a ndarray of 3d points<br>
for i in range(nb_points):<br>
point_3d = streamline[i]<br>
vtk_points.InsertNextPoint</big></tt><tt>(<big>point_3d</big>)</tt><br>
<br>
I know that InsertNextPoint is as fast as it can be, but the call
itself is expensive. As you said, there's probably nothing to be
done here using cython.<br>
<br>
Which bring me to another question! As I said above, I have a 2D
ndarray (list of 3d points) that I need to put in a vtkPoints
object. I think it's a waste of time to copy the data in a loop
because both vtk and numpy represent their data the same way and
should be able to read the data of the other library.<br>
<br>
I found the "VTK - numpy integration" posts this morning
<a class="moz-txt-link-freetext" href="http://www.kitware.com/blog/home/post/709">http://www.kitware.com/blog/home/post/709</a> and I thought that maybe
there a way to create a vtkPoints from a numpy array without a loop.
I couldn't find how to do it though. It seems we can only create
vtkDataSets and put them in bbtk objects. Do you know if what I want
to do is possible?<br>
<br>
Nil<br>
<br>
<div class="moz-cite-prefix">Le 2016-01-16 07:59, Cory Quammen a
écrit :<br>
</div>
<blockquote
cite="mid:CAB5Fpx4wnu9jW076Bo0N5hw4CSOn7h+N0FqMya_MiJP8y1WrRQ@mail.gmail.com"
type="cite">
<pre wrap="">Nil,
VTK is C++ library that provides Python language bindings, so all the
VTK parts you call in your Python code are invoking compiled C++
functions. There is no need to cythonize them.
Cory
On Fri, Jan 15, 2016 at 11:30 AM, Nil Goyette <a class="moz-txt-link-rfc2396E" href="mailto:nil.goyette@imeka.ca"><nil.goyette@imeka.ca></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,
I tried making a part of my pytthon code faster and vtk is the only part
which I can't change anything. In fact, I can't find any information on
cythonizing vtk. Maybe because one should use C++ if he wants a fast version
:) or maybe because there's simply not much information on the subject.
Is there some specific advices to vtk? Where to find the cdef?
Or it's simply the general advices like: get a pointer to the data asap to
be in C mode, then cdef everything?
Nil
</pre>
</blockquote>
</blockquote>
</body>
</html>