[Paraview] [EXTERNAL] Geometric center of Dataset
Hedieh Ebrahimi
hedieh.ebrahimi at amphos21.com
Tue Apr 2 05:26:38 EDT 2013
Thanks.
The thing is I have a composite dataset, the commands above i guess work
only for "simple dataset"
So I found that these commands for for a composite dataset and they make a
copy of input.
*from paraview.vtk.dataset_adapter import numpyTovtkDataArray *
*
*
* *
*def flatten(input, output):*
* *
* # Copy the cells etc.*
* *
* output.ShallowCopy(input)*
* *
* newPoints = vtk.vtkPoints()*
* *
* numPoints = input.GetNumberOfPoints()*
* *
* for i in range(0, numPoints):*
* *
* coord = input.GetPoint(i)*
* *
* x, y, z = coord[:3]*
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:
*print mean(coord)*
and I get the following error :
Traceback (most recent call last):
File "<string>", line 26, in <module>
File "<string>", line 13, in RequestData
NameError: global name 'coord' is not defined
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 ?
Thanks in advance for your help
On 29 March 2013 08:52, Favre Jean <jfavre at cscs.ch> wrote:
>
> If you are looking for the Centroid of the dataset, then I would propose 3
> lines of python in a Programmable Filter, using numpy's mean. Cut and paste
> in the script section of a PF:
>
>
> from paraview.vtk.dataset_adapter import numpyTovtkDataArray
>
> coords = inputs[0].Points
>
> print mean(coords)
>
> see page 85 of the ParaViewManual for other examples
>
> http://www.paraview.org/files/v3.98/ParaViewManual.v3.98.pdf
> -----------------
> Jean
> CSCS
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20130402/b2ea8053/attachment.htm>
More information about the ParaView
mailing list