[vtkusers] How to make "eval plane SetOrigin [[pl3d GetOutput] GetCenter]" work in C++?

Goodwin Lawlor goodwin.lawlor at ucd.ie
Thu Apr 10 10:03:37 EDT 2008


Hi Liushuyan,

eval is there to expand the single argument (returned by [GetCenter]) of 
a list of 3 coordinates to 3 arguments, each containing a coordinate value.

In C++, you would code:

plane->SetOrigin(pl3d->GetOutput()->GetCenter());

There's no need for argument expansion in C++ since it's passing a 
pointer (to an a array of 3 coordinates).

Alternatively, you could code:

double c[3];
pl3d->GetCenter(c);
plane->SetOrigin(c);

//or

plane->SetOrigin(c[0], c[1], c[2]);

Sometimes it's safer to copy a coordinate to a local variable rather 
than get a pointer whose values may change unexpectedly.

hth

Goodwin

liushuyan wrote:
> Hi, everyone,
>     I am learning to translate vtk into c++ style, and hit some problems.
>     Can someone explain how to translate "eval plane SetOrigin [[pl3d 
> GetOutput] GetCenter]"?
>     What does the "eval" mean?
>  
> piece of the source code:
>  
> vtkPLOT3DReader pl3d
>     pl3d SetXYZFileName "$VTK_DATA/combxyz.bin"
>     pl3d SetQFileName "$VTK_DATA/combq.bin"
>     pl3d SetScalarFunctionNumber 100
>     pl3d SetVectorFunctionNumber 202
>     pl3d Update
> vtkPlane plane
>     eval plane SetOrigin [[pl3d GetOutput] GetCenter]
>     plane SetNormal -0.287 0 0.9579




More information about the vtkusers mailing list