<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Jean,<br>
<br>
I tried your code and I got the following error: <br>
<br>
<tt>Traceback (most recent call last):</tt><tt><br>
</tt><tt> File "<string>", line 19, in <module></tt><tt><br>
</tt><tt> File "<string>", line 18, in RequestData</tt><tt><br>
</tt><tt>AttributeError: can't set attribute</tt><br>
<br>
Here's my source code:<br>
<br>
<tt>from struct import unpack_from</tt><tt><br>
</tt><tt>from os import stat</tt><tt><br>
</tt><tt>import numpy as np</tt><tt><br>
</tt><tt><br>
</tt><tt>def load_velodyne_points(filename):</tt><tt><br>
</tt><tt> num_points = stat(filename).st_size/16</tt><tt><br>
</tt><tt> points = np.zeros((4, num_points))</tt><tt><br>
</tt><tt> with open(filename, "rb") as f:</tt><tt><br>
</tt><tt> # Read all points, convert to floats and assign to
</tt><tt><br>
</tt><tt> # a column-wise flat view of points</tt><tt><br>
</tt><tt> points.T.flat[:] = unpack_from('f'*num_points,
f.read())</tt><tt><br>
</tt><tt> return points</tt><tt><br>
</tt><tt><br>
</tt><tt>filename = "worked.bin"</tt><tt><br>
</tt><tt>points = load_velodyne_points(filename)</tt><tt><br>
</tt><tt>N = points.shape[1] </tt><tt><br>
</tt><tt>output.Points = points[0:3,].reshape(N, 3)</tt><tt><br>
</tt><tt>output.PointData.append(points[3,], "reflectance")</tt><tt><br>
</tt><br>
<br>
Which version of paraview are you using? I'm using the 4.0.1 64bit
installed from apt-get on Ubuntu 14.04.4 LTS.<br>
<br>
Ellon<br>
<br>
<div class="moz-cite-prefix">On 04/22/2016 04:15 PM, Favre Jean
wrote:<br>
</div>
<blockquote
cite="mid:0EB9B6375711A04B820E6B6F5CCA9F68435E36E4@MBX211.d.ethz.ch"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
<div style="direction: ltr;font-family: Tahoma;color:
#000000;font-size: 10pt;"><br>
my suggestion would be to use some more numpy-oriented features.
Your "points" array is already a numpy array, you can feed it to
the vtkPolyData with a simple reshaping. Same for your
reflectance array. No need for a for-loop<br>
<div><br>
I'd replace your code with this:<br>
<br>
filename = "worked.bin"<br>
<br>
points = load_velodyne_points(filename)<br>
N=points.shape[1]<br>
# use "output" as the pre-defined vtkPolyData object<br>
output.Points = points[0:3,].reshape(N, 3)<br>
output.PointData.append(points[3,], "reflectance")<br>
<div class="BodyFragment"><font size="2"><span
style="font-size:10pt;">
<div class="PlainText"><br>
I usually skip building up cells, because I use a
PointGaussian representation mode. But your needs
might differ. Anyway, with the changes above, I can
read all 3 files without any problem.<br>
<br>
-----------------<br>
Jean<br>
</div>
</span></font></div>
</div>
</div>
</blockquote>
<br>
</body>
</html>