[vtkusers] vtkProgrammableFilter in Activiz C#

Benjamin Jähn jaminus_jahnatos at freenet.de
Thu Jan 3 14:30:34 EST 2013


Hello,

I try to use the vtkProgrammableFilter to write my own Filter in 
Activiz.Net. Please have a look at the following example which basically 
shows what I want to do. Whenever I run the code my function is called 
but nevertheless the application crashes. What am I doing wrong?

Thanks in advance!
Regards!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Kitware.VTK;

namespace ProgrammableFilter
{

     class Program
     {
         public static vtkProgrammableFilter ProgFilter = 
vtkProgrammableFilter.New();

         public static void ProgrammableFunction(System.IntPtr arg0)
         {
ProgFilter.GetPolyDataOutput().ShallowCopy(ProgFilter.GetPolyDataInput());
             Console.WriteLine("Programmable!");
         }

         public static void Main(String[] argv)
         {
             vtkSphereSource Sphere = vtkSphereSource.New();
             Sphere.SetPhiResolution(100);
             Sphere.SetThetaResolution(100);

             //vtkProgrammableFilter
ProgFilter.SetExecuteMethod(ProgrammableFunction,IntPtr.Zero);
ProgFilter.SetInputConnection(Sphere.GetOutputPort());

             vtkPolyDataMapper Mapper = vtkPolyDataMapper.New();
Mapper.SetInputConnection(ProgFilter.GetOutputPort());

             vtkActor Actor = vtkActor.New();
             Actor.SetMapper(Mapper);
Actor.GetProperty().SetRepresentationToSurface();

             vtkRenderer Renderer = vtkRenderer.New();
             Renderer.AddActor(Actor);
             vtkRenderWindow RenderWindow = vtkRenderWindow.New();
             RenderWindow.AddRenderer(Renderer);
             RenderWindow.Render();

             vtkRenderWindowInteractor Interactor = 
vtkRenderWindowInteractor.New();
             Interactor.SetRenderWindow(RenderWindow);

             Interactor.Initialize();
             Interactor.Start();

             Console.ReadKey();
         }

     }
}




More information about the vtkusers mailing list