[vtkusers] How to use vtkProgrammableFilter in Java

Ben Held ben.held at staarinc.com
Thu Aug 16 17:31:36 EDT 2001


Jeff,

Thanks for the help.  However, one thing that I forgot to mention is that I
need to use the programmable filter to change the type of the data from
vtkUnstructuredGrid to vtkPolyData.  Is this possible?  It appears that the
programmable filter sets the output type to match the input type - is there
a way to overload this or something?

Thanks,

Ben
  -----Original Message-----
  From: jal at megadodo.segNET.COM [mailto:jal at megadodo.segNET.COM]On Behalf Of
J.A. Lee
  Sent: Thursday, August 16, 2001 1:55 PM
  To: Ben Held
  Subject: Re: [vtkusers] How to use vtkProgrammableFilter in Java


  Ben,
  Presumably:
  vtkProgrammableFilter pFilt = new vtkProgrammableFilter();
  pFilt.SetInput(source.GetOutput()); // mabey source is output of another
filter?
  pFilt.SetExecuteMethod(new FilterMethod(), "execute");

  public class FilterMethod
  {
      public FilterMethod() {}

      public void execute() {

          vtkPolyData input = pFilt.GetPolyDataInput();
          // do some stuff like calculate new scalars?
          int numPts = input.GetNumberOfPoints();

          vtkScalars newScalars = new vtkScalars();

          for (int i = 0; i < numPts; ++i) {
              newScalars.InsertScalar(i, 2*i);
          }

          pFilt.GetPolyDataOutput().CopyStructure(input);
          pFilt.GetPolyDataOutput().GetPointData().SetScalars(newScalars);
          newScalars = null;
      }
  }

  Mabey you forgot the copy from input to output?
  -Jeff




  Ben Held wrote:

    Any idea how to setup up the output for the programmable filter?  A call
to progfilter.GetOutput or progfilter.GetPolyDataOutput returns a null.
Calling progfilter.SetOutput(new vtkPolyData()) seems to work, but my output
isn't rendered (I see nothing).Ben
      -----Original Message-----
      From: jal at megadodo.segNET.COM [mailto:jal at megadodo.segNET.COM]On
Behalf Of J.A. Lee
      Sent: Thursday, August 16, 2001 12:32 PM
      To: Ben Held
      Subject: Re: [vtkusers] How to use vtkProgrammableFilter in Java
      Ben,
      filt.SetExecuteMethod(new MyExecuteMethod(), "execute");

          public class MyExecuteMethod {

              public MyExecuteMethod(){ }

              public void execute(){
                  doStuff()....
              }
          }


      Ben Held wrote:

        Hello,
        I need to make use of vtkProgrammableFilter in my java application.
There
        are not any examples of how to set the execute function to a Java
function.
        I need to know the function signatures and how to call
SetExecuteMethod...

        Thanks,
        Ben

        Ben L. Held
        Simulation Technology & Applied Research, Inc.
        11520 N. Port Washington Rd.
        Suite 101B
        Mequon, WI  53092
        Phone: (262) 240-0291 x101
        FAX: (262) 240-0294
        e-mail: ben.held at staarinc.com
        web: http://www.staarinc.com

        _______________________________________________
        This is the private VTK discussion list.
        Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
        Follow this link to subscribe/unsubscribe:
        http://public.kitware.com/mailman/listinfo/vtkusers

--
J.A. Lee
Software Engineer
Computational Dynamics North America
3 Schoolhouse Lane
Etna NH, 03750
ph: 603-643-9993 x109, fax: 603-643-9994

--
J.A. Lee
Software Engineer
Computational Dynamics North America
3 Schoolhouse Lane
Etna NH, 03750
ph: 603-643-9993 x109, fax: 603-643-9994

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20010816/f71f46ca/attachment.htm>


More information about the vtkusers mailing list