[vtkusers] vtkProgrammableSource example written in C++ or Java

Jarek Sacha galicjan at yahoo.com
Tue May 27 13:01:17 EDT 2003


Yoshihiko:

Here is an example in Java. vtkProgrammableSource is used to generate
points on a cylinder. The pipeline is created in setupPipeline() method,
the first four lines maybe of most interest to you, output is extracted
from the source, in this case, with GetPolyDataOutput(). Here is the
definition of the source from the example (see attached file for the
rest):

    static class MyDataSource extends vtkProgrammableSource {
        void run() {
            // Get reference to output data
            vtkPolyData output = GetPolyDataOutput();
            // Create data points on a cylinder
            vtkPoints points = new vtkPoints();
            for (double z = 10D; z < (double) 100; z += 10) {
                for (double t = 0.0D;
                     t < 6.2831853071795862D;
                     t += 0.062831853071795868D) {
                    double x = (double) 25 * Math.sin(t);
                    double y = (double) 30 * Math.cos(t);
                    points.InsertNextPoint(x, y, z);
                }
            }
            // Set output data
            output.SetPoints(points);
        }
    }

Jarek

--- da5y at k2.dion.ne.jp wrote:
> Hi all
> 
> I've been learning the usage of vtkProgrammableSource.
> But I'm very confused the usage.
> 
> Especially, I can't understand the how to set the outputdata.
> 
> Dose anybody have an example written in C++ or Java?
> 
> Thanks in advance
> -- 
> Yoshihiko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ProgrammableSourceTest.java
Type: x-unknown/x-unknown
Size: 2842 bytes
Desc: ProgrammableSourceTest.java
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030527/28c73aca/attachment.bin>


More information about the vtkusers mailing list