[vtkusers] what's wrong in my code

Ali Habib ali.mahmoud.habib at gmail.com
Sat Jun 26 06:21:22 EDT 2010


I wante to cut part using vtk box widget , but the pipeline always fail any
suggestion please

the code is

        static vtkBoxWidget boxWidget;

        static vtkPlanes planes;

       static  vtkLODActor selectActor;

        static void Main(string[] args)
        {
            //Create a mace out of filters.

            vtkSphereSource sphere = new vtkSphereSource();
            vtkConeSource cone = new vtkConeSource();
            vtkGlyph3D glyph = new vtkGlyph3D();
            glyph.SetInputConnection(sphere.GetOutputPort());
            glyph.SetSource(cone.GetOutput());
            glyph.SetVectorModeToUseNormal();
            glyph.SetScaleModeToScaleByVector();
            glyph.SetScaleFactor(0.25);

            //The sphere and spikes are appended into a single polydata.
This just makes things
            //simpler to manage.
            vtkAppendPolyData apd = new vtkAppendPolyData();
            apd.AddInput(glyph.GetOutput());
            apd.AddInput(sphere.GetOutput());
            vtkPolyDataMapper maceMapper = new vtkPolyDataMapper();
            maceMapper.SetInputConnection(apd.GetOutputPort());
            vtkLODActor maceActor = new vtkLODActor();
            maceActor.SetMapper(maceMapper);
            maceActor.VisibilityOn();


            //This portion of the code clips the mace with the vtkPlanes
implicit function.
            //The clipped region is colored green.


            //Create the RenderWindow, Renderer and both Actors

            vtkRenderer ren1 = new vtkRenderer();
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer(ren1);

            vtkRenderWindowInteractor iren = new
vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);

            //The SetInteractor method is how 3D widgets are associated with
the render
            //window interactor. Internally, SetInteractor sets up a bunch
of callbacks
            //using the Command/Observer mechanism (AddObserver()).
            boxWidget = new vtkBoxWidget();
            boxWidget.SetInteractor(iren);
            boxWidget.SetPlaceFactor(1.25);

            ren1.AddActor(maceActor);
            ren1.AddActor(selectActor);

            //Add the actors to the renderer, set the background and size

            ren1.SetBackground(0.1, 0.2, 0.4);
            renWin.SetSize(300, 300);





            //Place the interactor initially. The input to a 3D widget is
used to
            //initially position and scale the widget. The
EndInteractionEvent is
            //observed which invokes the SelectPolygons callback.
            boxWidget.SetInput(glyph.GetOutput());
            boxWidget.PlaceWidget();
            iren.AddObserver((uint)vtk.EventIds.EndInteractionEvent, new
vtk.vtkDotNetCallback(SelectPolygons));
            iren.Initialize();







        }
        public static void SelectPolygons(vtk.vtkObject obj, uint eventId,
Object data, IntPtr clientdata)
        {
               boxWidget.GetPlanes( planes);
               selectActor.VisibilityOn();
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100626/a2f32c60/attachment.htm>


More information about the vtkusers mailing list