<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I've been thinking about how to make the vtk python binding more pythonesque? Here are a couple of examples and what I have in mind: <br>
<p>
Current syntax:
</p>
<div class="">
<pre class=""><span style="color:rgb(178,34,34)"># </span><span style="color:rgb(178,34,34)">poly is vtkPolyLine</span>
num_points = poly.GetNumberOfPoints()
pts = c.GetPoints()
<span style="color:rgb(160,32,240)">for</span> i <span style="color:rgb(160,32,240)">in</span> <span style="color:rgb(160,32,240)">range</span>(num_points):
p = pts.GetPoint(i)
foo(p)
</pre>
</div>
<p>
New syntax:
</p>
<div class="">
<pre class=""><span style="color:rgb(160,32,240)">for</span> p <span style="color:rgb(160,32,240)">in</span> poly:
foo(p)
</pre>
</div>
<p>
Needed change:
</p>
<ul class=""><li>For all vtk array like objects, support python sequence iterator API <code>tp_iter</code> and <code>tp_iternext</code>.
</li></ul>
<p>
Current syntax:
</p>
<div class="">
<pre class="">pts = c.GetPoints()
p1 = pts.GetPoint(0)
p2 = pts.GetPoint(1)
p3 = pts.GetPoint(2)
norm = [0,0,0]
vtk.vtkTriangle.ComputeNormalDirection(p1,p2,p3,norm)
</pre>
</div>
<p>
New syntax:
</p>
<div class="">
<pre class="">norm = vtk.vtkTriangle.ComputeNormalDirection(c.GetPoints()[0:3])
</pre>
</div>
<p>
Needed change:
</p>
<ul class=""><li>Support sequence methods <code>sq_length</code>, <code>sq_concat</code>, <code>sq_item</code>, <code>sq_slice</code>,
</li><li>For all methods returning values, if the arguments only contain the
number of input parameters, return the result in a python tuple.
</li></ul>Please let me know if you would accept patches for implementing the above behavior. <br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I would also appreciate a description of the mechanism for the autogeneration of the python binding. I assume that VTK/Wrapping/Tools/vtkWrapPython.c is used. (Btw, why is it written in c and not in C++ (or even python)?)<br>
<br>And finally, what is the proper way of submit patches? Is a pull request on github accepted?<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Regards,<br>Dov<br></div><div style id="divCleekiAttrib">
</div><div style id="divCleekiAttrib"></div></div>