<div dir="ltr"><div><div>Thanks.<br><br></div>The thing is I have a composite dataset, the commands above i guess work only for &quot;simple dataset&quot;<br><br></div>So I found that these commands for for a composite dataset and they make a copy of input. <br>
<br><b>from paraview.vtk.dataset_adapter import numpyTovtkDataArray
</b><p style="margin:0px;text-indent:0px"><b><br></b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>def flatten(input, output):</b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>    # Copy the cells etc.</b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>    output.ShallowCopy(input)</b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>    newPoints = vtk.vtkPoints()</b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>    numPoints = input.GetNumberOfPoints()</b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>    for i in range(0, numPoints):</b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>        coord = input.GetPoint(i)</b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>        x, y, z = coord[:3]</b></p><p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px">Now after I have made these copy of the input from my composite dataset, I can not print it to the output using the following:</p>
<p style="margin:0px;text-indent:0px"><b>print mean(coord)</b></p>
<p style="margin:0px;text-indent:0px"><br></p>and I get the following error :<br><br><span style="font-family:&#39;Courier&#39;;font-size:8.25pt;color:rgb(128,0,0)">Traceback (most recent call last):</span>
<p style="margin:0px;text-indent:0px"><span style="font-family:&#39;Courier&#39;;font-size:8.25pt;color:rgb(128,0,0)">  File &quot;&lt;string&gt;&quot;, line 26, in &lt;module&gt;</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:&#39;Courier&#39;;font-size:8.25pt;color:rgb(128,0,0)">  File &quot;&lt;string&gt;&quot;, line 13, in RequestData</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:&#39;Courier&#39;;font-size:8.25pt;color:rgb(128,0,0)">NameError: global name &#39;coord&#39; is not defined</span></p>
<p style="margin:0px;text-indent:0px;font-family:&#39;Courier&#39;;font-size:8.25pt;color:rgb(128,0,0)"><br></p><p style="margin:0px;text-indent:0px;font-family:&#39;Courier&#39;;font-size:8.25pt;color:rgb(128,0,0)"><br>
</p><br><p style="margin:0px;text-indent:0px">Does anybody know why I get this error and how I can fix it and so how I can get the geometric center of a composite dataset ?</p><p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px">Thanks in advance for your help</p><p style="margin:0px;text-indent:0px"><br></p><div><div><br></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On 29 March 2013 08:52, Favre  Jean <span dir="ltr">&lt;<a href="mailto:jfavre@cscs.ch" target="_blank">jfavre@cscs.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If you are looking for the Centroid of the dataset, then I would propose 3 lines of python in a Programmable Filter, using numpy&#39;s mean. Cut and paste in the script section of a PF:<br>
<br>
<br>
from paraview.vtk.dataset_adapter import numpyTovtkDataArray<br>
<br>
coords = inputs[0].Points<br>
<br>
print mean(coords)<br>
<br>
see page 85 of the ParaViewManual for other examples<br>
<br>
<a href="http://www.paraview.org/files/v3.98/ParaViewManual.v3.98.pdf" target="_blank">http://www.paraview.org/files/v3.98/ParaViewManual.v3.98.pdf</a><br>
-----------------<br>
Jean<br>
CSCS<br>
</blockquote></div><br></div>