<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;color:rgb(0,0,0)">Thanks a lot David for your directions.</div><div class="gmail_default" style="font-family:verdana,sans-serif;color:rgb(0,0,0)">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;color:rgb(0,0,0)">I managed to accomplish what you said by doing:</div><div class="gmail_default" style="font-family:verdana,sans-serif;color:rgb(0,0,0)">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;color:rgb(0,0,0)">>> zbuff_str = visPts.Initialize(True)</div><div class="gmail_default" style="font-family:verdana,sans-serif;color:rgb(0,0,0)">
<div class="gmail_default">>> address = int(zbuff_str[1:17], 16)</div><div class="gmail_default">>> w, h = renderWin.GetSize()</div><div class="gmail_default">>> size = w*h</div><div class="gmail_default">
>> FLOATP = ctypes.c_float * size</div><div class="gmail_default">>> zbuff_buff = FLOATP.from_address(address)</div><div class="gmail_default">>> # will do a copy here, `np.frombuffer(zbuff_buff)' would be more adequat</div>
<div class="gmail_default">>> zbuff = np.fromiter(zbuff_buff, dtype=np.float, count=size)</div><div class="gmail_default">>> ...</div><div class="gmail_default">>> visPts.IsPointOccluded(point, zbuff)</div>
<div class="gmail_default"><br></div><div class="gmail_default">By using numpy.frombuffer I get a crash in `IsPointOccluded'. I didn't get deeper into why this would happen, but this is ok for my use to copy the whole thing.</div>
<div class="gmail_default"><br></div><div class="gmail_default">It is a simple prototype so I don't mind the leak for now :)</div><div class="gmail_default"><br></div><div class="gmail_default">Thanks again,</div><div class="gmail_default">
<br></div><div class="gmail_default">Guillaume</div><div class="gmail_default"><br></div><div class="gmail_default"><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 9, 2014 at 1:03 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Guillaume,<br>
<br>
I'm surprised that the "float *Initialize()" method is even wrapped.<br>
Generally, such methods only return a "_xxxx_void_p" string if<br>
they return "void *".<br>
<br>
Anyway, in VTK 6.2, the IsPointOccluded() method is wrapped and<br>
you will be able to call it after you turn the "zBuffer" into a python<br>
container of some sort.  I'd recommend using a numpy array as the<br>
container for the sake of efficiency.<br>
<br>
So, what you will have to do is find a way of creating a numpy float<br>
array from the hexadecimal address in the string.  I have no idea<br>
how to do it, but I'm sure there is a way.<br>
<br>
Note, however, that the docs for vtkSelectVisiblePoints::Initialize()<br>
say that it returns a new pointer that must be deleted.  In other words,<br>
you will also have to find some way of deleting the pointer from<br>
Python or else you will end up with a memory leak.<br>
<span class="HOEnZb"><font color="#888888"><br>
  - David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Wed, Jul 9, 2014 at 10:19 AM, Guillaume Dumont <<a href="mailto:rippalka@gmail.com">rippalka@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> I am having a little issue concerning a function in Python that returns what<br>
> seems like a pointer as a string.<br>
><br>
>>> visPts = vtk.vtkSelectVisiblePoints()<br>
>>> visPts.SetInputData(polyData)<br>
>>> visPts.SetRenderer(ren)<br>
>>> zbuff = visPts.Initialize(True)<br>
>>> print zbuff<br>
>>> print type(zbuff)<br>
><br>
> and it prints:<br>
> _000000000dc90040_void_p<br>
> <type 'str'><br>
><br>
> I understand that `vtkSelectVisiblePoints::vtInitialize(bool)' returns a raw<br>
> pointer (float*) which I believe cannot directly be exposed to Python, but<br>
> is there a way to pass it to `vtkSelectVisiblePoints::IsPointOccluded(const<br>
> double[3], connst float* zBuffer)' in Python somehow? Or is it just a<br>
> limitation of the Python interface?<br>
><br>
> Thanks a lot for your help!<br>
><br>
> Guillaume<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><span style="border-collapse:collapse"><span style="font-size:10pt;font-family:'Trebuchet MS';color:rgb(51,51,51);background-color:transparent;font-weight:normal;font-style:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Guillaume Dumont</span><br>
<span style="font-size:10pt;font-family:'Trebuchet MS';color:rgb(51,51,51);background-color:transparent;font-weight:normal;font-style:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Kremlin-Bicêtre, France</span><br>
<span style="font-size:10pt;font-family:'Trebuchet MS';color:rgb(51,51,51);background-color:transparent;font-weight:normal;font-style:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Email: </span><span style="font-size:10pt;font-family:'Trebuchet MS';color:rgb(0,0,204);background-color:transparent;font-weight:normal;font-style:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><a href="mailto:me@guillaumedumont.com" style="color:rgb(0,0,204)" target="_blank">me@guillaumedumont.com</a></span><br>
<span style="font-size:10pt;font-family:'Trebuchet MS';color:rgb(51,51,51);background-color:transparent;font-weight:normal;font-style:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">EPITA SCIA 2013</span></span></div>

</div>