Beispiel #1
2
        static void Main()
        {
            string VTK_DATA_ROOT = "C:/Program Files/VTKData";

            // Create a vtkBYUReader and read in a data set.
            vtkBYUReader fohe = new vtkBYUReader();
            fohe.SetGeometryFileName(VTK_DATA_ROOT + "/Data/teapot.g");

            // Create a vtkPolyDataNormals filter to calculate the normals of the
            // data set.
            vtkPolyDataNormals normals = new vtkPolyDataNormals();
            normals.SetInputConnection(fohe.GetOutputPort());
            // Set up the associated mapper and actor.
            vtkPolyDataMapper foheMapper = new vtkPolyDataMapper();
            foheMapper.SetInputConnection(normals.GetOutputPort());
            vtkLODActor foheActor = new vtkLODActor();
            foheActor.SetMapper(foheMapper);

            // Create a vtkOutlineFilter to draw the bounding box of the data set.
            // Also create the associated mapper and actor.
            vtkOutlineFilter outline = new vtkOutlineFilter();
            outline.SetInputConnection(normals.GetOutputPort());
            vtkPolyDataMapper mapOutline = new vtkPolyDataMapper();
            mapOutline.SetInputConnection(outline.GetOutputPort());
            vtkActor outlineActor = new vtkActor();
            outlineActor.SetMapper(mapOutline);
            outlineActor.GetProperty().SetColor(0, 0, 0);

            // Create a vtkCamera, and set the camera parameters.
            vtkCamera camera = new vtkCamera();
            camera.SetClippingRange(1.60187, 20.0842);
            camera.SetFocalPoint(0.21406, 1.5, 0);
            camera.SetPosition(8.3761, 4.94858, 4.12505);
            camera.SetViewUp(0.180325, 0.549245, -0.815974);

            // Create a vtkLight, and set the light parameters.
            vtkLight light = new vtkLight();
            light.SetFocalPoint(0.21406, 1.5, 0);
            light.SetPosition(8.3761, 4.94858, 4.12505);

            // Create the Renderers.  Assign them the appropriate viewport
            // coordinates, active camera, and light.
            vtkRenderer ren = new vtkRenderer();
            ren.SetViewport(0, 0, 0.5, 1.0);
            ren.SetActiveCamera(camera);
            ren.AddLight(light);
            vtkRenderer ren2 = new vtkRenderer();
            ren2.SetViewport(0.5, 0, 1.0, 1.0);
            ren2.SetActiveCamera(camera);
            ren2.AddLight(light);

            // Create the RenderWindow and RenderWindowInteractor.
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer(ren);
            renWin.AddRenderer(ren2);
            renWin.SetWindowName("VTK - Cube Axes");
            renWin.SetSize(600, 300);
            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);

            // Add the actors to the renderer, and set the background.
            ren.AddViewProp(foheActor);
            ren.AddViewProp(outlineActor);
            ren2.AddViewProp(foheActor);
            ren2.AddViewProp(outlineActor);

            ren.SetBackground(0.1, 0.2, 0.4);
            ren2.SetBackground(0.1, 0.2, 0.4);

            // Create a text property for both cube axes
            vtkTextProperty tprop = new vtkTextProperty();
            tprop.SetColor(1, 1, 1);
            tprop.ShadowOn();

            // Create a vtkCubeAxesActor2D.  Use the outer edges of the bounding box to
            // draw the axes.  Add the actor to the renderer.
            vtkCubeAxesActor2D axes = new vtkCubeAxesActor2D();
            axes.SetInput(normals.GetOutput());
            axes.SetCamera(ren.GetActiveCamera());
            axes.SetLabelFormat("%6.4g");
            axes.SetFlyModeToOuterEdges();
            axes.SetFontFactor(0.8);
            axes.SetAxisTitleTextProperty(tprop);
            axes.SetAxisLabelTextProperty(tprop);
            ren.AddViewProp(axes);

            // Create a vtkCubeAxesActor2D.  Use the closest vertex to the camera to
            // determine where to draw the axes.  Add the actor to the renderer.
            vtkCubeAxesActor2D axes2 = new vtkCubeAxesActor2D();
            axes2.SetViewProp(foheActor);
            axes2.SetCamera(ren2.GetActiveCamera());
            axes2.SetLabelFormat("%6.4g");
            axes2.SetFlyModeToClosestTriad();
            axes2.SetFontFactor(0.8);
            axes2.ScalingOff();
            axes2.SetAxisTitleTextProperty(tprop);
            axes2.SetAxisLabelTextProperty(tprop);
            ren2.AddViewProp(axes2);

            renWin.AddObserver((uint) EventIds.AbortCheckEvent, CheckAbort);

            iren.Initialize();
            renWin.Render();
            iren.Start();

            vtkWin32OpenGLRenderWindow win32win =
                vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
            if (null != win32win) win32win.Clean();
        }
Beispiel #2
0
        /// <summary>
        /// Event fired when the graph selection is changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_SelectionChangedEvt(vtkObject sender, vtkObjectEventArgs e)
        {
            //Get the selection
            vtkDataRepresentation dr   = view.GetRepresentation(0);
            vtkAnnotationLink     al   = dr.GetAnnotationLink();
            vtkSelection          sel  = al.GetCurrentSelection();
            vtkAbstractArray      arr  = null;
            vtkSelectionNode      node = sel.GetNode(0);

            if (null != node)
            {
                arr = node.GetSelectionList();
            }

            vtkIdTypeArray arr1 = (vtkIdTypeArray)arr;

            // Short circuit if nothing is selected...
            int numSelected = (int)arr1.GetNumberOfTuples();

            if (0 == numSelected)
            {
                return;
            }

            vtkStringArray arr2 = ((vtkStringArray)g.GetVertexData().GetAbstractArray("label"));

            //get a pseudo random name if more than one are selected
            string name = arr2.GetValue(
                (int)arr1.GetValue(System.DateTime.Now.Millisecond % numSelected));

            //reset the small arrayList
            arrListSmall = new System.Collections.ArrayList();
            int hops;

            try
            {
                hops = System.Convert.ToInt32(toolStripTextBox3.Text);
            }
            catch (Exception)
            {
                hops = 1;
            }

            toolStripTextBox1.Text = name;
            toolStripTextBox1.Invalidate();
            this.Update();

            //Start the loading graphic and add another renderer on top for the spinning logo
            vtkRenderWindow win = this.renderWindowControl1.RenderWindow;

            win.AddRenderer(logoRenderer);
            win.Render();
            this.webBrowser1.Url = new Uri("http://en.wikipedia.org/wiki/" + name.Replace(" ", "_"));
            //Start the work
            addLinks(g, name, hops);
            //Remove the spinning logo after the work is done
            win.RemoveRenderer(logoRenderer);
            win.Render();
        }
Beispiel #3
0
        //Button press events

        //Drag events
        private void drag_LeftDown(vtkObject sender, vtkObjectEventArgs e)
        {
            if (mouseDownLeft == false)
            {
                //Get position
                int[]         pos   = renWin.GetInteractor().GetEventPosition();
                vtkCoordinate coord = vtkCoordinate.New();
                coord.SetCoordinateSystemToDisplay();
                coord.SetValue(pos[0], pos[1], 0);
                double[] tmp = coord.GetComputedWorldValue(renWin.GetRenderers().GetFirstRenderer());

                position[0] = (int)tmp[0];
                position[1] = (int)tmp[1];
                position[2] = (int)tmp[0];
                position[3] = (int)tmp[1];

                //Create new line object
                if (has_actor == true)
                {
                    line.update(position);
                }
                else
                {
                    line = new Rendering.vtkLine(renWin, slice);
                    line.draw(position);
                }


                renWin.Render();

                has_actor = true;

                mouseDownLeft = true;
            }
        }
Beispiel #4
0
        private void VRML()
        {
            // Path to vtk data must be set as an environment variable
            // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0"
            vtkTesting test     = vtkTesting.New();
            string     root     = test.GetDataRoot();
            string     filePath = System.IO.Path.Combine(root, @"Data\bot2.wrl");
            // reader
            vtkVRMLImporter importer = vtkVRMLImporter.New();

            importer.SetFileName(filePath);
            importer.Update();

            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;

            renderWindow.AddRenderer(importer.GetRenderer());
            renderWindow.Render();

            //vtkActorCollection actors = importer.GetRenderer().GetActors();
            //actors.InitTraversal();
            //vtkActor tmp;
            //while(( tmp = actors.GetNextActor()) != null) {
            //}
        }
Beispiel #5
0
        private void renderScene()
        {
            vtkCamera camera;

            if (toShow != null)
            {
                this.geometryPoints();

                vtkPolyData polydata = vtkPolyData.New();
                polydata.SetPoints(pontosVTK);

                vtkDelaunay2D del = vtkDelaunay2D.New();
                del.AddInput(polydata);

                vtkPolyDataMapper mapMesh = vtkPolyDataMapper.New();
                mapMesh.SetInput(del.GetOutput());

                vtkActor meshActor = vtkActor.New();
                meshActor.SetMapper(mapMesh);
                meshActor.GetProperty().SetColor(0.5d, 0.5d, 0d);

                windowVTK.AddRenderer(rendererVTK);
                rendererVTK.AddActor(meshActor);

                windowVTK.Render();
                rendererVTK.Render();

                meshActor.Render(rendererVTK, mapMesh);
                camera = rendererVTK.GetActiveCamera();
                camera.Zoom(1.0d);

                rendererVTK.ResetCamera();
            }
        }
Beispiel #6
0
        static private void init()
        {
            vtkSTLReader rdr = vtkSTLReader.New();

            rdr.SetFileName("BODY-EXTRUDEUR-WADE.stl");



            // Créer une géométrie sphérique

            /*vtkSphereSource sphere = vtkSphereSource.New();
             * sphere.SetRadius(1.0);
             * sphere.SetThetaResolution(18);
             * sphere.SetPhiResolution(18);*/

            // Transforme la géométrie en primitives graphiques (OpenGL dans notre cas)
            vtkPolyDataMapper map = vtkPolyDataMapper.New();

            map.SetInput(rdr.GetOutput());

            // L'acteur représente l'entitée géométrique.
            // Il permet de définir sa position, son orientation, sa couleur, etc.
            vtkActor aSphere = new vtkActor();

            aSphere.SetMapper(map);
            aSphere.GetProperty().SetColor(0.8, 0.8, 0.8); // color blue

            // Nous créons un renderer qui va faire le rendu de notre entitée.
            vtkRenderer ren1 = vtkRenderer.New();

            ren1.AddActor(aSphere);
            ren1.SetBackground(1, 1, 1); // background color white

            // Nous créons une fenêtre de rendu
            vtkRenderWindow renWin = vtkRenderWindow.New();

            renWin.AddRenderer(ren1);
            renWin.SetSize(300, 300);

            // Nous créons un interactor qui permet de bouger la caméra.
            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();

            iren.SetRenderWindow(renWin);

            // Nous lançons le rendu et l'interaction
            renWin.Render();
            iren.Start();


            ////// CLEANUP ///////
            rdr.Dispose();
            map.Dispose();
            aSphere.Dispose();
            ren1.Dispose();
            renWin.Dispose();
            iren.Dispose();
        }
Beispiel #7
0
        ///<summary>Entry Point</summary>
        static void Main(string[] args)
        {
            // Create a simple sphere. A pipeline is created.
            sphere = vtkSphereSource.New();
            sphere.SetThetaResolution(8);
            sphere.SetPhiResolution(16);

            shrink = vtkShrinkPolyData.New();
            shrink.SetInputConnection(sphere.GetOutputPort());
            shrink.SetShrinkFactor(0.9);

            mapper = vtkPolyDataMapper.New();
            mapper.SetInputConnection(shrink.GetOutputPort());

            // The actor links the data pipeline to the rendering subsystem
            actor = vtkActor.New();
            actor.SetMapper(mapper);
            actor.GetProperty().SetColor(1, 0, 0);

            // Create components of the rendering subsystem
            //
            ren1 = vtkRenderer.New();
            renWin = vtkRenderWindow.New();
            renWin.AddRenderer(ren1);
            iren = vtkRenderWindowInteractor.New();
            iren.SetRenderWindow(renWin);

            // Add the actors to the renderer, set the window size
            //
            ren1.AddViewProp(actor);
            renWin.SetSize(250, 250);
            renWin.Render();
            camera = ren1.GetActiveCamera();
            camera.Zoom(1.5);

            // render the image and start the event loop
            //
            renWin.Render();

            iren.Initialize();
            iren.Start();

            deleteAllVTKObjects();
        }
Beispiel #8
0
        public void setRender(vtkRenderWindow renWin)
        {
            _renWin = renWin;
            _render = renWin.GetRenderers().GetFirstRenderer();
            CompontData data = genData(true);

            _actor = CompontFactory.genActor(data, CompontFactory.genClickProperty());
            _render.AddViewProp(_actor);
            _renWin.Render();
        }
Beispiel #9
0
        private void sliderContourValue_Scroll(object sender, EventArgs e)
        {
            TrackBar slider = sender as TrackBar;

            if (slider != null)
            {
                _ContourFilter.GenerateValues(1, slider.Value, slider.Value);
                _RenderWindow.Render();
            }
        }
Beispiel #10
0
        /// <summary>
        /// Clears the graph and makes a new one
        /// </summary>
        private void createNewGraph()
        {
            String lookupValue = toolStripTextBox1.Text;

            //clean up any old graph views in the renderer
            vtkMutableDirectedGraph g_temp = g;

            g = vtkMutableDirectedGraph.New();
            if (g_temp != null)
            {
                g_temp.Dispose();
            }
            //reset array lists
            arrListSmall = new System.Collections.ArrayList();
            vtkStringArray label = vtkStringArray.New();

            label.SetName("label");
            //give the graph a starting point
            g.GetVertexData().AddArray(label);
            g.AddVertex();
            label.InsertNextValue(lookupValue);
            arrListSmall.Add(lookupValue);
            int hops;

            try
            {
                hops = System.Convert.ToInt32(toolStripTextBox3.Text);
            }
            catch (Exception)
            {
                hops = 1;
            }
            //Start the loading graphic and switch renderers
            vtkRenderWindow win = this.renderWindowControl1.RenderWindow;

            win.AddRenderer(logoRenderer);
            win.Render();

            this.webBrowser1.Url = new Uri("http://en.wikipedia.org/wiki/" + lookupValue.Replace(" ", "_"));
            //Start the work
            addLinks(g, lookupValue, hops);
            //Go back to the graph view after the work is done
            win.RemoveRenderer(logoRenderer);

            //Setup the view properties
            view.SetLayoutStrategyToSimple2D();
            view.AddRepresentationFromInput(g);
            view.SetVertexLabelArrayName("label");
            view.VertexLabelVisibilityOn();
            view.SetVertexColorArrayName("VertexDegree");
            view.ColorVerticesOn();
            view.GetRenderer().ResetCamera();
            view.Update();
        }
Beispiel #11
0
 /// <summary>
 ///A process translated from the tcl scripts
 /// </summary>
 public static void MotionCallback(double x, double y)
 {
     //Global Variable Declaration Skipped
     // Compute display point from Tk display point.[]
     WindowY = 400;
     y       = WindowY - y;
     z       = ren1.GetZ((int)x, (int)y);
     ren1.SetDisplayPoint((double)x, (double)y, (double)z);
     ren1.DisplayToWorld();
     pt = ren1.GetWorldPoint();
     //tk_messageBox -message "$pt"[]
     x   = (double)(lindex(pt, 0));
     y   = (double)(lindex(pt, 1));
     z   = (double)(lindex(pt, 2));
     val = puzzle.SetPoint((double)x, (double)y, (double)z);
     if ((val) != LastVal)
     {
         renWin.Render();
         LastVal = val;
     }
 }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestSpherePuzzle(String [] argv)
    {
        //Prefix Content is: ""

          // prevent the tk window from showing up then start the event loop[]
          renWin = vtkRenderWindow.New();
          // create a rendering window and renderer[]
          ren1 = vtkRenderer.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          renWin.SetSize((int)400,(int)400);
          puzzle = new vtkSpherePuzzle();
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)puzzle.GetOutputPort());
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          arrows = new vtkSpherePuzzleArrows();
          mapper2 = vtkPolyDataMapper.New();
          mapper2.SetInputConnection((vtkAlgorithmOutput)arrows.GetOutputPort());
          actor2 = new vtkActor();
          actor2.SetMapper((vtkMapper)mapper2);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)actor);
          ren1.AddActor((vtkProp)actor2);
          ren1.SetBackground((double)0.1,(double)0.2,(double)0.4);
          LastVal = -1;
          //method moved
          //method moved
          renWin.Render();
          cam = ren1.GetActiveCamera();
          cam.Elevation((double)-40);
          puzzle.MoveHorizontal((int)0,(int)100,(int)0);
          puzzle.MoveHorizontal((int)1,(int)100,(int)1);
          puzzle.MoveHorizontal((int)2,(int)100,(int)0);
          puzzle.MoveVertical((int)2,(int)100,(int)0);
          puzzle.MoveVertical((int)1,(int)100,(int)0);
          renWin.Render();

        //deleteAllVTKObjects();
    }
        /// <summary>
        /// Renders this VtkRenderWindowControl.
        /// </summary>
        ///
        /// <seealso cref="M:ActivizWPF.Framework.Native.HwndWrapper.Render()"/>
        protected override void Render()
        {
            try
            {
                if (_renderWindow != null)
                {
                    this.SyncRenderWindowSize();

                    if (_renderWindow.GetInteractor() != _renderWindowInteractor)
                    {
                        AttachInteractor();
                        _renderWindow.Render();
                    }

                    _renderWindow.Render();
                }
            }
            catch (Exception e)
            {
                log.ErrorException("Render()", e);
            }
        }
        private void Window_Activated(object sender, EventArgs e)
        {
            // 一定要先 vtkformhost.Child = vtkControl;下面三条顺序不能乱 否则报错 切记!
            vtkformhost.Child = vtkControl;
            vtkRenderWindow renWin    = vtkControl.RenderWindow;
            vtkRenderer     aRenderer = renWin.GetRenderers().GetFirstRenderer();

            renWin.AddRenderer(aRenderer);

            Marshal.Copy(ys1, 0, temp128, imgLine * imgPixel * imgNum);


            temp.SetArray(temp128, imgLine * imgPixel * imgNum, 1);

            testimgdata.SetDimensions(imgLine, imgPixel, imgNum);
            testimgdata.SetSpacing(1, 1, 4);
            testimgdata.SetScalarTypeToUnsignedChar();
            testimgdata.SetNumberOfScalarComponents(1);
            testimgdata.AllocateScalars();
            testimgdata.GetPointData().SetScalars(temp);
            testimgdata.Modified();

            VtkSetColor();
            VtkSetOpacity();

            volumeProperty.SetColor(colorTransferFunction);
            volumeProperty.SetScalarOpacity(opacityTransferFunction);
            volumeProperty.ShadeOn();
            volumeProperty.SetInterpolationTypeToLinear();

            volumeMapper.SetVolumeRayCastFunction(compositeFunction);
            volumeMapper.SetInput(testimgdata);

            volume.SetMapper(volumeMapper);
            volume.SetProperty(volumeProperty);

            aCamera.SetViewUp(0, -1, 0);
            aCamera.SetPosition(-1, 0, 1);
            aCamera.ComputeViewPlaneNormal();

            aRenderer.AddVolume(volume);
            aRenderer.SetBackground(0, 0, 0.6);
            aRenderer.SetActiveCamera(aCamera);
            aRenderer.ResetCamera();
            renWin.SetSize(800, 800);
            renWin.Render();
        }
Beispiel #15
0
        private void Axes()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.SetCenter(0.0, 0.0, 0.0);
            sphereSource.SetRadius(0.5);

            //create a mapper
            vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New();

            sphereMapper.SetInputConnection(sphereSource.GetOutputPort());

            // create an actor
            vtkActor sphereActor = vtkActor.New();

            sphereActor.SetMapper(sphereMapper);

            // a renderer and render window
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.2, 0.3, 0.4);

            // add the actors to the scene
            renderer.AddActor(sphereActor);

            vtkAxesActor axes = vtkAxesActor.New();
            // The axes are positioned with a user transform
            vtkTransform transform = vtkTransform.New();

            transform.Translate(0.75, 0.0, 0.0);
            axes.SetUserTransform(transform);
            // properties of the axes labels can be set as follows
            // this sets the x axis label to red
            // axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(1,0,0);

            // the actual text of the axis label can be changed:
            // axes.SetXAxisLabelText("test");

            renderer.AddActor(axes);
            // we need to call Render() for the whole renderWindow,
            // because vtkAxesActor uses an overlayed renderer for the axes label
            // in total we have now two renderer
            renderWindow.Render();
        }
Beispiel #16
0
        public static void ShowPolydata(string airwayPath)
        {
            if (!File.Exists(airwayPath))
            {
                MessageBox.Show("文件不存在!");
                return;
            }
            vtkRenderWindow renWin = vtkRenderWindow.New();

            renWin.SetSize(600, 600);

            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();

            renWin.SetInteractor(iren);

            vtkInteractorStyleTrackballCamera interactorStyle = new vtkInteractorStyleTrackballCamera();

            iren.SetInteractorStyle(interactorStyle);

            vtkRenderer renderer = vtkRenderer.New();

            renderer.GradientBackgroundOn();
            renderer.SetBackground(0, 0, 0);
            renderer.SetBackground2(0, 0, 1);
            renWin.AddRenderer(renderer);
            vtkXMLPolyDataReader reader = new vtkXMLPolyDataReader();

            reader.SetFileName(airwayPath);
            reader.Update();

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.ScalarVisibilityOff();
            mapper.SetInput(reader.GetOutput());
            reader.Dispose();
            vtkActor actor = new vtkActor();

            actor.SetMapper(mapper);

            renderer.AddActor(actor);

            renWin.Render();
        }
        private void VerticalViewBtn_Click_1(object sender, RoutedEventArgs e)
        {
            VTKFormRender   form   = (VTKFormRender)winform.Child;
            vtkRenderer     ren    = form.renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
            vtkRenderWindow renWin = form.renderWindowControl1.RenderWindow;

            vtkCamera camera = ren.GetActiveCamera();

            camera.SetRoll(form.StoredViewCamera[2].GetRoll());
            camera.SetPosition(form.StoredViewCamera[2].GetPosition()[0],
                               form.StoredViewCamera[2].GetPosition()[1],
                               form.StoredViewCamera[2].GetPosition()[2]);
            camera.SetFocalPoint(form.StoredViewCamera[2].GetFocalPoint()[0],
                                 form.StoredViewCamera[2].GetFocalPoint()[1],
                                 form.StoredViewCamera[2].GetFocalPoint()[2]);
            camera.SetViewUp(form.StoredViewCamera[2].GetViewUp()[0],
                             form.StoredViewCamera[2].GetViewUp()[1],
                             form.StoredViewCamera[2].GetViewUp()[2]);

            renWin.Render();
        }
Beispiel #18
0
        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            vtkSphereSource sphere = vtkSphereSource.New();

            sphere.SetThetaResolution(8);
            sphere.SetPhiResolution(16);

            vtkShrinkPolyData shrink = vtkShrinkPolyData.New();

            shrink.SetInputConnection(sphere.GetOutputPort());
            shrink.SetShrinkFactor(0.5);

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(shrink.GetOutputPort());

            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            actor.GetProperty().SetColor(0, 0, 1);

            vtkRenderer renderer = renderWindowControl1
                                   .RenderWindow.GetRenderers().GetFirstRenderer();
            vtkRenderWindow rendererWindow = renderWindowControl1
                                             .RenderWindow;

            renderer.AddViewProp(actor); //Actor to specjalizacja Prop
            rendererWindow.SetSize(250, 250);
            rendererWindow.Render();

            vtkCamera camera = renderer.GetActiveCamera();

            camera.Zoom(1.5);

            //do debugu
            //renderWindowControl1.AddTestActors = true;
        }
Beispiel #19
0
        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            // Create a simple sphere. A pipeline is created.
            vtkSphereSource sphere = vtkSphereSource.New();

            sphere.SetThetaResolution(8);
            sphere.SetPhiResolution(16);

            vtkShrinkPolyData shrink = vtkShrinkPolyData.New();

            shrink.SetInputConnection(sphere.GetOutputPort());
            shrink.SetShrinkFactor(0.9);

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(shrink.GetOutputPort());

            // The actor links the data pipeline to the rendering subsystem
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            actor.GetProperty().SetColor(1, 0, 0);

            // Create components of the rendering subsystem
            //
            vtkRenderer     ren1   = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
            vtkRenderWindow renWin = renderWindowControl1.RenderWindow;

            // Add the actors to the renderer, set the window size
            //
            ren1.AddViewProp(actor);
            renWin.SetSize(250, 250);
            renWin.Render();
            vtkCamera camera = ren1.GetActiveCamera();

            camera.Zoom(1.5);
        }
Beispiel #20
0
        private void ReadOBJ()
        {
            // Path to vtk data must be set as an environment variable
            // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0"
            vtkTesting test = vtkTesting.New();
            string     root = test.GetDataRoot();
            // caution: vtkdata-5.8.0\Data\mni-surface-mesh.obj is no valid obj file!
            //string filePath = System.IO.Path.Combine(root, @"Data\mni-surface-mesh.obj");
            string filePath = System.IO.Path.Combine(root, @"Data\ViewPoint\cow.obj");

            vtkOBJReader reader = vtkOBJReader.New();

            if (!File.Exists(filePath))
            {
                MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            reader.SetFileName(filePath);
            reader.Update();
            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(reader.GetOutputPort());
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            // renderer
            vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer();

            // set background color
            renderer.SetBackground(0.3, 0.6, 0.3);
            // add our actor to the renderer
            renderer.AddActor(actor);
            renderWindow.Render();
        }
Beispiel #21
0
        /// <summary>
        /// 读取stl文件,并在窗口进行显示,并设置全局变量originalMesh
        /// </summary>
        private void ReadSTL()
        {
            //Path to vtk data must be set as an environment variable
            //VTK_DATA_ROOT=""
            vtkSTLReader reader = vtkSTLReader.New();
            reader.SetFileName(FileFullName);
            reader.Update();
            mapper = vtkPolyDataMapper.New();
            mapper.SetInputConnection(reader.GetOutputPort());

            actor = vtkActor.New();
            actor.SetMapper(mapper);
            //get a reference to the renderwindow of our renderWindowControll
            renderWindow = renderWindowControl1.RenderWindow;
            //renderer
            renderer = renderWindow.GetRenderers().GetFirstRenderer();
            //移除之前所有prop
            renderer.RemoveAllViewProps();
            //set background color
            renderer.SetBackground(0.2, 0.3, 0.4);
            //add our actor to the renderer
            renderer.AddActor(actor);
            originalMesh = vtkPolyData.New();
            originalMesh.DeepCopy(reader.GetOutput());
            tb_numOfPoint.Text = originalMesh.GetNumberOfPoints().ToString();

            //creat a cell picker
            picker = vtkCellPicker.New();
            vtkRenderWindowInteractor iren = renderWindow.GetInteractor();
            iren.SetPicker(picker);

            renderer.ResetCamera();
            renderWindow.Render();
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVSelectionLoop(String [] argv)
    {
        //Prefix Content is: ""

          //[]
          // Demonstrate the use of implicit selection loop as well as closest point[]
          // connectivity[]
          //[]
          // create pipeline[]
          //[]
          sphere = new vtkSphereSource();
          sphere.SetRadius((double)1);
          sphere.SetPhiResolution((int)100);
          sphere.SetThetaResolution((int)100);
          selectionPoints = new vtkPoints();
          selectionPoints.InsertPoint((int)0,(double)0.07325,(double)0.8417,(double)0.5612);
          selectionPoints.InsertPoint((int)1,(double)0.07244,(double)0.6568,(double)0.7450);
          selectionPoints.InsertPoint((int)2,(double)0.1727,(double)0.4597,(double)0.8850);
          selectionPoints.InsertPoint((int)3,(double)0.3265,(double)0.6054,(double)0.7309);
          selectionPoints.InsertPoint((int)4,(double)0.5722,(double)0.5848,(double)0.5927);
          selectionPoints.InsertPoint((int)5,(double)0.4305,(double)0.8138,(double)0.4189);
          loop = new vtkImplicitSelectionLoop();
          loop.SetLoop((vtkPoints)selectionPoints);
          extract = new vtkExtractGeometry();
          extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          extract.SetImplicitFunction((vtkImplicitFunction)loop);
          connect = new vtkConnectivityFilter();
          connect.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort());
          connect.SetExtractionModeToClosestPointRegion();
          connect.SetClosestPoint((double)selectionPoints.GetPoint((int)0)[0], (double)selectionPoints.GetPoint((int)0)[1],(double)selectionPoints.GetPoint((int)0)[2]);
          clipMapper = new vtkDataSetMapper();
          clipMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort());
          backProp = new vtkProperty();
          backProp.SetDiffuseColor((double) 1.0000, 0.3882, 0.2784 );
          clipActor = new vtkActor();
          clipActor.SetMapper((vtkMapper)clipMapper);
          clipActor.GetProperty().SetColor((double) 0.2000, 0.6300, 0.7900 );
          clipActor.SetBackfaceProperty((vtkProperty)backProp);
          // Create graphics stuff[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)clipActor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Azimuth((double)30);
          ren1.GetActiveCamera().Elevation((double)30);
          ren1.GetActiveCamera().Dolly((double)1.2);
          ren1.ResetCameraClippingRange();
          renWin.SetSize((int)400,(int)400);
          renWin.Render();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVLineIntersectQuadraticCells(String [] argv)
    {
        //Prefix Content is: ""

          // Contour every quadratic cell type[]
          // Create a scene with one of each cell type.[]
          // QuadraticEdge[]
          edgePoints = new vtkPoints();
          edgePoints.SetNumberOfPoints((int)3);
          edgePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          edgePoints.InsertPoint((int)1,(double)1.0,(double)0,(double)0);
          edgePoints.InsertPoint((int)2,(double)0.5,(double)0.25,(double)0);
          edgeScalars = new vtkFloatArray();
          edgeScalars.SetNumberOfTuples((int)3);
          edgeScalars.InsertValue((int)0,(float)0.0);
          edgeScalars.InsertValue((int)1,(float)0.0);
          edgeScalars.InsertValue((int)2,(float)0.9);
          aEdge = new vtkQuadraticEdge();
          aEdge.GetPointIds().SetId((int)0,(int)0);
          aEdge.GetPointIds().SetId((int)1,(int)1);
          aEdge.GetPointIds().SetId((int)2,(int)2);
          aEdgeGrid = new vtkUnstructuredGrid();
          aEdgeGrid.Allocate((int)1,(int)1);
          aEdgeGrid.InsertNextCell((int)aEdge.GetCellType(),(vtkIdList)aEdge.GetPointIds());
          aEdgeGrid.SetPoints((vtkPoints)edgePoints);
          aEdgeGrid.GetPointData().SetScalars((vtkDataArray)edgeScalars);
          aEdgeMapper = new vtkDataSetMapper();
          aEdgeMapper.SetInputData((vtkDataSet)aEdgeGrid);
          aEdgeMapper.ScalarVisibilityOff();
          aEdgeActor = new vtkActor();
          aEdgeActor.SetMapper((vtkMapper)aEdgeMapper);
          aEdgeActor.GetProperty().SetRepresentationToWireframe();
          aEdgeActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic triangle[]
          triPoints = new vtkPoints();
          triPoints.SetNumberOfPoints((int)6);
          triPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          triPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0);
          triPoints.InsertPoint((int)2,(double)0.5,(double)0.8,(double)0.0);
          triPoints.InsertPoint((int)3,(double)0.5,(double)0.0,(double)0.0);
          triPoints.InsertPoint((int)4,(double)0.75,(double)0.4,(double)0.0);
          triPoints.InsertPoint((int)5,(double)0.25,(double)0.4,(double)0.0);
          triScalars = new vtkFloatArray();
          triScalars.SetNumberOfTuples((int)6);
          triScalars.InsertValue((int)0,(float)0.0);
          triScalars.InsertValue((int)1,(float)0.0);
          triScalars.InsertValue((int)2,(float)0.0);
          triScalars.InsertValue((int)3,(float)1.0);
          triScalars.InsertValue((int)4,(float)0.0);
          triScalars.InsertValue((int)5,(float)0.0);
          aTri = new vtkQuadraticTriangle();
          aTri.GetPointIds().SetId((int)0,(int)0);
          aTri.GetPointIds().SetId((int)1,(int)1);
          aTri.GetPointIds().SetId((int)2,(int)2);
          aTri.GetPointIds().SetId((int)3,(int)3);
          aTri.GetPointIds().SetId((int)4,(int)4);
          aTri.GetPointIds().SetId((int)5,(int)5);
          aTriGrid = new vtkUnstructuredGrid();
          aTriGrid.Allocate((int)1,(int)1);
          aTriGrid.InsertNextCell((int)aTri.GetCellType(),(vtkIdList)aTri.GetPointIds());
          aTriGrid.SetPoints((vtkPoints)triPoints);
          aTriGrid.GetPointData().SetScalars((vtkDataArray)triScalars);
          aTriMapper = new vtkDataSetMapper();
          aTriMapper.SetInputData((vtkDataSet)aTriGrid);
          aTriMapper.ScalarVisibilityOff();
          aTriActor = new vtkActor();
          aTriActor.SetMapper((vtkMapper)aTriMapper);
          aTriActor.GetProperty().SetRepresentationToWireframe();
          aTriActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic quadrilateral[]
          quadPoints = new vtkPoints();
          quadPoints.SetNumberOfPoints((int)8);
          quadPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          quadPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0);
          quadPoints.InsertPoint((int)2,(double)1.0,(double)1.0,(double)0.0);
          quadPoints.InsertPoint((int)3,(double)0.0,(double)1.0,(double)0.0);
          quadPoints.InsertPoint((int)4,(double)0.5,(double)0.0,(double)0.0);
          quadPoints.InsertPoint((int)5,(double)1.0,(double)0.5,(double)0.0);
          quadPoints.InsertPoint((int)6,(double)0.5,(double)1.0,(double)0.0);
          quadPoints.InsertPoint((int)7,(double)0.0,(double)0.5,(double)0.0);
          quadScalars = new vtkFloatArray();
          quadScalars.SetNumberOfTuples((int)8);
          quadScalars.InsertValue((int)0,(float)0.0);
          quadScalars.InsertValue((int)1,(float)0.0);
          quadScalars.InsertValue((int)2,(float)1.0);
          quadScalars.InsertValue((int)3,(float)1.0);
          quadScalars.InsertValue((int)4,(float)1.0);
          quadScalars.InsertValue((int)5,(float)0.0);
          quadScalars.InsertValue((int)6,(float)0.0);
          quadScalars.InsertValue((int)7,(float)0.0);
          aQuad = new vtkQuadraticQuad();
          aQuad.GetPointIds().SetId((int)0,(int)0);
          aQuad.GetPointIds().SetId((int)1,(int)1);
          aQuad.GetPointIds().SetId((int)2,(int)2);
          aQuad.GetPointIds().SetId((int)3,(int)3);
          aQuad.GetPointIds().SetId((int)4,(int)4);
          aQuad.GetPointIds().SetId((int)5,(int)5);
          aQuad.GetPointIds().SetId((int)6,(int)6);
          aQuad.GetPointIds().SetId((int)7,(int)7);
          aQuadGrid = new vtkUnstructuredGrid();
          aQuadGrid.Allocate((int)1,(int)1);
          aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds());
          aQuadGrid.SetPoints((vtkPoints)quadPoints);
          aQuadGrid.GetPointData().SetScalars((vtkDataArray)quadScalars);
          aQuadMapper = new vtkDataSetMapper();
          aQuadMapper.SetInputData((vtkDataSet)aQuadGrid);
          aQuadMapper.ScalarVisibilityOff();
          aQuadActor = new vtkActor();
          aQuadActor.SetMapper((vtkMapper)aQuadMapper);
          aQuadActor.GetProperty().SetRepresentationToWireframe();
          aQuadActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic tetrahedron[]
          tetPoints = new vtkPoints();
          tetPoints.SetNumberOfPoints((int)10);
          tetPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          tetPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0);
          tetPoints.InsertPoint((int)2,(double)0.5,(double)0.8,(double)0.0);
          tetPoints.InsertPoint((int)3,(double)0.5,(double)0.4,(double)1.0);
          tetPoints.InsertPoint((int)4,(double)0.5,(double)0.0,(double)0.0);
          tetPoints.InsertPoint((int)5,(double)0.75,(double)0.4,(double)0.0);
          tetPoints.InsertPoint((int)6,(double)0.25,(double)0.4,(double)0.0);
          tetPoints.InsertPoint((int)7,(double)0.25,(double)0.2,(double)0.5);
          tetPoints.InsertPoint((int)8,(double)0.75,(double)0.2,(double)0.5);
          tetPoints.InsertPoint((int)9,(double)0.50,(double)0.6,(double)0.5);
          tetScalars = new vtkFloatArray();
          tetScalars.SetNumberOfTuples((int)10);
          tetScalars.InsertValue((int)0,(float)1.0);
          tetScalars.InsertValue((int)1,(float)1.0);
          tetScalars.InsertValue((int)2,(float)1.0);
          tetScalars.InsertValue((int)3,(float)1.0);
          tetScalars.InsertValue((int)4,(float)0.0);
          tetScalars.InsertValue((int)5,(float)0.0);
          tetScalars.InsertValue((int)6,(float)0.0);
          tetScalars.InsertValue((int)7,(float)0.0);
          tetScalars.InsertValue((int)8,(float)0.0);
          tetScalars.InsertValue((int)9,(float)0.0);
          aTet = new vtkQuadraticTetra();
          aTet.GetPointIds().SetId((int)0,(int)0);
          aTet.GetPointIds().SetId((int)1,(int)1);
          aTet.GetPointIds().SetId((int)2,(int)2);
          aTet.GetPointIds().SetId((int)3,(int)3);
          aTet.GetPointIds().SetId((int)4,(int)4);
          aTet.GetPointIds().SetId((int)5,(int)5);
          aTet.GetPointIds().SetId((int)6,(int)6);
          aTet.GetPointIds().SetId((int)7,(int)7);
          aTet.GetPointIds().SetId((int)8,(int)8);
          aTet.GetPointIds().SetId((int)9,(int)9);
          aTetGrid = new vtkUnstructuredGrid();
          aTetGrid.Allocate((int)1,(int)1);
          aTetGrid.InsertNextCell((int)aTet.GetCellType(),(vtkIdList)aTet.GetPointIds());
          aTetGrid.SetPoints((vtkPoints)tetPoints);
          aTetGrid.GetPointData().SetScalars((vtkDataArray)tetScalars);
          aTetMapper = new vtkDataSetMapper();
          aTetMapper.SetInputData((vtkDataSet)aTetGrid);
          aTetMapper.ScalarVisibilityOff();
          aTetActor = new vtkActor();
          aTetActor.SetMapper((vtkMapper)aTetMapper);
          aTetActor.GetProperty().SetRepresentationToWireframe();
          aTetActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic hexahedron[]
          hexPoints = new vtkPoints();
          hexPoints.SetNumberOfPoints((int)20);
          hexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          hexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          hexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          hexPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          hexPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          hexPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          hexPoints.InsertPoint((int)6,(double)1,(double)1,(double)1);
          hexPoints.InsertPoint((int)7,(double)0,(double)1,(double)1);
          hexPoints.InsertPoint((int)8,(double)0.5,(double)0,(double)0);
          hexPoints.InsertPoint((int)9,(double)1,(double)0.5,(double)0);
          hexPoints.InsertPoint((int)10,(double)0.5,(double)1,(double)0);
          hexPoints.InsertPoint((int)11,(double)0,(double)0.5,(double)0);
          hexPoints.InsertPoint((int)12,(double)0.5,(double)0,(double)1);
          hexPoints.InsertPoint((int)13,(double)1,(double)0.5,(double)1);
          hexPoints.InsertPoint((int)14,(double)0.5,(double)1,(double)1);
          hexPoints.InsertPoint((int)15,(double)0,(double)0.5,(double)1);
          hexPoints.InsertPoint((int)16,(double)0,(double)0,(double)0.5);
          hexPoints.InsertPoint((int)17,(double)1,(double)0,(double)0.5);
          hexPoints.InsertPoint((int)18,(double)1,(double)1,(double)0.5);
          hexPoints.InsertPoint((int)19,(double)0,(double)1,(double)0.5);
          hexScalars = new vtkFloatArray();
          hexScalars.SetNumberOfTuples((int)20);
          hexScalars.InsertValue((int)0,(float)1.0);
          hexScalars.InsertValue((int)1,(float)1.0);
          hexScalars.InsertValue((int)2,(float)1.0);
          hexScalars.InsertValue((int)3,(float)1.0);
          hexScalars.InsertValue((int)4,(float)1.0);
          hexScalars.InsertValue((int)5,(float)1.0);
          hexScalars.InsertValue((int)6,(float)1.0);
          hexScalars.InsertValue((int)7,(float)1.0);
          hexScalars.InsertValue((int)8,(float)0.0);
          hexScalars.InsertValue((int)9,(float)0.0);
          hexScalars.InsertValue((int)10,(float)0.0);
          hexScalars.InsertValue((int)11,(float)0.0);
          hexScalars.InsertValue((int)12,(float)0.0);
          hexScalars.InsertValue((int)13,(float)0.0);
          hexScalars.InsertValue((int)14,(float)0.0);
          hexScalars.InsertValue((int)15,(float)0.0);
          hexScalars.InsertValue((int)16,(float)0.0);
          hexScalars.InsertValue((int)17,(float)0.0);
          hexScalars.InsertValue((int)18,(float)0.0);
          hexScalars.InsertValue((int)19,(float)0.0);
          aHex = new vtkQuadraticHexahedron();
          aHex.GetPointIds().SetId((int)0,(int)0);
          aHex.GetPointIds().SetId((int)1,(int)1);
          aHex.GetPointIds().SetId((int)2,(int)2);
          aHex.GetPointIds().SetId((int)3,(int)3);
          aHex.GetPointIds().SetId((int)4,(int)4);
          aHex.GetPointIds().SetId((int)5,(int)5);
          aHex.GetPointIds().SetId((int)6,(int)6);
          aHex.GetPointIds().SetId((int)7,(int)7);
          aHex.GetPointIds().SetId((int)8,(int)8);
          aHex.GetPointIds().SetId((int)9,(int)9);
          aHex.GetPointIds().SetId((int)10,(int)10);
          aHex.GetPointIds().SetId((int)11,(int)11);
          aHex.GetPointIds().SetId((int)12,(int)12);
          aHex.GetPointIds().SetId((int)13,(int)13);
          aHex.GetPointIds().SetId((int)14,(int)14);
          aHex.GetPointIds().SetId((int)15,(int)15);
          aHex.GetPointIds().SetId((int)16,(int)16);
          aHex.GetPointIds().SetId((int)17,(int)17);
          aHex.GetPointIds().SetId((int)18,(int)18);
          aHex.GetPointIds().SetId((int)19,(int)19);
          aHexGrid = new vtkUnstructuredGrid();
          aHexGrid.Allocate((int)1,(int)1);
          aHexGrid.InsertNextCell((int)aHex.GetCellType(),(vtkIdList)aHex.GetPointIds());
          aHexGrid.SetPoints((vtkPoints)hexPoints);
          aHexGrid.GetPointData().SetScalars((vtkDataArray)hexScalars);
          aHexMapper = new vtkDataSetMapper();
          aHexMapper.SetInputData((vtkDataSet)aHexGrid);
          aHexMapper.ScalarVisibilityOff();
          aHexActor = new vtkActor();
          aHexActor.SetMapper((vtkMapper)aHexMapper);
          aHexActor.GetProperty().SetRepresentationToWireframe();
          aHexActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic wedge[]
          wedgePoints = new vtkPoints();
          wedgePoints.SetNumberOfPoints((int)15);
          wedgePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          wedgePoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          wedgePoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          wedgePoints.InsertPoint((int)3,(double)0,(double)0,(double)1);
          wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)1);
          wedgePoints.InsertPoint((int)5,(double)0,(double)1,(double)1);
          wedgePoints.InsertPoint((int)6,(double)0.5,(double)0,(double)0);
          wedgePoints.InsertPoint((int)7,(double)0.5,(double)0.5,(double)0);
          wedgePoints.InsertPoint((int)8,(double)0,(double)0.5,(double)0);
          wedgePoints.InsertPoint((int)9,(double)0.5,(double)0,(double)1);
          wedgePoints.InsertPoint((int)10,(double)0.5,(double)0.5,(double)1);
          wedgePoints.InsertPoint((int)11,(double)0,(double)0.5,(double)1);
          wedgePoints.InsertPoint((int)12,(double)0,(double)0,(double)0.5);
          wedgePoints.InsertPoint((int)13,(double)1,(double)0,(double)0.5);
          wedgePoints.InsertPoint((int)14,(double)0,(double)1,(double)0.5);
          wedgeScalars = new vtkFloatArray();
          wedgeScalars.SetNumberOfTuples((int)15);
          wedgeScalars.InsertValue((int)0,(float)1.0);
          wedgeScalars.InsertValue((int)1,(float)1.0);
          wedgeScalars.InsertValue((int)2,(float)1.0);
          wedgeScalars.InsertValue((int)3,(float)1.0);
          wedgeScalars.InsertValue((int)4,(float)1.0);
          wedgeScalars.InsertValue((int)5,(float)1.0);
          wedgeScalars.InsertValue((int)6,(float)1.0);
          wedgeScalars.InsertValue((int)7,(float)1.0);
          wedgeScalars.InsertValue((int)8,(float)0.0);
          wedgeScalars.InsertValue((int)9,(float)0.0);
          wedgeScalars.InsertValue((int)10,(float)0.0);
          wedgeScalars.InsertValue((int)11,(float)0.0);
          wedgeScalars.InsertValue((int)12,(float)0.0);
          wedgeScalars.InsertValue((int)13,(float)0.0);
          wedgeScalars.InsertValue((int)14,(float)0.0);
          aWedge = new vtkQuadraticWedge();
          aWedge.GetPointIds().SetId((int)0,(int)0);
          aWedge.GetPointIds().SetId((int)1,(int)1);
          aWedge.GetPointIds().SetId((int)2,(int)2);
          aWedge.GetPointIds().SetId((int)3,(int)3);
          aWedge.GetPointIds().SetId((int)4,(int)4);
          aWedge.GetPointIds().SetId((int)5,(int)5);
          aWedge.GetPointIds().SetId((int)6,(int)6);
          aWedge.GetPointIds().SetId((int)7,(int)7);
          aWedge.GetPointIds().SetId((int)8,(int)8);
          aWedge.GetPointIds().SetId((int)9,(int)9);
          aWedge.GetPointIds().SetId((int)10,(int)10);
          aWedge.GetPointIds().SetId((int)11,(int)11);
          aWedge.GetPointIds().SetId((int)12,(int)12);
          aWedge.GetPointIds().SetId((int)13,(int)13);
          aWedge.GetPointIds().SetId((int)14,(int)14);
          aWedgeGrid = new vtkUnstructuredGrid();
          aWedgeGrid.Allocate((int)1,(int)1);
          aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds());
          aWedgeGrid.SetPoints((vtkPoints)wedgePoints);
          aWedgeGrid.GetPointData().SetScalars((vtkDataArray)wedgeScalars);
          wedgeContours = new vtkClipDataSet();
          wedgeContours.SetInputData((vtkDataObject)aWedgeGrid);
          wedgeContours.SetValue((double)0.5);
          aWedgeContourMapper = new vtkDataSetMapper();
          aWedgeContourMapper.SetInputConnection((vtkAlgorithmOutput)wedgeContours.GetOutputPort());
          aWedgeContourMapper.ScalarVisibilityOff();
          aWedgeMapper = new vtkDataSetMapper();
          aWedgeMapper.SetInputData((vtkDataSet)aWedgeGrid);
          aWedgeMapper.ScalarVisibilityOff();
          aWedgeActor = new vtkActor();
          aWedgeActor.SetMapper((vtkMapper)aWedgeMapper);
          aWedgeActor.GetProperty().SetRepresentationToWireframe();
          aWedgeActor.GetProperty().SetAmbient((double)1.0);
          aWedgeContourActor = new vtkActor();
          aWedgeContourActor.SetMapper((vtkMapper)aWedgeContourMapper);
          aWedgeContourActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic pyramid[]
          pyraPoints = new vtkPoints();
          pyraPoints.SetNumberOfPoints((int)13);
          pyraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pyraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pyraPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          pyraPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          pyraPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          pyraPoints.InsertPoint((int)5,(double)0.5,(double)0,(double)0);
          pyraPoints.InsertPoint((int)6,(double)1,(double)0.5,(double)0);
          pyraPoints.InsertPoint((int)7,(double)0.5,(double)1,(double)0);
          pyraPoints.InsertPoint((int)8,(double)0,(double)0.5,(double)0);
          pyraPoints.InsertPoint((int)9,(double)0,(double)0,(double)0.5);
          pyraPoints.InsertPoint((int)10,(double)0.5,(double)0,(double)0.5);
          pyraPoints.InsertPoint((int)11,(double)0.5,(double)0.5,(double)0.5);
          pyraPoints.InsertPoint((int)12,(double)0,(double)0.5,(double)0.5);
          pyraScalars = new vtkFloatArray();
          pyraScalars.SetNumberOfTuples((int)13);
          pyraScalars.InsertValue((int)0,(float)1.0);
          pyraScalars.InsertValue((int)1,(float)1.0);
          pyraScalars.InsertValue((int)2,(float)1.0);
          pyraScalars.InsertValue((int)3,(float)1.0);
          pyraScalars.InsertValue((int)4,(float)1.0);
          pyraScalars.InsertValue((int)5,(float)1.0);
          pyraScalars.InsertValue((int)6,(float)1.0);
          pyraScalars.InsertValue((int)7,(float)1.0);
          pyraScalars.InsertValue((int)8,(float)0.0);
          pyraScalars.InsertValue((int)9,(float)0.0);
          pyraScalars.InsertValue((int)10,(float)0.0);
          pyraScalars.InsertValue((int)11,(float)0.0);
          pyraScalars.InsertValue((int)12,(float)0.0);
          aPyramid = new vtkQuadraticPyramid();
          aPyramid.GetPointIds().SetId((int)0,(int)0);
          aPyramid.GetPointIds().SetId((int)1,(int)1);
          aPyramid.GetPointIds().SetId((int)2,(int)2);
          aPyramid.GetPointIds().SetId((int)3,(int)3);
          aPyramid.GetPointIds().SetId((int)4,(int)4);
          aPyramid.GetPointIds().SetId((int)5,(int)5);
          aPyramid.GetPointIds().SetId((int)6,(int)6);
          aPyramid.GetPointIds().SetId((int)7,(int)7);
          aPyramid.GetPointIds().SetId((int)8,(int)8);
          aPyramid.GetPointIds().SetId((int)9,(int)9);
          aPyramid.GetPointIds().SetId((int)10,(int)10);
          aPyramid.GetPointIds().SetId((int)11,(int)11);
          aPyramid.GetPointIds().SetId((int)12,(int)12);
          aPyramidGrid = new vtkUnstructuredGrid();
          aPyramidGrid.Allocate((int)1,(int)1);
          aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds());
          aPyramidGrid.SetPoints((vtkPoints)pyraPoints);
          aPyramidGrid.GetPointData().SetScalars((vtkDataArray)pyraScalars);
          pyraContours = new vtkClipDataSet();
          pyraContours.SetInputData((vtkDataObject)aPyramidGrid);
          pyraContours.SetValue((double)0.5);
          aPyramidContourMapper = new vtkDataSetMapper();
          aPyramidContourMapper.SetInputConnection((vtkAlgorithmOutput)pyraContours.GetOutputPort());
          aPyramidContourMapper.ScalarVisibilityOff();
          aPyramidMapper = new vtkDataSetMapper();
          aPyramidMapper.SetInputData((vtkDataSet)aPyramidGrid);
          aPyramidMapper.ScalarVisibilityOff();
          aPyramidActor = new vtkActor();
          aPyramidActor.SetMapper((vtkMapper)aPyramidMapper);
          aPyramidActor.GetProperty().SetRepresentationToWireframe();
          aPyramidActor.GetProperty().SetAmbient((double)1.0);
          aPyramidContourActor = new vtkActor();
          aPyramidContourActor.SetMapper((vtkMapper)aPyramidContourMapper);
          aPyramidContourActor.GetProperty().SetAmbient((double)1.0);
          // Create the rendering related stuff.[]
          // Since some of our actors are a single vertex, we need to remove all[]
          // cullers so the single vertex actors will render[]
          ren1 = vtkRenderer.New();
          ren1.GetCullers().RemoveAllItems();
          renWin = vtkRenderWindow.New();
          renWin.SetMultiSamples(0);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          ren1.SetBackground((double).1,(double).2,(double).3);
          renWin.SetSize((int)400,(int)200);
          // specify properties[]
          ren1.AddActor((vtkProp)aEdgeActor);
          ren1.AddActor((vtkProp)aTriActor);
          ren1.AddActor((vtkProp)aQuadActor);
          ren1.AddActor((vtkProp)aTetActor);
          ren1.AddActor((vtkProp)aHexActor);
          ren1.AddActor((vtkProp)aWedgeActor);
          ren1.AddActor((vtkProp)aPyramidActor);
          // places everyone!![]
          aTriActor.AddPosition((double)2,(double)0,(double)0);
          aQuadActor.AddPosition((double)4,(double)0,(double)0);
          aTetActor.AddPosition((double)6,(double)0,(double)0);
          aHexActor.AddPosition((double)8,(double)0,(double)0);
          aWedgeActor.AddPosition((double)10,(double)0,(double)0);
          aPyramidActor.AddPosition((double)12,(double)0,(double)0);
          BuildBackdrop(-1, 15, -1, 4, -1, 2, .1);
          ren1.AddActor((vtkProp)base1);
          base1.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
          ren1.AddActor((vtkProp)left);
          left.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
          ren1.AddActor((vtkProp)back);
          back.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Dolly((double)2.5);
          ren1.ResetCameraClippingRange();
          renWin.Render();
          // create a little scorecard above each of the cells. These are displayed[]
          // if a ray cast hits the cell, otherwise they are not shown.[]
          pm = new vtkPlaneSource();
          pm.SetXResolution((int)1);
          pm.SetYResolution((int)1);
          pmapper = vtkPolyDataMapper.New();
          pmapper.SetInputConnection((vtkAlgorithmOutput)pm.GetOutputPort());
          // now try intersecting rays with the cell[]
          cellPicker = new vtkCellPicker();
          edgeCheck = new vtkActor();
          edgeCheck.SetMapper((vtkMapper)pmapper);
          edgeCheck.AddPosition((double)0.5,(double)2.5,(double)0);
          cellPicker.Pick((double)87,(double)71,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)edgeCheck);
        }

          triCheck = new vtkActor();
          triCheck.SetMapper((vtkMapper)pmapper);
          triCheck.AddPosition((double)2.5,(double)2.5,(double)0);
          cellPicker.Pick((double)139,(double)72,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)triCheck);
        }

          quadCheck = new vtkActor();
          quadCheck.SetMapper((vtkMapper)pmapper);
          quadCheck.AddPosition((double)4.5,(double)2.5,(double)0);
          cellPicker.Pick((double)192,(double)78,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)quadCheck);
        }

          tetCheck = new vtkActor();
          tetCheck.SetMapper((vtkMapper)pmapper);
          tetCheck.AddPosition((double)6.5,(double)2.5,(double)0);
          cellPicker.Pick((double)233,(double)70,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)tetCheck);
        }

          hexCheck = new vtkActor();
          hexCheck.SetMapper((vtkMapper)pmapper);
          hexCheck.AddPosition((double)8.5,(double)2.5,(double)0);
          cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)hexCheck);
        }

          wedgeCheck = new vtkActor();
          wedgeCheck.SetMapper((vtkMapper)pmapper);
          wedgeCheck.AddPosition((double)10.5,(double)2.5,(double)0);
          cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)wedgeCheck);
        }

          pyraCheck = new vtkActor();
          pyraCheck.SetMapper((vtkMapper)pmapper);
          pyraCheck.AddPosition((double)12.5,(double)2.5,(double)0);
          cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)pyraCheck);
        }

          // render the image[]
          //[]
          iren.Initialize();

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVlabeledContours(String [] argv)
    {
        //Prefix Content is: ""

          // demonstrate labeling of contour with scalar value[]
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.SetMultiSamples(0);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // Read a slice and contour it[]
          v16 = new vtkVolume16Reader();
          v16.SetDataDimensions((int)64,(int)64);
          v16.GetOutput().SetOrigin((double)0.0,(double)0.0,(double)0.0);
          v16.SetDataByteOrderToLittleEndian();
          v16.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter");
          v16.SetImageRange((int)45,(int)45);
          v16.SetDataSpacing((double)3.2,(double)3.2,(double)1.5);
          iso = new vtkContourFilter();
          iso.SetInputConnection((vtkAlgorithmOutput)v16.GetOutputPort());
          iso.GenerateValues((int)6,(double)500,(double)1150);
          iso.Update();
          numPts = iso.GetOutput().GetNumberOfPoints();
          isoMapper = vtkPolyDataMapper.New();
          isoMapper.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
          isoMapper.ScalarVisibilityOn();
          isoMapper.SetScalarRange((double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[1]);
          isoActor = new vtkActor();
          isoActor.SetMapper((vtkMapper)isoMapper);
          // Subsample the points and label them[]
          mask = new vtkMaskPoints();
          mask.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
          mask.SetOnRatio((int)(numPts/50));
          mask.SetMaximumNumberOfPoints((int)50);
          mask.RandomModeOn();
          // Create labels for points - only show visible points[]
          visPts = new vtkSelectVisiblePoints();
          visPts.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort());
          visPts.SetRenderer((vtkRenderer)ren1);
          ldm = new vtkLabeledDataMapper();
          ldm.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort());
          //    ldm SetLabelFormat "%g"[]
          ldm.SetLabelModeToLabelScalars();
          tprop = ldm.GetLabelTextProperty();
          tprop.SetFontFamilyToArial();
          tprop.SetFontSize((int)10);
          tprop.SetColor((double)1,(double)0,(double)0);
          contourLabels = new vtkActor2D();
          contourLabels.SetMapper((vtkMapper2D)ldm);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor2D((vtkProp)isoActor);
          ren1.AddActor2D((vtkProp)contourLabels);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)500,(int)500);
          renWin.Render();
          ren1.GetActiveCamera().Zoom((double)1.5);
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
        static void PrintImage(string Ipath)
        {
            vtkDICOMImageReader reader = vtkDICOMImageReader.New();

            reader.SetDirectoryName(Ipath);
            reader.Update();
            X = reader.GetWidth();
            Y = reader.GetHeight();
            Z = reader.GetPixelSpacing();
            Console.WriteLine(X * Z[0]);
            Console.WriteLine(Y * Z[1]);
            Console.WriteLine(Z[2]);

            // Visualize
            _ImageViewer = vtkImageViewer2.New();
            _ImageViewer.SetInputConnection(reader.GetOutputPort());

            // Get range of slices (min is the first index, max is the last index)
            _ImageViewer.GetSliceRange(ref _MinSlice, ref _MaxSlice);
            Console.WriteLine(_MinSlice);
            Console.WriteLine(_MaxSlice);

            _SliceStatusMapper = vtkTextMapper.New();
            _SliceStatusMapper.SetInputConnection(reader.GetOutputPort());

            vtkActor2D sliceStatusActor = vtkActor2D.New();

            sliceStatusActor.SetMapper(_SliceStatusMapper);

            vtkRenderWindow renderWindow = vtkRenderWindow.New();

            //Display in full screen
            renderWindow.SetFullScreen(1);

            vtkInteractorStyleImage interactorStyle = vtkInteractorStyleImage.New();

            renderWindow.GetRenderers().InitTraversal();
            vtkRenderer ren;

            while ((ren = renderWindow.GetRenderers().GetNextItem()) != null)
            {
                renderWindow.AddRenderer(ren);
            }

            _ImageViewer.SetRenderWindow(renderWindow);
            _ImageViewer.GetRenderer().AddActor2D(sliceStatusActor);
            _ImageViewer.SetSlice(_Slice);
            _ColorLevel = 500;
            _ImageViewer.SetColorLevel(_BlackLevel);
            _ImageViewer.Render();
            Down(_period, 62);
            Backward(_period, 1);

            _ImageViewer.SetColorLevel(_ColorLevel);
            _ImageViewer.Render();
            System.Threading.Thread.Sleep(_layertime);  // delay

            iren = vtkRenderWindowInteractor.New();
            iren.SetRenderWindow(renderWindow);
            renderWindow.Render();

            //Start Timer
            InitTimer();
            iren.Start();

            if (reader != null)
            {
                reader.Dispose();
            }
            if (_ImageViewer != null)
            {
                _ImageViewer.Dispose();
            }
            if (_SliceStatusMapper != null)
            {
                _SliceStatusMapper.Dispose();
            }
            if (sliceStatusActor != null)
            {
                sliceStatusActor.Dispose();
            }
            if (renderWindow != null)
            {
                renderWindow.Dispose();
            }
            if (interactorStyle != null)
            {
                interactorStyle.Dispose();
            }
            if (ren != null)
            {
                ren.Dispose();
            }
            if (iren != null)
            {
                iren.Dispose();
            }
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVMatrixToTransform(String [] argv)
    {
        //Prefix Content is: ""

          // This example demonstrates how to use a matrix in place of a transfrom[]
          // via vtkMatrixToLinearTransform and vtkMatrixToHomogeneousTransform.[]
          // create a rendering window[]
          renWin = vtkRenderWindow.New();
          renWin.SetSize((int)600,(int)300);
          // set up first set of polydata[]
          p1 = new vtkPlaneSource();
          p1.SetOrigin((double)0.5,(double)0.508,(double)-0.5);
          p1.SetPoint1((double)-0.5,(double)0.508,(double)-0.5);
          p1.SetPoint2((double)0.5,(double)0.508,(double)0.5);
          p1.SetXResolution((int)5);
          p1.SetYResolution((int)5);
          p2 = new vtkPlaneSource();
          p2.SetOrigin((double)-0.508,(double)0.5,(double)-0.5);
          p2.SetPoint1((double)-0.508,(double)-0.5,(double)-0.5);
          p2.SetPoint2((double)-0.508,(double)0.5,(double)0.5);
          p2.SetXResolution((int)5);
          p2.SetYResolution((int)5);
          p3 = new vtkPlaneSource();
          p3.SetOrigin((double)-0.5,(double)-0.508,(double)-0.5);
          p3.SetPoint1((double)0.5,(double)-0.508,(double)-0.5);
          p3.SetPoint2((double)-0.5,(double)-0.508,(double)0.5);
          p3.SetXResolution((int)5);
          p3.SetYResolution((int)5);
          p4 = new vtkPlaneSource();
          p4.SetOrigin((double)0.508,(double)-0.5,(double)-0.5);
          p4.SetPoint1((double)0.508,(double)0.5,(double)-0.5);
          p4.SetPoint2((double)0.508,(double)-0.5,(double)0.5);
          p4.SetXResolution((int)5);
          p4.SetYResolution((int)5);
          p5 = new vtkPlaneSource();
          p5.SetOrigin((double)0.5,(double)0.5,(double)-0.508);
          p5.SetPoint1((double)0.5,(double)-0.5,(double)-0.508);
          p5.SetPoint2((double)-0.5,(double)0.5,(double)-0.508);
          p5.SetXResolution((int)5);
          p5.SetYResolution((int)5);
          p6 = new vtkPlaneSource();
          p6.SetOrigin((double)0.5,(double)0.5,(double)0.508);
          p6.SetPoint1((double)-0.5,(double)0.5,(double)0.508);
          p6.SetPoint2((double)0.5,(double)-0.5,(double)0.508);
          p6.SetXResolution((int)5);
          p6.SetYResolution((int)5);
          // append together[]
          ap = new vtkAppendPolyData();
          ap.AddInputConnection(p1.GetOutputPort());
          ap.AddInputConnection(p2.GetOutputPort());
          ap.AddInputConnection(p3.GetOutputPort());
          ap.AddInputConnection(p4.GetOutputPort());
          ap.AddInputConnection(p5.GetOutputPort());
          ap.AddInputConnection(p6.GetOutputPort());
          //--------------------------[]
          // linear transform matrix[]
          t1 = new vtkMatrixToLinearTransform();
          m1 = new vtkMatrix4x4();
          t1.SetInput((vtkMatrix4x4)m1);
          m1.SetElement((int)0,(int)0,(double)1.127631);
          m1.SetElement((int)0,(int)1,(double)0.205212);
          m1.SetElement((int)0,(int)2,(double)-0.355438);
          m1.SetElement((int)1,(int)0,(double)0.000000);
          m1.SetElement((int)1,(int)1,(double)0.692820);
          m1.SetElement((int)1,(int)2,(double)0.400000);
          m1.SetElement((int)2,(int)0,(double)0.200000);
          m1.SetElement((int)2,(int)1,(double)-0.469846);
          m1.SetElement((int)2,(int)2,(double)0.813798);
          f11 = new vtkTransformPolyDataFilter();
          f11.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f11.SetTransform((vtkAbstractTransform)t1);
          m11 = new vtkDataSetMapper();
          m11.SetInputConnection((vtkAlgorithmOutput)f11.GetOutputPort());
          a11 = new vtkActor();
          a11.SetMapper((vtkMapper)m11);
          a11.GetProperty().SetColor((double)1,(double)0,(double)0);
          a11.GetProperty().SetRepresentationToWireframe();
          ren11 = vtkRenderer.New();
          ren11.SetViewport((double)0.0,(double)0.5,(double)0.25,(double)1.0);
          ren11.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren11.AddActor((vtkProp)a11);
          renWin.AddRenderer((vtkRenderer)ren11);
          // inverse identity transform[]
          f12 = new vtkTransformPolyDataFilter();
          f12.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f12.SetTransform((vtkAbstractTransform)t1.GetInverse());
          m12 = new vtkDataSetMapper();
          m12.SetInputConnection((vtkAlgorithmOutput)f12.GetOutputPort());
          a12 = new vtkActor();
          a12.SetMapper((vtkMapper)m12);
          a12.GetProperty().SetColor((double)0.9,(double)0.9,(double)0);
          a12.GetProperty().SetRepresentationToWireframe();
          ren12 = vtkRenderer.New();
          ren12.SetViewport((double)0.0,(double)0.0,(double)0.25,(double)0.5);
          ren12.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren12.AddActor((vtkProp)a12);
          renWin.AddRenderer((vtkRenderer)ren12);
          //--------------------------[]
          // perspective transform matrix[]
          m2 = new vtkMatrix4x4();
          m2.SetElement((int)3,(int)0,(double)-0.11);
          m2.SetElement((int)3,(int)1,(double)0.3);
          m2.SetElement((int)3,(int)2,(double)0.2);
          t2 = new vtkMatrixToHomogeneousTransform();
          t2.SetInput((vtkMatrix4x4)m2);
          f21 = new vtkTransformPolyDataFilter();
          f21.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f21.SetTransform((vtkAbstractTransform)t2);
          m21 = new vtkDataSetMapper();
          m21.SetInputConnection((vtkAlgorithmOutput)f21.GetOutputPort());
          a21 = new vtkActor();
          a21.SetMapper((vtkMapper)m21);
          a21.GetProperty().SetColor((double)1,(double)0,(double)0);
          a21.GetProperty().SetRepresentationToWireframe();
          ren21 = vtkRenderer.New();
          ren21.SetViewport((double)0.25,(double)0.5,(double)0.50,(double)1.0);
          ren21.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren21.AddActor((vtkProp)a21);
          renWin.AddRenderer((vtkRenderer)ren21);
          // inverse linear transform[]
          f22 = new vtkTransformPolyDataFilter();
          f22.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f22.SetTransform((vtkAbstractTransform)t2.GetInverse());
          m22 = new vtkDataSetMapper();
          m22.SetInputConnection((vtkAlgorithmOutput)f22.GetOutputPort());
          a22 = new vtkActor();
          a22.SetMapper((vtkMapper)m22);
          a22.GetProperty().SetColor((double)0.9,(double)0.9,(double)0);
          a22.GetProperty().SetRepresentationToWireframe();
          ren22 = vtkRenderer.New();
          ren22.SetViewport((double)0.25,(double)0.0,(double)0.50,(double)0.5);
          ren22.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren22.AddActor((vtkProp)a22);
          renWin.AddRenderer((vtkRenderer)ren22);
          //--------------------------[]
          // linear concatenation - should end up with identity here[]
          t3 = new vtkTransform();
          t3.Concatenate((vtkLinearTransform)t1);
          t3.Concatenate((vtkLinearTransform)t1.GetInverse());
          f31 = new vtkTransformPolyDataFilter();
          f31.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f31.SetTransform((vtkAbstractTransform)t3);
          m31 = new vtkDataSetMapper();
          m31.SetInputConnection((vtkAlgorithmOutput)f31.GetOutputPort());
          a31 = new vtkActor();
          a31.SetMapper((vtkMapper)m31);
          a31.GetProperty().SetColor((double)1,(double)0,(double)0);
          a31.GetProperty().SetRepresentationToWireframe();
          ren31 = vtkRenderer.New();
          ren31.SetViewport((double)0.50,(double)0.5,(double)0.75,(double)1.0);
          ren31.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren31.AddActor((vtkProp)a31);
          renWin.AddRenderer((vtkRenderer)ren31);
          // inverse linear transform[]
          f32 = new vtkTransformPolyDataFilter();
          f32.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f32.SetTransform((vtkAbstractTransform)t3.GetInverse());
          m32 = new vtkDataSetMapper();
          m32.SetInputConnection((vtkAlgorithmOutput)f32.GetOutputPort());
          a32 = new vtkActor();
          a32.SetMapper((vtkMapper)m32);
          a32.GetProperty().SetColor((double)0.9,(double)0.9,(double)0);
          a32.GetProperty().SetRepresentationToWireframe();
          ren32 = vtkRenderer.New();
          ren32.SetViewport((double)0.5,(double)0.0,(double)0.75,(double)0.5);
          ren32.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren32.AddActor((vtkProp)a32);
          renWin.AddRenderer((vtkRenderer)ren32);
          //--------------------------[]
          // perspective transform concatenation[]
          t4 = new vtkPerspectiveTransform();
          t4.Concatenate((vtkHomogeneousTransform)t1);
          t4.Concatenate((vtkHomogeneousTransform)t2);
          t4.Concatenate((vtkHomogeneousTransform)t3);
          f41 = new vtkTransformPolyDataFilter();
          f41.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f41.SetTransform((vtkAbstractTransform)t4);
          m41 = new vtkDataSetMapper();
          m41.SetInputConnection((vtkAlgorithmOutput)f41.GetOutputPort());
          a41 = new vtkActor();
          a41.SetMapper((vtkMapper)m41);
          a41.GetProperty().SetColor((double)1,(double)0,(double)0);
          a41.GetProperty().SetRepresentationToWireframe();
          ren41 = vtkRenderer.New();
          ren41.SetViewport((double)0.75,(double)0.5,(double)1.0,(double)1.0);
          ren41.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren41.AddActor((vtkProp)a41);
          renWin.AddRenderer((vtkRenderer)ren41);
          // inverse of transform concatenation[]
          f42 = new vtkTransformPolyDataFilter();
          f42.SetInputConnection((vtkAlgorithmOutput)ap.GetOutputPort());
          f42.SetTransform((vtkAbstractTransform)t4.GetInverse());
          m42 = new vtkDataSetMapper();
          m42.SetInputConnection((vtkAlgorithmOutput)f42.GetOutputPort());
          a42 = new vtkActor();
          a42.SetMapper((vtkMapper)m42);
          a42.GetProperty().SetColor((double)0.9,(double)0.9,(double)0);
          a42.GetProperty().SetRepresentationToWireframe();
          ren42 = vtkRenderer.New();
          ren42.SetViewport((double)0.75,(double)0.0,(double)1.0,(double)0.5);
          ren42.ResetCamera((double)-0.5,(double)0.5,(double)-0.5,(double)0.5,(double)-1,(double)1);
          ren42.AddActor((vtkProp)a42);
          renWin.AddRenderer((vtkRenderer)ren42);
          renWin.Render();

        //deleteAllVTKObjects();
    }
Beispiel #27
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyper(String [] argv)
    {
        //Prefix Content is: ""

          // Create the RenderWindow, Renderer and interactive renderer[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
          //[]
          // generate tensors[]
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)20,(int)20,(int)20);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          //[]
          // If the current directory is writable, then test the witers[]
          //[]
          try
          {
         channel = new StreamWriter("test.tmp");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          File.Delete("test.tmp");
          wSP = new vtkDataSetWriter();
          wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          wSP.SetFileName((string)"wSP.vtk");
          wSP.SetTensorsName((string)"pointload");
          wSP.SetScalarsName((string)"effective_stress");
          wSP.Write();
          rSP = new vtkDataSetReader();
          rSP.SetFileName((string)"wSP.vtk");
          rSP.SetTensorsName((string)"pointload");
          rSP.SetScalarsName((string)"effective_stress");
          rSP.Update();
          input = rSP.GetOutput();
          File.Delete("wSP.vtk");
        }
          else
        {
          input = ptLoad.GetOutput();
        }

          // Generate hyperstreamlines[]
          s1 = new vtkHyperStreamline();
          s1.SetInputData((vtkDataObject)input);
          s1.SetStartPosition((double)9,(double)9,(double)-9);
          s1.IntegrateMinorEigenvector();
          s1.SetMaximumPropagationDistance((double)18.0);
          s1.SetIntegrationStepLength((double)0.1);
          s1.SetStepLength((double)0.01);
          s1.SetRadius((double)0.25);
          s1.SetNumberOfSides((int)18);
          s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s1.Update();
          // Map hyperstreamlines[]
          lut = new vtkLogLookupTable();
          lut.SetHueRange((double).6667,(double)0.0);
          s1Mapper = vtkPolyDataMapper.New();
          s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
          s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
          ptLoad.Update();
          //force update for scalar range[]
          s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s1Actor = new vtkActor();
          s1Actor.SetMapper((vtkMapper)s1Mapper);
          s2 = new vtkHyperStreamline();
          s2.SetInputData((vtkDataObject)input);
          s2.SetStartPosition((double)-9,(double)-9,(double)-9);
          s2.IntegrateMinorEigenvector();
          s2.SetMaximumPropagationDistance((double)18.0);
          s2.SetIntegrationStepLength((double)0.1);
          s2.SetStepLength((double)0.01);
          s2.SetRadius((double)0.25);
          s2.SetNumberOfSides((int)18);
          s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s2.Update();
          s2Mapper = vtkPolyDataMapper.New();
          s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
          s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s2Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]);
          s2Actor = new vtkActor();
          s2Actor.SetMapper((vtkMapper)s2Mapper);
          s3 = new vtkHyperStreamline();
          s3.SetInputData((vtkDataObject)input);
          s3.SetStartPosition((double)9,(double)-9,(double)-9);
          s3.IntegrateMinorEigenvector();
          s3.SetMaximumPropagationDistance((double)18.0);
          s3.SetIntegrationStepLength((double)0.1);
          s3.SetStepLength((double)0.01);
          s3.SetRadius((double)0.25);
          s3.SetNumberOfSides((int)18);
          s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s3.Update();
          s3Mapper = vtkPolyDataMapper.New();
          s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
          s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s3Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],
          (double)((vtkDataSet)input).GetScalarRange()[1]);
          s3Actor = new vtkActor();
          s3Actor.SetMapper((vtkMapper)s3Mapper);
          s4 = new vtkHyperStreamline();
          s4.SetInputData((vtkDataObject)input);
          s4.SetStartPosition((double)-9,(double)9,(double)-9);
          s4.IntegrateMinorEigenvector();
          s4.SetMaximumPropagationDistance((double)18.0);
          s4.SetIntegrationStepLength((double)0.1);
          s4.SetStepLength((double)0.01);
          s4.SetRadius((double)0.25);
          s4.SetNumberOfSides((int)18);
          s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s4.Update();
          s4Mapper = vtkPolyDataMapper.New();
          s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
          s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s4Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]);
          s4Actor = new vtkActor();
          s4Actor.SetMapper((vtkMapper)s4Mapper);
          // plane for context[]
          //[]
          g = new vtkImageDataGeometryFilter();
          g.SetInputData((vtkDataObject)input);
          g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          g.Update();
          //for scalar range[]
          gm = vtkPolyDataMapper.New();
          gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
          gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
          ga = new vtkActor();
          ga.SetMapper((vtkMapper)gm);
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputData((vtkDataObject)input);
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor((vtkProp)s1Actor);
          ren1.AddActor((vtkProp)s2Actor);
          ren1.AddActor((vtkProp)s3Actor);
          ren1.AddActor((vtkProp)s4Actor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.AddActor((vtkProp)ga);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)300,(int)300);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        try
        {
          bool fail_on_image_diff = false;

          //Prefix Content is: ""
          int argc = 0;
          if (argv != null)
          {
        argc = argv.Length;
          }

          // setup some common things for testing[]
          vtkMath.RandomSeed(6);
          // create the testing class to do the work[]
          rtTester = new vtkTesting();
          for (int i = 1; i < argc; i++)
          {
        rtTester.AddArgument(argv[i]);

        if (argv[i] == "--fail-on-image-diff")
        {
          fail_on_image_diff = true;
        }
          }

          // string auto_path = "";
          //
          VTK_DATA_ROOT = rtTester.GetDataRoot();

          // load in the script[]
          if (0 == argv.Length)
          {
        test = GetTestNameInteractively();
          }
          else
          {
        test = argv[0];
          }

          //The class that we are about to execute the test in
          System.Type t = System.Type.GetType(test + "Class");
          if (null == t)
          {
        throw new System.ArgumentException(System.String.Format(
              "error: could not create a Type object for '{0}'...\n\n{1}\n{2}\n{3}\n{4}\n\n{5}\n\n",
              test + "Class",
              "Typo?",
              "Did you follow the C# test driver naming convention?",
              "Did you add the test to the CMakeLists.txt file?",
              "Did you reconfigure/rebuild after adding the test?",
              "Test 'method' name should equal 'file name without extension'... Test 'public class' name should be the same but with 'Class' appended..."
              ));
          }

          // set the default threshold, the Tcl script may change this[]
          threshold = -1;

          executeMethod(t, "Setthreshold", new object[] { threshold });
          executeMethod(t, "SetVTK_DATA_ROOT", new object[] { VTK_DATA_ROOT });

          //run the test
          executeMethod(t, test, new object[] { argv });

          tempRenderWindowInteractor = (vtkRenderWindowInteractor)executeMethod(t, "Getiren", new object[] { });
          tempRenderWindow = (vtkRenderWindow)executeMethod(t, "GetrenWin", new object[] { });
          tempViewer = (vtkObject)executeMethod(t, "Getviewer", new object[] { });
          tempw2i = (vtkWindowToImageFilter)executeMethod(t, "Getw2i", new object[] { });

          //update the threshold from what the test made it
          threshold = (int)executeMethod(t, "Getthreshold", new object[] { });
          if (tempRenderWindowInteractor != null)
          {
        tempRenderWindow.Render();
          }

          // run the event loop quickly to map any tkwidget windows[]
          // current directory[]
          rtResult = 0;
          if (fail_on_image_diff && rtTester.IsValidImageSpecified() != 0)
          {
        // look for a renderWindow ImageWindow or ImageViewer[]
        // first check for some common names[]
        if (tempRenderWindow != null)
        {
          rtTester.SetRenderWindow(tempRenderWindow);
          if ((threshold) == -1)
          {
            threshold = 10;
          }
        }
        else
        {
          if ((threshold) == -1)
          {
            threshold = 5;
          }
          if (tempViewer != null)
          {
            if (tempViewer.IsA("vtkImageViewer") != 0)
            {
              tempRenderWindow = ((vtkImageViewer)tempViewer).GetRenderWindow();
            }
            else if (tempViewer.IsA("vtkImageViewer2") != 0)
            {
              tempRenderWindow = ((vtkImageViewer2)tempViewer).GetRenderWindow();
            }
            else
            {
              throw new System.Exception("");
            }
            rtTester.SetRenderWindow(tempRenderWindow);

            if (tempViewer.IsA("vtkImageViewer") != 0)
            {
              ((vtkImageViewer)tempViewer).Render();
            }
            else if (tempViewer.IsA("vtkImageViewer2") != 0)
            {
              ((vtkImageViewer2)tempViewer).Render();
            }
          }
          else
          {
            tempRenderWindow = (vtkRenderWindow)executeMethod(t, "GetimgWin", new object[] { });
            if (tempRenderWindow != null)
            {
              rtTester.SetRenderWindow(tempRenderWindow);
              tempRenderWindow.Render();
            }
          }
        }

        if (tempRenderWindow == null)
        {
          throw new System.Exception("tempRenderWindow cannot be null for IsValidImageSpecified case...");
        }

        rtResult = rtTester.RegressionTest(threshold);
          }

          if (rtTester.IsInteractiveModeSpecified() != 0)
          {
        if (tempRenderWindowInteractor != null)
        {
          tempRenderWindowInteractor.Start();
        }
          }

          // Force other objects that may have holds on the render window
          // to let go:
          //
          rtTester.SetRenderWindow(null);
          if (null != tempw2i)
          {
        tempw2i.SetInput(null);
          }

          executeMethod(t, "deleteAllVTKObjects", new object[] { });
          deleteAllVTKObjects();

          // Force a garbage collection prior to exiting the test
          // so that any memory leaks reported are likely to be
          // *actual* leaks of some sort rather than false reports:
          //
          System.GC.Collect();
          System.GC.WaitForPendingFinalizers();

          // Fail the tests that have image diffs if fail_on_image_diff is on:
          //
          if (fail_on_image_diff && 0 == rtResult)
          {
        throw new System.Exception("error: image RegressionTest failed");
          }

          // Test finished without throwing any exceptions...
          // Therefore, it passed. Exit with a zero ExitCode.
          //
          System.Environment.ExitCode = 0;
        }
        catch (System.Exception exc)
        {
          // Catch anything, spit it out to the console so it can be captured
          // by ctest. Exit with a non-zero ExitCode.
          //
          System.Console.Error.WriteLine("================================================================================");
          System.Console.Error.WriteLine("");
          System.Console.Error.WriteLine("TclToCsScript C# test driver caught System.Exception:");
          System.Console.Error.WriteLine("");
          System.Console.Error.WriteLine("{0}", exc.ToString());
          System.Console.Error.WriteLine("");
          System.Console.Error.WriteLine("================================================================================");
          System.Console.Error.WriteLine("");
          System.Environment.ExitCode = 2345;
        }
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestExtractCTHPart(String [] argv)
    {
        //Prefix Content is: ""

          // we need to use composite data pipeline with multiblock datasets[]
          alg = new vtkAlgorithm();
          pip = new vtkCompositeDataPipeline();
          vtkAlgorithm.SetDefaultExecutivePrototype((vtkExecutive)pip);
          //skipping Delete pip
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          Ren1 = vtkRenderer.New();
          Ren1.SetBackground((double)0.33,(double)0.35,(double)0.43);
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)Ren1);
          renWin.SetSize((int)300,(int)300);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          pvTemp59 = new vtkXMLRectilinearGridReader();
          pvTemp59.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/cth.vtr");
          pvTemp59.UpdateInformation();
          pvTemp59.SetCellArrayStatus((string)"X Velocity",(int)0);
          pvTemp59.SetCellArrayStatus((string)"Y Velocity",(int)0);
          pvTemp59.SetCellArrayStatus((string)"Z Velocity",(int)0);
          pvTemp59.SetCellArrayStatus((string)"Mass for Armor Plate",(int)0);
          pvTemp59.SetCellArrayStatus((string)"Mass for Body, Nose",(int)0);
          pvTemp79 = new vtkExtractCTHPart();
          pvTemp79.SetInputConnection((vtkAlgorithmOutput)pvTemp59.GetOutputPort());
          pvTemp79.AddVolumeArrayName((string)"Volume Fraction for Armor Plate");
          pvTemp79.AddVolumeArrayName((string)"Volume Fraction for Body, Nose");
          pvTemp79.SetClipPlane(null);
          pvTemp104 = new vtkLookupTable();
          pvTemp104.SetNumberOfTableValues((int)256);
          pvTemp104.SetHueRange((double)0.6667,(double)0);
          pvTemp104.SetSaturationRange((double)1,(double)1);
          pvTemp104.SetValueRange((double)1,(double)1);
          pvTemp104.SetTableRange((double)0,(double)1);
          pvTemp104.SetVectorComponent((int)0);
          pvTemp104.Build();
          pvTemp87 = new vtkCompositePolyDataMapper();
          pvTemp87.SetInputConnection((vtkAlgorithmOutput)pvTemp79.GetOutputPort());
          pvTemp87.SetImmediateModeRendering((int)1);
          pvTemp87.SetScalarRange((double)0,(double)1);
          pvTemp87.UseLookupTableScalarRangeOn();
          pvTemp87.SetScalarVisibility((int)1);
          pvTemp87.SetScalarModeToUsePointFieldData();
          pvTemp87.SelectColorArray((string)"Part Index");
          pvTemp87.SetLookupTable((vtkScalarsToColors)pvTemp104);
          pvTemp88 = new vtkActor();
          pvTemp88.SetMapper((vtkMapper)pvTemp87);
          pvTemp88.GetProperty().SetRepresentationToSurface();
          pvTemp88.GetProperty().SetInterpolationToGouraud();
          pvTemp88.GetProperty().SetAmbient((double)0);
          pvTemp88.GetProperty().SetDiffuse((double)1);
          pvTemp88.GetProperty().SetSpecular((double)0);
          pvTemp88.GetProperty().SetSpecularPower((double)1);
          pvTemp88.GetProperty().SetSpecularColor((double)1,(double)1,(double)1);
          Ren1.AddActor((vtkProp)pvTemp88);
          renWin.Render();
          vtkAlgorithm.SetDefaultExecutivePrototype(null);

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVPlot3DScalars(String[] argv)
    {
        //Prefix Content is: ""

        //[]
        // All Plot3D scalar functions[]
        //[]
        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        renWin = vtkRenderWindow.New();
        renWin.SetMultiSamples(0);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        scalarLabels = "Density Pressure Temperature Enthalpy Internal_Energy Kinetic_Energy Velocity_Magnitude Stagnation_Energy Entropy Swirl";
        scalarFunctions = "100 110 120 130 140 144 153 163 170 184";
        camera = new vtkCamera();
        light = new vtkLight();
        math = new vtkMath();
        // All text actors will share the same text prop[]
        textProp = new vtkTextProperty();
        textProp.SetFontSize((int)10);
        textProp.SetFontFamilyToArial();
        textProp.SetColor((double)0, (double)0, (double)0);
        i = 0;
        foreach (string scalarFunction in scalarFunctions.Split(new char[] { ' ' }))
        {
            pl3d[getArrayIndex(scalarFunction)] = new vtkMultiBlockPLOT3DReader();
            pl3d[getArrayIndex(scalarFunction)].SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinxyz.bin");
            pl3d[getArrayIndex(scalarFunction)].SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinq.bin");
            pl3d[getArrayIndex(scalarFunction)].SetScalarFunctionNumber((int)(int)(Int32.Parse(scalarFunction)));
            pl3d[getArrayIndex(scalarFunction)].Update();

            plane[getArrayIndex(scalarFunction)] = new vtkStructuredGridGeometryFilter();
            plane[getArrayIndex(scalarFunction)].SetInputData((vtkDataSet)pl3d[getArrayIndex(scalarFunction)].GetOutput().GetBlock(0));
            plane[getArrayIndex(scalarFunction)].SetExtent((int)25, (int)25, (int)0, (int)100, (int)0, (int)100);

            mapper[getArrayIndex(scalarFunction)] = vtkPolyDataMapper.New();
            mapper[getArrayIndex(scalarFunction)].SetInputConnection((vtkAlgorithmOutput)plane[getArrayIndex(scalarFunction)].GetOutputPort());
            mapper[getArrayIndex(scalarFunction)].SetScalarRange((double)((vtkDataSet)pl3d[getArrayIndex(scalarFunction)].GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[0],
                (double)((vtkDataSet)pl3d[getArrayIndex(scalarFunction)].GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[1]);

            actor[getArrayIndex(scalarFunction)] = new vtkActor();
            actor[getArrayIndex(scalarFunction)].SetMapper((vtkMapper)mapper[getArrayIndex(scalarFunction)]);
            ren[getArrayIndex(scalarFunction)] = vtkRenderer.New();
            ren[getArrayIndex(scalarFunction)].SetBackground((double)0, (double)0, (double).5);
            ren[getArrayIndex(scalarFunction)].SetActiveCamera((vtkCamera)camera);
            ren[getArrayIndex(scalarFunction)].AddLight((vtkLight)light);
            renWin.AddRenderer(ren[getArrayIndex(scalarFunction)]);
            ren[getArrayIndex(scalarFunction)].SetBackground((double)vtkMath.Random((double).5, (double)1), (double)vtkMath.Random((double).5, (double)1), (double)vtkMath.Random((double).5, (double)1));
            ren[getArrayIndex(scalarFunction)].AddActor((vtkProp)actor[getArrayIndex(scalarFunction)]);

            textMapper[getArrayIndex(scalarFunction)] = new vtkTextMapper();
            textMapper[getArrayIndex(scalarFunction)].SetInput(scalarLabels.Split(new char[] { ' ' })[i]);
            textMapper[getArrayIndex(scalarFunction)].SetTextProperty((vtkTextProperty)textProp);

            text[getArrayIndex(scalarFunction)] = new vtkActor2D();
            text[getArrayIndex(scalarFunction)].SetMapper((vtkMapper2D)textMapper[getArrayIndex(scalarFunction)]);
            text[getArrayIndex(scalarFunction)].SetPosition((double)2, (double)3);

            ren[getArrayIndex(scalarFunction)].AddActor2D(text[getArrayIndex(scalarFunction)]);

            i = i + 1;

        }
        //[]
        // now layout renderers[]
        column = 1;
        row = 1;
        deltaX = 1.0 / 5.0;
        deltaY = 1.0 / 2.0;
        foreach (string scalarFunction in scalarFunctions.Split(new char[] { ' ' }))
        {
            ren[getArrayIndex(scalarFunction)].SetViewport((double)(column - 1) * deltaX, (double)(row - 1) * deltaY, (double)column * deltaX, (double)row * deltaY);
            column = column + 1;
            if ((column) > 5)
            {
                column = 1;
                row = row + 1;
            }
        }
        camera.SetViewUp((double)0, (double)1, (double)0);
        camera.SetFocalPoint((double)0, (double)0, (double)0);
        camera.SetPosition((double)1, (double)0, (double)0);
        ren[100].ResetCamera();
        camera.Dolly((double)1.25);
        ren[100].ResetCameraClippingRange();
        ren[110].ResetCameraClippingRange();
        ren[120].ResetCameraClippingRange();
        ren[130].ResetCameraClippingRange();
        ren[140].ResetCameraClippingRange();
        ren[144].ResetCameraClippingRange();
        ren[153].ResetCameraClippingRange();
        ren[163].ResetCameraClippingRange();
        ren[170].ResetCameraClippingRange();
        ren[184].ResetCameraClippingRange();

        light.SetPosition(camera.GetPosition()[0], camera.GetPosition()[1], camera.GetPosition()[2]);
        light.SetFocalPoint(camera.GetFocalPoint()[0], camera.GetFocalPoint()[1], camera.GetFocalPoint()[2]);

        renWin.SetSize(600, 180);
        renWin.Render();
        iren.Initialize();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Beispiel #31
0
        public void Coloring(int shft = 0)
        {
            //vtkFixedPointVolumeRayCastMapper texMapper = vtkFixedPointVolumeRayCastMapper.New();
            vtkSmartVolumeMapper texMapper = vtkSmartVolumeMapper.New();

            vol = vtkVolume.New();
            vtkColorTransferFunction ctf  = vtkColorTransferFunction.New();
            vtkPiecewiseFunction     spwf = vtkPiecewiseFunction.New();
            vtkPiecewiseFunction     gpwf = vtkPiecewiseFunction.New();

            texMapper.SetInputConnection(reader3D.GetOutputPort());

            //Set the color curve for the volume
            //ctf.AddHSVPoint(0, .67, .07, 1);
            //ctf.AddHSVPoint(94, .67, .07, 1);
            //ctf.AddHSVPoint(139, 0, 0, 0);
            //ctf.AddHSVPoint(160, .28, .047, 1);
            //ctf.AddHSVPoint(254, .38, .013, 1);

            ctf.AddRGBPoint(0.0, 0.0, 0.0, 0.0);
            ctf.AddRGBPoint(64.0, 1.0, 0.0, 0.0);
            ctf.AddRGBPoint(128.0, 0.0, 0.0, 1.0);
            ctf.AddRGBPoint(192.0, 0.0, 1.0, 0.0);
            ctf.AddRGBPoint(255.0, 0.0, 0.2, 0.0);

            //Set the opacity curve for the volume
            spwf.AddPoint(584 + shft, 0);
            spwf.AddPoint(651 + shft, .1);
            //spwf.AddPoint(255, 1);


            //spwf.AddPoint(4, 0);
            //spwf.AddPoint(51, .7);
            //spwf.AddPoint(155, 0.5);
            //spwf.AddPoint(255, 0.2);
            //spwf.AddPoint(1055, 0);


            //Set the gradient curve for the volume
            //gpwf.AddPoint(0, .2);
            gpwf.AddPoint(10, 1);
            gpwf.AddPoint(225, 0.5);
            gpwf.AddPoint(1235, 0.2);
            gpwf.AddPoint(3235, 0);

            vol.GetProperty().SetColor(ctf);
            vol.GetProperty().SetScalarOpacity(spwf);
            //vol.GetProperty().SetGradientOpacity(gpwf);

            vol.GetProperty().ShadeOn();
            vol.GetProperty().SetInterpolationTypeToLinear();

            vol.SetMapper(texMapper);

            //green background
            renderer3D.SetBackground(0.3, 0.6, 0.3);
            //Go through the Graphics Pipeline
            renderer3D.AddVolume(vol);

            renderWindow3D.Render();
        }
Beispiel #32
0
        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            // Create components of the rendering subsystem
            //
            vtkRenderer     ren1   = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
            vtkRenderWindow renWin = renderWindowControl1.RenderWindow;

            renWin.SetSize((int)paras.Height, (int)paras.Width);

            // Add the actors to the renderer, set the window size
            //
            vtkPoints      points  = vtkPoints.New();
            vtkCellArray   polys   = vtkCellArray.New();
            vtkFloatArray  scalars = vtkFloatArray.New();
            vtkLookupTable Luk     = vtkLookupTable.New();

            if (paras.Using3DTower == 1)
            {
                vtkActor   actor1  = new vtkActor();
                vtkActor2D actor2D = new vtkActor2D();
                if (paras.StageID != -1)
                {
                    if (paras.UsingEdges == 1)
                    {
                        MessageBox.Show("单元显示无法使用");
                    }
                    else
                    {
                        BasicVTKBuilder(ref actor1, ref points, ref polys, ref scalars, ref Luk, ref actor2D);
                        ren1.AddActor(actor1);
                        ren1.AddActor2D(actor2D);

                        vtkActor2D textActor = new vtkActor2D();
                        VTKInfoBuilder(ref textActor);
                        ren1.AddActor2D(textActor);
                    }
                }
                else
                {
                    if (paras.UsingEdges == 1)
                    {
                        ExtractEdgesVTKBuilderWithoutRunning(ref actor1, ref points, ref polys, ref scalars, ref Luk);
                    }
                    else
                    {
                        BasicVTKBuilderWithoutRunning(ref actor1, ref points, ref polys, ref scalars, ref Luk);
                    }
                    ren1.AddActor(actor1);
                }
            }

            if (paras.UsingVirtualHeater == 1)
            {
                //MessageBox.Show("!");
                vtkActor2D actor2 = VirtualHeaterVTKBuilder();
                ren1.AddActor(actor2);
            }


            renWin.Render();
            vtkCamera camera = ren1.GetActiveCamera();

            //camera.ParallelProjectionOn();
            //camera.Elevation(20);
            int[] camera_pos = new int[3];

            if (paras.globalEnv == 1)
            {
                camera_pos[1] = -70;
            }
            else
            {
                camera_pos[1] = -80;
            }

            if (paras.RotateAngle == 0)
            {
                camera_pos[1] = -camera_pos[1];
                camera_pos[0] = camera_pos[2] = 0;
                camera.SetRoll(-2);
            }
            else if (paras.RotateAngle == 180)
            {
                camera_pos[0] = camera_pos[2] = 0;
                camera.SetRoll(180);
            }
            else if (paras.RotateAngle == 90)
            {
                double r = (double)Math.Abs(camera_pos[1]);
                camera_pos[0] = (int)(-r * 0.707);
                camera_pos[1] = (int)(-r * 0.707);
                camera_pos[2] = 0;
                camera.SetRoll(225);
            }
            else if (paras.RotateAngle == 270)
            {
                double r = (double)Math.Abs(camera_pos[1]);
                camera_pos[0] = (int)(r * 0.707);
                camera_pos[1] = (int)(-r * 0.707);
                camera_pos[2] = 0;
                camera.SetRoll(135);
            }

            camera.SetPosition((double)camera_pos[0], (double)camera_pos[1], (double)camera_pos[2]);
            //camera.Yaw(10);
            camera.Elevation(1);
            camera.ParallelProjectionOn();
            camera.Zoom(0.9);
            StoredViewCamera = new List <vtkCamera>();
            for (int i = 0; i < 3; i++)
            {
                vtkCamera ViewCamera = new vtkCamera();


                if (i == 0)
                {
                    ViewCamera.SetPosition(camera.GetPosition()[0],
                                           camera.GetPosition()[1],
                                           camera.GetPosition()[2]);
                    ViewCamera.SetRoll(camera.GetRoll());
                }
                else if (i == 1)
                {
                    ViewCamera.SetPosition(80, 0, 0);
                    ViewCamera.SetRoll(180);
                }
                else if (i == 2)
                {
                    ViewCamera.SetPosition(0, 0, -80);
                    ViewCamera.SetRoll(camera.GetRoll());
                }
                ViewCamera.SetFocalPoint(camera.GetFocalPoint()[0],
                                         camera.GetFocalPoint()[1],
                                         camera.GetFocalPoint()[2]);
                ViewCamera.SetViewUp(camera.GetViewUp()[0],
                                     camera.GetViewUp()[1],
                                     camera.GetViewUp()[2]);
                StoredViewCamera.Add(ViewCamera);
            }

            //camera.Zoom(1.5);
        }
    /// <summary>
    /// Entry Point
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        // This example demonstrates how to use the vtkLineWidget to seed
        // and manipulate streamlines. Two line widgets are created. One is
        // invoked by pressing 'W', the other by pressing 'L'. Both can exist
        // together.
        // Start by loading some data.
        pl3d = vtkMultiBlockPLOT3DReader.New();
        pl3d.SetXYZFileName("../../../combxyz.bin");
        pl3d.SetQFileName("../../../combq.bin");
        pl3d.SetScalarFunctionNumber(100);
        pl3d.SetVectorFunctionNumber(202);
        pl3d.Update();
        // The line widget is used seed the streamlines.
        lineWidget = vtkLineWidget.New();
        seeds = vtkPolyData.New();

        lineWidget.SetInput(pl3d.GetOutput());
        lineWidget.SetAlignToYAxis();
        lineWidget.PlaceWidget();
        lineWidget.GetPolyData(seeds);
        lineWidget.ClampToBoundsOn();

        rk4 = vtkRungeKutta4.New();
        streamer = vtkStreamLine.New();
        streamer.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        streamer.SetSource(seeds);
        streamer.SetMaximumPropagationTime(100);
        streamer.SetIntegrationStepLength(.2);
        streamer.SetStepLength(.001);
        streamer.SetNumberOfThreads(1);
        streamer.SetIntegrationDirectionToForward();
        streamer.VorticityOn();
        streamer.SetIntegrator(rk4);

        rf = vtkRibbonFilter.New();
        rf.SetInputConnection(streamer.GetOutputPort());
        rf.SetWidth(0.1);
        rf.SetWidthFactor(5);

        streamMapper = vtkPolyDataMapper.New();
        streamMapper.SetInputConnection(rf.GetOutputPort());
        streamMapper.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]);
        streamline = vtkActor.New();
        streamline.SetMapper(streamMapper);
        streamline.VisibilityOff();

        // The second line widget is used seed more streamlines.
        lineWidget2 = vtkLineWidget.New();
        seeds2 = vtkPolyData.New();
        lineWidget2.SetInput(pl3d.GetOutput());
        lineWidget2.PlaceWidget();
        lineWidget2.GetPolyData(seeds2);
        lineWidget2.SetKeyPressActivationValue((sbyte)108);

        streamer2 = vtkStreamLine.New();
        streamer2.SetInputDaat((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        streamer2.SetSource(seeds2);
        streamer2.SetMaximumPropagationTime(100);
        streamer2.SetIntegrationStepLength(.2);
        streamer2.SetStepLength(.001);
        streamer2.SetNumberOfThreads(1);
        streamer2.SetIntegrationDirectionToForward();
        streamer2.VorticityOn();
        streamer2.SetIntegrator(rk4);

        rf2 = vtkRibbonFilter.New();
        rf2.SetInputConnection(streamer2.GetOutputPort());
        rf2.SetWidth(0.1);
        rf2.SetWidthFactor(5);

        streamMapper2 = vtkPolyDataMapper.New();
        streamMapper2.SetInputConnection(rf2.GetOutputPort());
        streamMapper2.SetScalarRange(pl3d.GetOutput().GetScalarRange()[0], pl3d.GetOutput().GetScalarRange()[1]);

        streamline2 = vtkActor.New();
        streamline2.SetMapper(streamMapper2);
        streamline2.VisibilityOff();

        outline = vtkStructuredGridOutlineFilter.New();
        outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));

        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection(outline.GetOutputPort());
        outlineActor = vtkActor.New();
        outlineActor.SetMapper(outlineMapper);

        // Create the RenderWindow, Renderer and both Actors
        ren1 = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer(ren1);
        iren = vtkRenderWindowInteractor.New();
        iren.SetRenderWindow(renWin);

        // Associate the line widget with the interactor
        lineWidget.SetInteractor(iren);
        lineWidget.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(BeginInteraction);
        lineWidget.InteractionEvt += new vtkObject.vtkObjectEventHandler(GenerateStreamlines);
        lineWidget2.SetInteractor(iren);
        lineWidget2.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(BeginInteraction2);
        lineWidget2.EndInteractionEvt += new vtkObject.vtkObjectEventHandler(GenerateStreamlines2);

        // Add the actors to the renderer, set the background and size
        ren1.AddActor(outlineActor);
        ren1.AddActor(streamline);
        ren1.AddActor(streamline2);

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

        cam1 = ren1.GetActiveCamera();
        cam1.SetClippingRange(3.95297, 50);
        cam1.SetFocalPoint(9.71821, 0.458166, 29.3999);
        cam1.SetPosition(2.7439, -37.3196, 38.7167);
        cam1.SetViewUp(-0.16123, 0.264271, 0.950876);

        // render the image
        renWin.Render();
        lineWidget2.On();
        iren.Initialize();
        iren.Start();

        //Clean Up
        deleteAllVTKObjects();
    }
Beispiel #34
0
        private void PolygonalSurfaceContourLineInterpolator()
        {
            vtkPolyData     polyData;
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.SetThetaResolution(40);
            sphereSource.SetPhiResolution(20);
            sphereSource.Update();

            polyData = sphereSource.GetOutput();
            // The Dijkstra interpolator will not accept cells that aren't triangles
            vtkTriangleFilter triangleFilter = vtkTriangleFilter.New();

#if VTK_MAJOR_VERSION_5
            triangleFilter.SetInput(polyData);
#else
            triangleFilter.SetInputData(polyData);
#endif
            triangleFilter.Update();

            vtkPolyData pd = triangleFilter.GetOutput();

            //Create a mapper and actor
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
            mapper.SetInputConnection(triangleFilter.GetOutputPort());

            vtkActor actor = vtkActor.New();
            actor.SetMapper(mapper);
            actor.GetProperty().SetInterpolationToFlat();

            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            // renderer
            vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer();
            // set background color
            renderer.SetBackground(0.3, 0.4, 0.5);
            // add our actor to the renderer
            renderer.AddActor(actor);

            // Here comes the contour widget stuff.....
            vtkContourWidget contourWidget = vtkContourWidget.New();
            contourWidget.SetInteractor(renderWindow.GetInteractor());
            vtkOrientedGlyphContourRepresentation rep =
                vtkOrientedGlyphContourRepresentation.SafeDownCast(
                    contourWidget.GetRepresentation());
            rep.GetLinesProperty().SetColor(1, 0.2, 0);
            rep.GetLinesProperty().SetLineWidth(3.0f);

            vtkPolygonalSurfacePointPlacer pointPlacer =
                vtkPolygonalSurfacePointPlacer.New();
            pointPlacer.AddProp(actor);
            pointPlacer.GetPolys().AddItem(pd);
            rep.SetPointPlacer(pointPlacer);

            vtkPolygonalSurfaceContourLineInterpolator interpolator =
                vtkPolygonalSurfaceContourLineInterpolator.New();
            interpolator.GetPolys().AddItem(pd);
            rep.SetLineInterpolator(interpolator);

            renderWindow.Render();
            contourWidget.EnabledOn();
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        try
        {
            bool fail_on_image_diff = false;

            //Prefix Content is: ""
            int argc = 0;
            if (argv != null)
            {
                argc = argv.Length;
            }

            // setup some common things for testing[]
            vtkMath.RandomSeed(6);
            // create the testing class to do the work[]
            rtTester = new vtkTesting();
            for (int i = 1; i < argc; i++)
            {
                rtTester.AddArgument(argv[i]);

                if (argv[i] == "--fail-on-image-diff")
                {
                    fail_on_image_diff = true;
                }
            }

            // string auto_path = "";
            //
            VTK_DATA_ROOT = rtTester.GetDataRoot();

            // load in the script[]
            if (0 == argv.Length)
            {
                test = GetTestNameInteractively();
            }
            else
            {
                test = argv[0];
            }

            //The class that we are about to execute the test in
            System.Type t = System.Type.GetType(test + "Class");
            if (null == t)
            {
                throw new System.ArgumentException(System.String.Format(
                                                       "error: could not create a Type object for '{0}'...\n\n{1}\n{2}\n{3}\n{4}\n\n{5}\n\n",
                                                       test + "Class",
                                                       "Typo?",
                                                       "Did you follow the C# test driver naming convention?",
                                                       "Did you add the test to the CMakeLists.txt file?",
                                                       "Did you reconfigure/rebuild after adding the test?",
                                                       "Test 'method' name should equal 'file name without extension'... Test 'public class' name should be the same but with 'Class' appended..."
                                                       ));
            }


            // set the default threshold, the Tcl script may change this[]
            threshold = -1;

            executeMethod(t, "Setthreshold", new object[] { threshold });
            executeMethod(t, "SetVTK_DATA_ROOT", new object[] { VTK_DATA_ROOT });

            //run the test
            executeMethod(t, test, new object[] { argv });

            tempRenderWindowInteractor = (vtkRenderWindowInteractor)executeMethod(t, "Getiren", new object[] { });
            tempRenderWindow           = (vtkRenderWindow)executeMethod(t, "GetrenWin", new object[] { });
            tempViewer = (vtkObject)executeMethod(t, "Getviewer", new object[] { });
            tempw2i    = (vtkWindowToImageFilter)executeMethod(t, "Getw2i", new object[] { });

            //update the threshold from what the test made it
            threshold = (int)executeMethod(t, "Getthreshold", new object[] { });
            if (tempRenderWindowInteractor != null)
            {
                tempRenderWindow.Render();
            }

            // run the event loop quickly to map any tkwidget windows[]
            // current directory[]
            rtResult = 0;
            if (fail_on_image_diff && rtTester.IsValidImageSpecified() != 0)
            {
                // look for a renderWindow ImageWindow or ImageViewer[]
                // first check for some common names[]
                if (tempRenderWindow != null)
                {
                    rtTester.SetRenderWindow(tempRenderWindow);
                    if ((threshold) == -1)
                    {
                        threshold = 10;
                    }
                }
                else
                {
                    if ((threshold) == -1)
                    {
                        threshold = 5;
                    }
                    if (tempViewer != null)
                    {
                        if (tempViewer.IsA("vtkImageViewer") != 0)
                        {
                            tempRenderWindow = ((vtkImageViewer)tempViewer).GetRenderWindow();
                        }
                        else if (tempViewer.IsA("vtkImageViewer2") != 0)
                        {
                            tempRenderWindow = ((vtkImageViewer2)tempViewer).GetRenderWindow();
                        }
                        else
                        {
                            throw new System.Exception("");
                        }
                        rtTester.SetRenderWindow(tempRenderWindow);

                        if (tempViewer.IsA("vtkImageViewer") != 0)
                        {
                            ((vtkImageViewer)tempViewer).Render();
                        }
                        else if (tempViewer.IsA("vtkImageViewer2") != 0)
                        {
                            ((vtkImageViewer2)tempViewer).Render();
                        }
                    }
                    else
                    {
                        tempRenderWindow = (vtkRenderWindow)executeMethod(t, "GetimgWin", new object[] { });
                        if (tempRenderWindow != null)
                        {
                            rtTester.SetRenderWindow(tempRenderWindow);
                            tempRenderWindow.Render();
                        }
                    }
                }

                if (tempRenderWindow == null)
                {
                    throw new System.Exception("tempRenderWindow cannot be null for IsValidImageSpecified case...");
                }

                rtResult = rtTester.RegressionTest(threshold);
            }

            if (rtTester.IsInteractiveModeSpecified() != 0)
            {
                if (tempRenderWindowInteractor != null)
                {
                    tempRenderWindowInteractor.Start();
                }
            }

            // Force other objects that may have holds on the render window
            // to let go:
            //
            rtTester.SetRenderWindow(null);
            if (null != tempw2i)
            {
                tempw2i.SetInput(null);
            }

            executeMethod(t, "deleteAllVTKObjects", new object[] { });
            deleteAllVTKObjects();

            // Force a garbage collection prior to exiting the test
            // so that any memory leaks reported are likely to be
            // *actual* leaks of some sort rather than false reports:
            //
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();

            // Fail the tests that have image diffs if fail_on_image_diff is on:
            //
            if (fail_on_image_diff && 0 == rtResult)
            {
                throw new System.Exception("error: image RegressionTest failed");
            }

            // Test finished without throwing any exceptions...
            // Therefore, it passed. Exit with a zero ExitCode.
            //
            System.Environment.ExitCode = 0;
        }
        catch (System.Exception exc)
        {
            // Catch anything, spit it out to the console so it can be captured
            // by ctest. Exit with a non-zero ExitCode.
            //
            System.Console.Error.WriteLine("================================================================================");
            System.Console.Error.WriteLine("");
            System.Console.Error.WriteLine("TclToCsScript C# test driver caught System.Exception:");
            System.Console.Error.WriteLine("");
            System.Console.Error.WriteLine("{0}", exc.ToString());
            System.Console.Error.WriteLine("");
            System.Console.Error.WriteLine("================================================================================");
            System.Console.Error.WriteLine("");
            System.Environment.ExitCode = 2345;
        }
    }
Beispiel #36
0
    /// <summary>
    /// An example that does not use a Windows Form
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        // This example demonstrates the use of vtkCubeAxesActor2D to indicate the
        // position in space that the camera is currently viewing.
        // The vtkCubeAxesActor2D draws axes on the bounding box of the data set and
        // labels the axes with x-y-z coordinates.
        //
        // First we include the VTK Tcl packages which will make available
        // all of the vtk commands to Tcl
        //
        // Create a vtkBYUReader and read in a data set.
        //
        fohe = vtkBYUReader.New();
        fohe.SetGeometryFileName("../../../teapot.g");

        // Create a vtkPolyDataNormals filter to calculate the normals of the data set.
        normals = vtkPolyDataNormals.New();
        normals.SetInputConnection(fohe.GetOutputPort());

        // Set up the associated mapper and actor.
        foheMapper = vtkPolyDataMapper.New();
        foheMapper.SetInputConnection(normals.GetOutputPort());

        foheActor = vtkLODActor.New();
        foheActor.SetMapper(foheMapper);

        // Create a vtkOutlineFilter to draw the bounding box of the data set.  Also
        // create the associated mapper and actor.
        outline = vtkOutlineFilter.New();
        outline.SetInputConnection(normals.GetOutputPort());

        mapOutline = vtkPolyDataMapper.New();
        mapOutline.SetInputConnection(outline.GetOutputPort());

        outlineActor = vtkActor.New();
        outlineActor.SetMapper(mapOutline);
        outlineActor.GetProperty().SetColor(0, 0, 0);

        // Create a vtkCamera, and set the camera parameters.
        camera = vtkCamera.New();
        camera.SetClippingRange(1.60187, 20.0842);
        camera.SetFocalPoint(0.21406, 1.5, 0);
        camera.SetPosition(8.3761, 4.94858, 4.12505);
        camera.SetViewUp(0.180325, 0.549245, -0.815974);

        // Create a vtkLight, and set the light parameters.
        light = vtkLight.New();
        light.SetFocalPoint(0.21406, 1.5, 0);
        light.SetPosition(8.3761, 4.94858, 4.12505);

        // Create the Renderers.  Assign them the appropriate viewport coordinates,
        // active camera, and light.
        ren1 = vtkRenderer.New();
        ren1.SetViewport(0, 0, 0.5, 1.0);
        ren1.SetActiveCamera(camera);
        ren1.AddLight(light);

        ren2 = vtkRenderer.New();
        ren2.SetViewport(0.5, 0, 1.0, 1.0);
        ren2.SetActiveCamera(camera);
        ren2.AddLight(light);

        // Create the RenderWindow and RenderWindowInteractor.
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer(ren1);
        renWin.AddRenderer(ren2);
        renWin.SetWindowName("VTK - Cube Axes");
        renWin.SetSize(600, 300);
        iren = vtkRenderWindowInteractor.New();
        iren.SetRenderWindow(renWin);

        // Add the actors to the renderer, and set the background.
        ren1.AddViewProp(foheActor);
        ren1.AddViewProp(outlineActor);
        ren2.AddViewProp(foheActor);
        ren2.AddViewProp(outlineActor);
        ren1.SetBackground(0.1, 0.2, 0.4);
        ren2.SetBackground(0.1, 0.2, 0.4);

        // Create a text property for both cube axes
        tprop = vtkTextProperty.New();
        tprop.SetColor(1, 1, 1);
        tprop.ShadowOn();

        // Create a vtkCubeAxesActor2D.  Use the outer edges of the bounding box to
        // draw the axes.  Add the actor to the renderer.
        axes = vtkCubeAxesActor2D.New();
        axes.SetInput(normals.GetOutput());
        axes.SetCamera(ren1.GetActiveCamera());
        axes.SetLabelFormat("%6.4g");
        axes.SetFlyModeToOuterEdges();
        axes.SetFontFactor(0.8);
        axes.SetAxisTitleTextProperty(tprop);
        axes.SetAxisLabelTextProperty(tprop);
        ren1.AddViewProp(axes);

        // Create a vtkCubeAxesActor2D.  Use the closest vertex to the camera to
        // determine where to draw the axes.  Add the actor to the renderer.
        axes2 = vtkCubeAxesActor2D.New();
        axes2.SetViewProp(foheActor);
        axes2.SetCamera(ren2.GetActiveCamera());
        axes2.SetLabelFormat("%6.4g");
        axes2.SetFlyModeToClosestTriad();
        axes2.SetFontFactor(0.8);
        axes2.ScalingOff();
        axes2.SetAxisTitleTextProperty(tprop);
        axes2.SetAxisLabelTextProperty(tprop);
        ren2.AddViewProp(axes2);

        // Render
        renWin.Render();

        // Set the user method (bound to key 'u')
        iren.Initialize();
        iren.Start();

        // Set up a check for aborting rendering.
        renWin.AbortCheckEvt += new vtkObject.vtkObjectEventHandler(TkCheckAbort);

        //Clean Up
        deleteAllVTKObjects();
    }
Beispiel #37
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTenEllip(String [] argv)
    {
        //Prefix Content is: ""

          // create tensor ellipsoids[]
          // Create the RenderWindow, Renderer and interactive renderer[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.SetMultiSamples(0);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          //[]
          // Create tensor ellipsoids[]
          //[]
          // generate tensors[]
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)6,(int)6,(int)6);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          // extract plane of data[]
          plane = new vtkImageDataGeometryFilter();
          plane.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          plane.SetExtent((int)2,(int)2,(int)0,(int)99,(int)0,(int)99);
          // Generate ellipsoids[]
          sphere = new vtkSphereSource();
          sphere.SetThetaResolution((int)8);
          sphere.SetPhiResolution((int)8);
          ellipsoids = new vtkTensorGlyph();
          ellipsoids.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          ellipsoids.SetSourceConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          ellipsoids.SetScaleFactor((double)10);
          ellipsoids.ClampScalingOn();
          ellipNormals = new vtkPolyDataNormals();
          ellipNormals.SetInputConnection((vtkAlgorithmOutput)ellipsoids.GetOutputPort());
          // Map contour[]
          lut = new vtkLogLookupTable();
          lut.SetHueRange((double).6667,(double)0.0);
          ellipMapper = vtkPolyDataMapper.New();
          ellipMapper.SetInputConnection((vtkAlgorithmOutput)ellipNormals.GetOutputPort());
          ellipMapper.SetLookupTable((vtkScalarsToColors)lut);
          plane.Update();
          //force update for scalar range[]
          ellipMapper.SetScalarRange((double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)plane.GetOutput()).GetScalarRange()[1]);
          ellipActor = new vtkActor();
          ellipActor.SetMapper((vtkMapper)ellipMapper);
          //[]
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          //[]
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor((vtkProp)ellipActor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)400,(int)400);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
        static void ReadSupport(string Spath)
        {
            vtkJPEGReader reader = vtkJPEGReader.New();

            reader.SetFileName(Spath);
            reader.Update();

            // Visualize
            _ImageViewer = vtkImageViewer2.New();
            _ImageViewer.SetInputConnection(reader.GetOutputPort());

            _SliceStatusMapper = vtkTextMapper.New();
            _SliceStatusMapper.SetInputConnection(reader.GetOutputPort());

            vtkActor2D sliceStatusActor = vtkActor2D.New();

            sliceStatusActor.SetMapper(_SliceStatusMapper);

            vtkRenderWindow renderWindow = vtkRenderWindow.New();

            //Display in full screen
            renderWindow.SetFullScreen(1);

            vtkInteractorStyleImage interactorStyle = vtkInteractorStyleImage.New();

            renderWindow.GetRenderers().InitTraversal();
            vtkRenderer ren;

            while ((ren = renderWindow.GetRenderers().GetNextItem()) != null)
            {
                renderWindow.AddRenderer(ren);
            }

            _ImageViewer.SetRenderWindow(renderWindow);
            _ImageViewer.GetRenderer().AddActor2D(sliceStatusActor);
            _ImageViewer.SetSlice(_SupportSlice);

            iren = vtkRenderWindowInteractor.New();
            iren.SetRenderWindow(renderWindow);
            renderWindow.Render();
            _ColorLevel = 60;
            _ImageViewer.SetColorLevel(_BlackLevel);
            _ImageViewer.Render();
            Down(_period, 170);
            Backward(_period, 1);

            for (int i = 0; i < _SupportLayers; i++)
            {
                System.Threading.Thread.Sleep(_layertime); // delay
                Backward(_period, 1);
            }
            _ImageViewer.SetColorLevel(_BlackLevel);
            _ImageViewer.Render();
            Forward(_period, _MovedLayers);
            Console.WriteLine(_MovedLayers);

            if (reader != null)
            {
                reader.Dispose();
            }
            if (_ImageViewer != null)
            {
                _ImageViewer.Dispose();
            }
            if (_SliceStatusMapper != null)
            {
                _SliceStatusMapper.Dispose();
            }
            if (sliceStatusActor != null)
            {
                sliceStatusActor.Dispose();
            }
            if (renderWindow != null)
            {
                renderWindow.Dispose();
            }
            if (interactorStyle != null)
            {
                interactorStyle.Dispose();
            }
            if (ren != null)
            {
                ren.Dispose();
            }
            if (iren != null)
            {
                iren.Dispose();
            }
        }
        private void Window_Activated(object sender, EventArgs e)
        {
            vtkPolyData   cube    = new vtkPolyData();
            vtkPoints     points  = new vtkPoints();
            vtkCellArray  polys   = new vtkCellArray();
            vtkFloatArray scalars = new vtkFloatArray();

            Kitware.VTK.RenderWindowControl vtkControl = new Kitware.VTK.RenderWindowControl();
            vtkControl.AddTestActors = false;
            vtkControl.Location      = new System.Drawing.Point(10, 10);
            vtkControl.Name          = "_renwin";
            vtkControl.Size          = new System.Drawing.Size(100, 100);
            vtkControl.TabIndex      = 0;
            vtkControl.TestText      = null;
            vtkControl.Dock          = System.Windows.Forms.DockStyle.Fill;
            vtkformhost.Child        = vtkControl;
            vtkformhost.Visibility   = System.Windows.Visibility.Visible;


            int i;

            float[][] x = new float[8][]
            {
                new float[] { 0, 0, 0 }, //第0个点的坐标
                new float[] { 1, 0, 0 }, //第1个点的坐标
                new float[] { 1, 1, 0 }, //第2个点的坐标
                new float[] { 0, 1, 0 }, //3
                new float[] { 0, 0, 1 }, //4
                new float[] { 1, 0, 1 }, //5
                new float[] { 1, 1, 1 }, //6
                new float[] { 0, 1, 1 } //7
            };
            for (i = 0; i < 8; i++)
            {
                points.InsertPoint(i, x[i][0], x[i][1], x[i][2]);                    //加载点,创建数据结构的几何
            }
            List <int[]> temp = new List <int[]>();

            int[] temparray0 = new int[4] {
                0, 1, 2, 3
            };                                           //第0,1,2,3个点连接在一起,成为一个单元
            int[] temparray1 = new int[4] {
                4, 5, 6, 7
            };                                           //第4,5,6,7个点连接在一起,成为一个单元
            int[] temparray2 = new int[4] {
                0, 1, 5, 4
            };
            int[] temparray3 = new int[4] {
                1, 2, 6, 5
            };
            int[] temparray4 = new int[4] {
                2, 3, 7, 6
            };
            int[] temparray5 = new int[4] {
                3, 0, 4, 7
            };
            temp.Add(temparray0);
            temp.Add(temparray1);
            temp.Add(temparray2);
            temp.Add(temparray3);
            temp.Add(temparray4);
            temp.Add(temparray5);
            //因为在activiz中没有vtkIdType这个类,所以用了其他的方法代替C++代码中的实现。
            for (int j = 0; j < temp.Count; j++)
            {
                IntPtr pP = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * 4);
                Marshal.Copy(temp[j], 0, pP, 4);
                polys.InsertNextCell(4, pP);//加载单元,定义数据集的拓扑
                Marshal.FreeHGlobal(pP);
            }
            for (i = 0; i < 8; i++)
            {
                scalars.InsertTuple1(i, i);                    //为每一个点设置点属性。
            }
            cube.SetPoints(points);
            cube.SetPolys(polys);
            cube.GetPointData().SetScalars(scalars);

            vtkPolyDataMapper cubemapper = new vtkPainterPolyDataMapper();

            cubemapper.SetInput(cube);
            cubemapper.SetScalarRange(0, 7);

            vtkActor cubeactor = new vtkActor();

            cubeactor.SetMapper(cubemapper);

            // Create components of the rendering subsystem
            //
            vtkRenderWindow _renwin = vtkControl.RenderWindow;
            vtkRenderer     ren1    = _renwin.GetRenderers().GetFirstRenderer();


            // Add the actors to the renderer, set the window size
            //
            ren1.AddViewProp(cubeactor);
            _renwin.SetSize(250, 250);
            _renwin.Render();
            ren1.ResetCamera();
        }
Beispiel #40
0
        private void Triangulate()
        {
            vtkRegularPolygonSource polygonSource = vtkRegularPolygonSource.New();

            polygonSource.Update();

            vtkTriangleFilter triangleFilter = vtkTriangleFilter.New();

#if VTK_MAJOR_VERSION_5
            triangleFilter.SetInputConnection(polygonSource.GetOutputPort());
#else
            triangleFilter.SetInputData(polygonSource);
#endif
            triangleFilter.Update();

            vtkPolyDataMapper inputMapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            inputMapper.SetInputConnection(polygonSource.GetOutputPort());
#else
            inputMapper.SetInputData(polygonSource);
#endif
            vtkActor inputActor = vtkActor.New();
            inputActor.SetMapper(inputMapper);
            inputActor.GetProperty().SetRepresentationToWireframe();

            vtkPolyDataMapper triangleMapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            triangleMapper.SetInputConnection(triangleFilter.GetOutputPort());
#else
            triangleMapper.SetInputData(triangleFilter);
#endif
            vtkActor triangleActor = vtkActor.New();
            triangleActor.SetMapper(triangleMapper);
            triangleActor.GetProperty().SetRepresentationToWireframe();

            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            this.Size = new System.Drawing.Size(612, 352);

            // Define viewport ranges
            // (xmin, ymin, xmax, ymax)
            double[] leftViewport  = new double[] { 0.0, 0.0, 0.5, 1.0 };
            double[] rightViewport = new double[] { 0.5, 0.0, 1.0, 1.0 };

            // Setup both renderers
            vtkRenderer leftRenderer = vtkRenderer.New();
            renderWindow.AddRenderer(leftRenderer);
            leftRenderer.SetViewport(leftViewport[0], leftViewport[1], leftViewport[2], leftViewport[3]);
            leftRenderer.SetBackground(.6, .5, .4);

            vtkRenderer rightRenderer = vtkRenderer.New();
            renderWindow.AddRenderer(rightRenderer);
            rightRenderer.SetViewport(rightViewport[0], rightViewport[1], rightViewport[2], rightViewport[3]);
            rightRenderer.SetBackground(.4, .5, .6);

            // Add the sphere to the left and the cube to the right
            leftRenderer.AddActor(inputActor);
            rightRenderer.AddActor(triangleActor);
            leftRenderer.ResetCamera();
            rightRenderer.ResetCamera();
            renderWindow.Render();
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestGridSynchronizedTemplates3D(String [] argv)
    {
        //Prefix Content is: ""

          // cut data[]
          pl3d = new vtkMultiBlockPLOT3DReader();
          pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin");
          pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin");
          pl3d.SetScalarFunctionNumber((int)100);
          pl3d.SetVectorFunctionNumber((int)202);
          pl3d.Update();
          range = ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange();
          min = (double)(lindex(range,0));
          max = (double)(lindex(range,1));
          value = (min+max)/2.0;
          //vtkGridSynchronizedTemplates3D cf[]
          cf = new vtkContourFilter();
          cf.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          cf.SetValue((int)0,(double)value);
          //cf ComputeNormalsOff[]
          cfMapper = vtkPolyDataMapper.New();
          cfMapper.ImmediateModeRenderingOn();
          cfMapper.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort());
          cfMapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[1]);
          cfActor = new vtkActor();
          cfActor.SetMapper((vtkMapper)cfMapper);
          //outline[]
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          //# Graphics stuff[]
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.SetMultiSamples(0);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)cfActor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)400,(int)400);
          cam1 = ren1.GetActiveCamera();
          cam1.SetClippingRange((double)3.95297,(double)50);
          cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999);
          cam1.SetPosition((double)2.7439,(double)-37.3196,(double)38.7167);
          cam1.SetViewUp((double)-0.16123,(double)0.264271,(double)0.950876);
          iren.Initialize();
          // render the image[]
          //[]
          // loop over surfaces[]
          i = 0;
          while((i) < 17)
        {
          cf.SetValue((int)0,(double)min+(i/16.0)*(max-min));
          renWin.Render();
          i = i + 1;
        }

          cf.SetValue((int)0,(double)min+(0.2)*(max-min));
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVpickCells(String [] argv)
    {
        //Prefix Content is: ""

          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // create a scene with one of each cell type[]
          // Voxel[]
          voxelPoints = new vtkPoints();
          voxelPoints.SetNumberOfPoints((int)8);
          voxelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          voxelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          voxelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          voxelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          voxelPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          voxelPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          voxelPoints.InsertPoint((int)6,(double)0,(double)1,(double)1);
          voxelPoints.InsertPoint((int)7,(double)1,(double)1,(double)1);
          aVoxel = new vtkVoxel();
          aVoxel.GetPointIds().SetId((int)0,(int)0);
          aVoxel.GetPointIds().SetId((int)1,(int)1);
          aVoxel.GetPointIds().SetId((int)2,(int)2);
          aVoxel.GetPointIds().SetId((int)3,(int)3);
          aVoxel.GetPointIds().SetId((int)4,(int)4);
          aVoxel.GetPointIds().SetId((int)5,(int)5);
          aVoxel.GetPointIds().SetId((int)6,(int)6);
          aVoxel.GetPointIds().SetId((int)7,(int)7);
          aVoxelGrid = new vtkUnstructuredGrid();
          aVoxelGrid.Allocate((int)1,(int)1);
          aVoxelGrid.InsertNextCell((int)aVoxel.GetCellType(),(vtkIdList)aVoxel.GetPointIds());
          aVoxelGrid.SetPoints((vtkPoints)voxelPoints);
          aVoxelMapper = new vtkDataSetMapper();
          aVoxelMapper.SetInput((vtkDataSet)aVoxelGrid);
          aVoxelActor = new vtkActor();
          aVoxelActor.SetMapper((vtkMapper)aVoxelMapper);
          aVoxelActor.GetProperty().BackfaceCullingOn();
          // Hexahedron[]
          hexahedronPoints = new vtkPoints();
          hexahedronPoints.SetNumberOfPoints((int)8);
          hexahedronPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)6,(double)1,(double)1,(double)1);
          hexahedronPoints.InsertPoint((int)7,(double)0,(double)1,(double)1);
          aHexahedron = new vtkHexahedron();
          aHexahedron.GetPointIds().SetId((int)0,(int)0);
          aHexahedron.GetPointIds().SetId((int)1,(int)1);
          aHexahedron.GetPointIds().SetId((int)2,(int)2);
          aHexahedron.GetPointIds().SetId((int)3,(int)3);
          aHexahedron.GetPointIds().SetId((int)4,(int)4);
          aHexahedron.GetPointIds().SetId((int)5,(int)5);
          aHexahedron.GetPointIds().SetId((int)6,(int)6);
          aHexahedron.GetPointIds().SetId((int)7,(int)7);
          aHexahedronGrid = new vtkUnstructuredGrid();
          aHexahedronGrid.Allocate((int)1,(int)1);
          aHexahedronGrid.InsertNextCell((int)aHexahedron.GetCellType(),(vtkIdList)aHexahedron.GetPointIds());
          aHexahedronGrid.SetPoints((vtkPoints)hexahedronPoints);
          aHexahedronMapper = new vtkDataSetMapper();
          aHexahedronMapper.SetInput((vtkDataSet)aHexahedronGrid);
          aHexahedronActor = new vtkActor();
          aHexahedronActor.SetMapper((vtkMapper)aHexahedronMapper);
          aHexahedronActor.AddPosition((double)2,(double)0,(double)0);
          aHexahedronActor.GetProperty().BackfaceCullingOn();
          // Tetra[]
          tetraPoints = new vtkPoints();
          tetraPoints.SetNumberOfPoints((int)4);
          tetraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          tetraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          tetraPoints.InsertPoint((int)2,(double).5,(double)1,(double)0);
          tetraPoints.InsertPoint((int)3,(double).5,(double).5,(double)1);
          aTetra = new vtkTetra();
          aTetra.GetPointIds().SetId((int)0,(int)0);
          aTetra.GetPointIds().SetId((int)1,(int)1);
          aTetra.GetPointIds().SetId((int)2,(int)2);
          aTetra.GetPointIds().SetId((int)3,(int)3);
          aTetraGrid = new vtkUnstructuredGrid();
          aTetraGrid.Allocate((int)1,(int)1);
          aTetraGrid.InsertNextCell((int)aTetra.GetCellType(),(vtkIdList)aTetra.GetPointIds());
          aTetraGrid.SetPoints((vtkPoints)tetraPoints);
          aTetraMapper = new vtkDataSetMapper();
          aTetraMapper.SetInput((vtkDataSet)aTetraGrid);
          aTetraActor = new vtkActor();
          aTetraActor.SetMapper((vtkMapper)aTetraMapper);
          aTetraActor.AddPosition((double)4,(double)0,(double)0);
          aTetraActor.GetProperty().BackfaceCullingOn();
          // Wedge[]
          wedgePoints = new vtkPoints();
          wedgePoints.SetNumberOfPoints((int)6);
          wedgePoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          wedgePoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          wedgePoints.InsertPoint((int)2,(double)0,(double).5,(double).5);
          wedgePoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)0);
          wedgePoints.InsertPoint((int)5,(double)1,(double).5,(double).5);
          aWedge = new vtkWedge();
          aWedge.GetPointIds().SetId((int)0,(int)0);
          aWedge.GetPointIds().SetId((int)1,(int)1);
          aWedge.GetPointIds().SetId((int)2,(int)2);
          aWedge.GetPointIds().SetId((int)3,(int)3);
          aWedge.GetPointIds().SetId((int)4,(int)4);
          aWedge.GetPointIds().SetId((int)5,(int)5);
          aWedgeGrid = new vtkUnstructuredGrid();
          aWedgeGrid.Allocate((int)1,(int)1);
          aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds());
          aWedgeGrid.SetPoints((vtkPoints)wedgePoints);
          aWedgeMapper = new vtkDataSetMapper();
          aWedgeMapper.SetInput((vtkDataSet)aWedgeGrid);
          aWedgeActor = new vtkActor();
          aWedgeActor.SetMapper((vtkMapper)aWedgeMapper);
          aWedgeActor.AddPosition((double)6,(double)0,(double)0);
          aWedgeActor.GetProperty().BackfaceCullingOn();
          // Pyramid[]
          pyramidPoints = new vtkPoints();
          pyramidPoints.SetNumberOfPoints((int)5);
          pyramidPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)4,(double).5,(double).5,(double)1);
          aPyramid = new vtkPyramid();
          aPyramid.GetPointIds().SetId((int)0,(int)0);
          aPyramid.GetPointIds().SetId((int)1,(int)1);
          aPyramid.GetPointIds().SetId((int)2,(int)2);
          aPyramid.GetPointIds().SetId((int)3,(int)3);
          aPyramid.GetPointIds().SetId((int)4,(int)4);
          aPyramidGrid = new vtkUnstructuredGrid();
          aPyramidGrid.Allocate((int)1,(int)1);
          aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds());
          aPyramidGrid.SetPoints((vtkPoints)pyramidPoints);
          aPyramidMapper = new vtkDataSetMapper();
          aPyramidMapper.SetInput((vtkDataSet)aPyramidGrid);
          aPyramidActor = new vtkActor();
          aPyramidActor.SetMapper((vtkMapper)aPyramidMapper);
          aPyramidActor.AddPosition((double)8,(double)0,(double)0);
          aPyramidActor.GetProperty().BackfaceCullingOn();
          // Pixel[]
          pixelPoints = new vtkPoints();
          pixelPoints.SetNumberOfPoints((int)4);
          pixelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pixelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pixelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          pixelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          aPixel = new vtkPixel();
          aPixel.GetPointIds().SetId((int)0,(int)0);
          aPixel.GetPointIds().SetId((int)1,(int)1);
          aPixel.GetPointIds().SetId((int)2,(int)2);
          aPixel.GetPointIds().SetId((int)3,(int)3);
          aPixelGrid = new vtkUnstructuredGrid();
          aPixelGrid.Allocate((int)1,(int)1);
          aPixelGrid.InsertNextCell((int)aPixel.GetCellType(),(vtkIdList)aPixel.GetPointIds());
          aPixelGrid.SetPoints((vtkPoints)pixelPoints);
          aPixelMapper = new vtkDataSetMapper();
          aPixelMapper.SetInput((vtkDataSet)aPixelGrid);
          aPixelActor = new vtkActor();
          aPixelActor.SetMapper((vtkMapper)aPixelMapper);
          aPixelActor.AddPosition((double)0,(double)0,(double)2);
          aPixelActor.GetProperty().BackfaceCullingOn();
          // Quad[]
          quadPoints = new vtkPoints();
          quadPoints.SetNumberOfPoints((int)4);
          quadPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          quadPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          quadPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          quadPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aQuad = new vtkQuad();
          aQuad.GetPointIds().SetId((int)0,(int)0);
          aQuad.GetPointIds().SetId((int)1,(int)1);
          aQuad.GetPointIds().SetId((int)2,(int)2);
          aQuad.GetPointIds().SetId((int)3,(int)3);
          aQuadGrid = new vtkUnstructuredGrid();
          aQuadGrid.Allocate((int)1,(int)1);
          aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds());
          aQuadGrid.SetPoints((vtkPoints)quadPoints);
          aQuadMapper = new vtkDataSetMapper();
          aQuadMapper.SetInput((vtkDataSet)aQuadGrid);
          aQuadActor = new vtkActor();
          aQuadActor.SetMapper((vtkMapper)aQuadMapper);
          aQuadActor.AddPosition((double)2,(double)0,(double)2);
          aQuadActor.GetProperty().BackfaceCullingOn();
          // Triangle[]
          trianglePoints = new vtkPoints();
          trianglePoints.SetNumberOfPoints((int)3);
          trianglePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          trianglePoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          trianglePoints.InsertPoint((int)2,(double).5,(double).5,(double)0);
          aTriangle = new vtkTriangle();
          aTriangle.GetPointIds().SetId((int)0,(int)0);
          aTriangle.GetPointIds().SetId((int)1,(int)1);
          aTriangle.GetPointIds().SetId((int)2,(int)2);
          aTriangleGrid = new vtkUnstructuredGrid();
          aTriangleGrid.Allocate((int)1,(int)1);
          aTriangleGrid.InsertNextCell((int)aTriangle.GetCellType(),(vtkIdList)aTriangle.GetPointIds());
          aTriangleGrid.SetPoints((vtkPoints)trianglePoints);
          aTriangleMapper = new vtkDataSetMapper();
          aTriangleMapper.SetInput((vtkDataSet)aTriangleGrid);
          aTriangleActor = new vtkActor();
          aTriangleActor.SetMapper((vtkMapper)aTriangleMapper);
          aTriangleActor.AddPosition((double)4,(double)0,(double)2);
          aTriangleActor.GetProperty().BackfaceCullingOn();
          // Polygon[]
          polygonPoints = new vtkPoints();
          polygonPoints.SetNumberOfPoints((int)4);
          polygonPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polygonPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polygonPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          polygonPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aPolygon = new vtkPolygon();
          aPolygon.GetPointIds().SetNumberOfIds((int)4);
          aPolygon.GetPointIds().SetId((int)0,(int)0);
          aPolygon.GetPointIds().SetId((int)1,(int)1);
          aPolygon.GetPointIds().SetId((int)2,(int)2);
          aPolygon.GetPointIds().SetId((int)3,(int)3);
          aPolygonGrid = new vtkUnstructuredGrid();
          aPolygonGrid.Allocate((int)1,(int)1);
          aPolygonGrid.InsertNextCell((int)aPolygon.GetCellType(),(vtkIdList)aPolygon.GetPointIds());
          aPolygonGrid.SetPoints((vtkPoints)polygonPoints);
          aPolygonMapper = new vtkDataSetMapper();
          aPolygonMapper.SetInput((vtkDataSet)aPolygonGrid);
          aPolygonActor = new vtkActor();
          aPolygonActor.SetMapper((vtkMapper)aPolygonMapper);
          aPolygonActor.AddPosition((double)6,(double)0,(double)2);
          aPolygonActor.GetProperty().BackfaceCullingOn();
          // Triangle Strip[]
          triangleStripPoints = new vtkPoints();
          triangleStripPoints.SetNumberOfPoints((int)5);
          triangleStripPoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)3,(double)1,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)4,(double)2,(double)1,(double)0);
          aTriangleStrip = new vtkTriangleStrip();
          aTriangleStrip.GetPointIds().SetNumberOfIds((int)5);
          aTriangleStrip.GetPointIds().SetId((int)0,(int)0);
          aTriangleStrip.GetPointIds().SetId((int)1,(int)1);
          aTriangleStrip.GetPointIds().SetId((int)2,(int)2);
          aTriangleStrip.GetPointIds().SetId((int)3,(int)3);
          aTriangleStrip.GetPointIds().SetId((int)4,(int)4);
          aTriangleStripGrid = new vtkUnstructuredGrid();
          aTriangleStripGrid.Allocate((int)1,(int)1);
          aTriangleStripGrid.InsertNextCell((int)aTriangleStrip.GetCellType(),(vtkIdList)aTriangleStrip.GetPointIds());
          aTriangleStripGrid.SetPoints((vtkPoints)triangleStripPoints);
          aTriangleStripMapper = new vtkDataSetMapper();
          aTriangleStripMapper.SetInput((vtkDataSet)aTriangleStripGrid);
          aTriangleStripActor = new vtkActor();
          aTriangleStripActor.SetMapper((vtkMapper)aTriangleStripMapper);
          aTriangleStripActor.AddPosition((double)8,(double)0,(double)2);
          aTriangleStripActor.GetProperty().BackfaceCullingOn();
          // Line[]
          linePoints = new vtkPoints();
          linePoints.SetNumberOfPoints((int)2);
          linePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          linePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          aLine = new vtkLine();
          aLine.GetPointIds().SetId((int)0,(int)0);
          aLine.GetPointIds().SetId((int)1,(int)1);
          aLineGrid = new vtkUnstructuredGrid();
          aLineGrid.Allocate((int)1,(int)1);
          aLineGrid.InsertNextCell((int)aLine.GetCellType(),(vtkIdList)aLine.GetPointIds());
          aLineGrid.SetPoints((vtkPoints)linePoints);
          aLineMapper = new vtkDataSetMapper();
          aLineMapper.SetInput((vtkDataSet)aLineGrid);
          aLineActor = new vtkActor();
          aLineActor.SetMapper((vtkMapper)aLineMapper);
          aLineActor.AddPosition((double)0,(double)0,(double)4);
          aLineActor.GetProperty().BackfaceCullingOn();
          // Poly line[]
          polyLinePoints = new vtkPoints();
          polyLinePoints.SetNumberOfPoints((int)3);
          polyLinePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyLinePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          polyLinePoints.InsertPoint((int)2,(double)1,(double)0,(double)0);
          aPolyLine = new vtkPolyLine();
          aPolyLine.GetPointIds().SetNumberOfIds((int)3);
          aPolyLine.GetPointIds().SetId((int)0,(int)0);
          aPolyLine.GetPointIds().SetId((int)1,(int)1);
          aPolyLine.GetPointIds().SetId((int)2,(int)2);
          aPolyLineGrid = new vtkUnstructuredGrid();
          aPolyLineGrid.Allocate((int)1,(int)1);
          aPolyLineGrid.InsertNextCell((int)aPolyLine.GetCellType(),(vtkIdList)aPolyLine.GetPointIds());
          aPolyLineGrid.SetPoints((vtkPoints)polyLinePoints);
          aPolyLineMapper = new vtkDataSetMapper();
          aPolyLineMapper.SetInput((vtkDataSet)aPolyLineGrid);
          aPolyLineActor = new vtkActor();
          aPolyLineActor.SetMapper((vtkMapper)aPolyLineMapper);
          aPolyLineActor.AddPosition((double)2,(double)0,(double)4);
          aPolyLineActor.GetProperty().BackfaceCullingOn();
          // Vertex[]
          vertexPoints = new vtkPoints();
          vertexPoints.SetNumberOfPoints((int)1);
          vertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          aVertex = new vtkVertex();
          aVertex.GetPointIds().SetId((int)0,(int)0);
          aVertexGrid = new vtkUnstructuredGrid();
          aVertexGrid.Allocate((int)1,(int)1);
          aVertexGrid.InsertNextCell((int)aVertex.GetCellType(),(vtkIdList)aVertex.GetPointIds());
          aVertexGrid.SetPoints((vtkPoints)vertexPoints);
          aVertexMapper = new vtkDataSetMapper();
          aVertexMapper.SetInput((vtkDataSet)aVertexGrid);
          aVertexActor = new vtkActor();
          aVertexActor.SetMapper((vtkMapper)aVertexMapper);
          aVertexActor.AddPosition((double)0,(double)0,(double)6);
          aVertexActor.GetProperty().BackfaceCullingOn();
          // Poly Vertex[]
          polyVertexPoints = new vtkPoints();
          polyVertexPoints.SetNumberOfPoints((int)3);
          polyVertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          aPolyVertex = new vtkPolyVertex();
          aPolyVertex.GetPointIds().SetNumberOfIds((int)3);
          aPolyVertex.GetPointIds().SetId((int)0,(int)0);
          aPolyVertex.GetPointIds().SetId((int)1,(int)1);
          aPolyVertex.GetPointIds().SetId((int)2,(int)2);
          aPolyVertexGrid = new vtkUnstructuredGrid();
          aPolyVertexGrid.Allocate((int)1,(int)1);
          aPolyVertexGrid.InsertNextCell((int)aPolyVertex.GetCellType(),(vtkIdList)aPolyVertex.GetPointIds());
          aPolyVertexGrid.SetPoints((vtkPoints)polyVertexPoints);
          aPolyVertexMapper = new vtkDataSetMapper();
          aPolyVertexMapper.SetInput((vtkDataSet)aPolyVertexGrid);
          aPolyVertexActor = new vtkActor();
          aPolyVertexActor.SetMapper((vtkMapper)aPolyVertexMapper);
          aPolyVertexActor.AddPosition((double)2,(double)0,(double)6);
          aPolyVertexActor.GetProperty().BackfaceCullingOn();
          // Pentagonal prism[]
          pentaPoints = new vtkPoints();
          pentaPoints.SetNumberOfPoints((int)10);
          pentaPoints.InsertPoint((int)0,(double)0.25,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)1,(double)0.75,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)3,(double)0.5,(double)1.0,(double)0.0);
          pentaPoints.InsertPoint((int)4,(double)0.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)5,(double)0.25,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)6,(double)0.75,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)7,(double)1.0,(double)0.5,(double)1.0);
          pentaPoints.InsertPoint((int)8,(double)0.5,(double)1.0,(double)1.0);
          pentaPoints.InsertPoint((int)9,(double)0.0,(double)0.5,(double)1.0);
          aPenta = new vtkPentagonalPrism();
          aPenta.GetPointIds().SetId((int)0,(int)0);
          aPenta.GetPointIds().SetId((int)1,(int)1);
          aPenta.GetPointIds().SetId((int)2,(int)2);
          aPenta.GetPointIds().SetId((int)3,(int)3);
          aPenta.GetPointIds().SetId((int)4,(int)4);
          aPenta.GetPointIds().SetId((int)5,(int)5);
          aPenta.GetPointIds().SetId((int)6,(int)6);
          aPenta.GetPointIds().SetId((int)7,(int)7);
          aPenta.GetPointIds().SetId((int)8,(int)8);
          aPenta.GetPointIds().SetId((int)9,(int)9);
          aPentaGrid = new vtkUnstructuredGrid();
          aPentaGrid.Allocate((int)1,(int)1);
          aPentaGrid.InsertNextCell((int)aPenta.GetCellType(),(vtkIdList)aPenta.GetPointIds());
          aPentaGrid.SetPoints((vtkPoints)pentaPoints);
          aPentaMapper = new vtkDataSetMapper();
          aPentaMapper.SetInput((vtkDataSet)aPentaGrid);
          aPentaActor = new vtkActor();
          aPentaActor.SetMapper((vtkMapper)aPentaMapper);
          aPentaActor.AddPosition((double)10,(double)0,(double)0);
          aPentaActor.GetProperty().BackfaceCullingOn();
          // Hexagonal prism[]
          hexaPoints = new vtkPoints();
          hexaPoints.SetNumberOfPoints((int)12);
          hexaPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)1,(double)0.5,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)3,(double)1.0,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)4,(double)0.5,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)5,(double)0.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)6,(double)0.0,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)7,(double)0.5,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)8,(double)1.0,(double)0.5,(double)1.0);
          hexaPoints.InsertPoint((int)9,(double)1.0,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)10,(double)0.5,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)11,(double)0.0,(double)0.5,(double)1.0);
          aHexa = new vtkHexagonalPrism();
          aHexa.GetPointIds().SetId((int)0,(int)0);
          aHexa.GetPointIds().SetId((int)1,(int)1);
          aHexa.GetPointIds().SetId((int)2,(int)2);
          aHexa.GetPointIds().SetId((int)3,(int)3);
          aHexa.GetPointIds().SetId((int)4,(int)4);
          aHexa.GetPointIds().SetId((int)5,(int)5);
          aHexa.GetPointIds().SetId((int)6,(int)6);
          aHexa.GetPointIds().SetId((int)7,(int)7);
          aHexa.GetPointIds().SetId((int)8,(int)8);
          aHexa.GetPointIds().SetId((int)9,(int)9);
          aHexa.GetPointIds().SetId((int)10,(int)10);
          aHexa.GetPointIds().SetId((int)11,(int)11);
          aHexaGrid = new vtkUnstructuredGrid();
          aHexaGrid.Allocate((int)1,(int)1);
          aHexaGrid.InsertNextCell((int)aHexa.GetCellType(),(vtkIdList)aHexa.GetPointIds());
          aHexaGrid.SetPoints((vtkPoints)hexaPoints);
          aHexaMapper = new vtkDataSetMapper();
          aHexaMapper.SetInput((vtkDataSet)aHexaGrid);
          aHexaActor = new vtkActor();
          aHexaActor.SetMapper((vtkMapper)aHexaMapper);
          aHexaActor.AddPosition((double)12,(double)0,(double)0);
          aHexaActor.GetProperty().BackfaceCullingOn();
          ren1.SetBackground((double).1,(double).2,(double).4);
          ren1.AddActor((vtkProp)aVoxelActor);
          aVoxelActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)0);
          ren1.AddActor((vtkProp)aHexahedronActor);
          aHexahedronActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          ren1.AddActor((vtkProp)aTetraActor);
          aTetraActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)0);
          ren1.AddActor((vtkProp)aWedgeActor);
          aWedgeActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPyramidActor);
          aPyramidActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aPixelActor);
          aPixelActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aQuadActor);
          aQuadActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aTriangleActor);
          aTriangleActor.GetProperty().SetDiffuseColor((double).3,(double)1,(double).5);
          ren1.AddActor((vtkProp)aPolygonActor);
          aPolygonActor.GetProperty().SetDiffuseColor((double)1,(double).4,(double).5);
          ren1.AddActor((vtkProp)aTriangleStripActor);
          aTriangleStripActor.GetProperty().SetDiffuseColor((double).3,(double).7,(double)1);
          ren1.AddActor((vtkProp)aLineActor);
          aLineActor.GetProperty().SetDiffuseColor((double).2,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyLineActor);
          aPolyLineActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aVertexActor);
          aVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyVertexActor);
          aPolyVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPentaActor);
          aPentaActor.GetProperty().SetDiffuseColor((double).2,(double).4,(double).7);
          ren1.AddActor((vtkProp)aHexaActor);
          aHexaActor.GetProperty().SetDiffuseColor((double).7,(double).5,(double)1);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Azimuth((double)30);
          ren1.GetActiveCamera().Elevation((double)20);
          ren1.GetActiveCamera().Dolly((double)1.25);
          ren1.ResetCameraClippingRange();
          renWin.Render();
          cellPicker = new vtkCellPicker();
          pointPicker = new vtkPointPicker();
          worldPicker = new vtkWorldPointPicker();
          cellCount = 0;
          pointCount = 0;
          ren1.IsInViewport((int)0,(int)0);
          x = 0;
          while((x) <= 265)
        {
          y = 100;
          while((y) <= 200)
        {
          cellPicker.Pick((double)x,(double)y,(double)0,(vtkRenderer)ren1);
          pointPicker.Pick((double)x,(double)y,(double)0,(vtkRenderer)ren1);
          worldPicker.Pick((double)x,(double)y,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
            {
              cellCount = cellCount + 1;
            }

          if ((pointPicker.GetPointId()) != -1)
            {
              pointCount = pointCount + 1;
            }

          y = y + 6;
        }

          x = x + 6;
        }

          // render the image[]
          //[]
          iren.Initialize();

        //deleteAllVTKObjects();
    }
Beispiel #43
0
    public static int Main(string[] args)
    {
        vtkTesting testHelper = vtkTesting.New();

        for (int cc = 0; cc < args.Length; cc++)
        {
            //testHelper.AddArguments(argc,const_cast<const char **>(argv));
            //System.Console.Write( "args: " + args[cc] + "\n" );
            testHelper.AddArgument(args[cc]);
        }
        if (testHelper.IsFlagSpecified("-D") != 0)
        {
            string VTK_DATA_ROOT = vtkGDCMTesting.GetVTKDataRoot();
            if (VTK_DATA_ROOT != null)
            {
                //System.Console.Write( "VTK_DATA_ROOT: " + VTK_DATA_ROOT  + "\n" );
                testHelper.SetDataRoot(VTK_DATA_ROOT);
                testHelper.AddArgument("-D");
                testHelper.AddArgument(VTK_DATA_ROOT);
            }
        }

        string dataRoot = testHelper.GetDataRoot();
        string filename = dataRoot;

        filename += "/Data/mr.001";

        vtkDirectory dir = vtkDirectory.New();

        if (dir.FileIsDirectory(dataRoot) == 0)
        {
            filename = vtkGDCMTesting.GetGDCMDataRoot() + "/test.acr";
        }
        //System.Console.Write( "dataRoot: " + dataRoot + "\n" );
        System.Console.Write("filename being used is: " + filename + "\n");

        vtkGDCMImageReader reader = vtkGDCMImageReader.New();
        vtkStringArray     array  = vtkStringArray.New();

        array.InsertNextValue(filename);
        reader.SetFileNames(array);
        reader.Update();

        System.Console.Write(reader.GetOutput());

        vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();

        vtkRenderer     ren1   = vtkRenderer.New();
        vtkRenderWindow renWin = vtkRenderWindow.New();

        renWin.AddRenderer(ren1);

        vtkImageActor actor = vtkImageActor.New();

        vtkImageMapToWindowLevelColors coronalColors = vtkImageMapToWindowLevelColors.New();

        coronalColors.SetInput(reader.GetOutput());

        actor.SetInput(coronalColors.GetOutput());

        ren1.AddActor(actor);
        iren.SetRenderWindow(renWin);

        iren.Initialize();

        renWin.Render();

        int retVal = testHelper.IsInteractiveModeSpecified();

        if (retVal != 0)
        {
            iren.Start();
        }

        return(0);
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestCellDerivs(String [] argv)
    {
        //Prefix Content is: ""

          // Demonstrates vtkCellDerivatives for all cell types[]
          //[]
          // get the interactor ui[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // create a scene with one of each cell type[]
          // Voxel[]
          voxelPoints = new vtkPoints();
          voxelPoints.SetNumberOfPoints((int)8);
          voxelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          voxelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          voxelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          voxelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          voxelPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          voxelPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          voxelPoints.InsertPoint((int)6,(double)0,(double)1,(double)1);
          voxelPoints.InsertPoint((int)7,(double)1,(double)1,(double)1);
          aVoxel = new vtkVoxel();
          aVoxel.GetPointIds().SetId((int)0,(int)0);
          aVoxel.GetPointIds().SetId((int)1,(int)1);
          aVoxel.GetPointIds().SetId((int)2,(int)2);
          aVoxel.GetPointIds().SetId((int)3,(int)3);
          aVoxel.GetPointIds().SetId((int)4,(int)4);
          aVoxel.GetPointIds().SetId((int)5,(int)5);
          aVoxel.GetPointIds().SetId((int)6,(int)6);
          aVoxel.GetPointIds().SetId((int)7,(int)7);
          aVoxelGrid = new vtkUnstructuredGrid();
          aVoxelGrid.Allocate((int)1,(int)1);
          aVoxelGrid.InsertNextCell((int)aVoxel.GetCellType(),(vtkIdList)aVoxel.GetPointIds());
          aVoxelGrid.SetPoints((vtkPoints)voxelPoints);
          aVoxelMapper = new vtkDataSetMapper();
          aVoxelMapper.SetInput((vtkDataSet)aVoxelGrid);
          aVoxelActor = new vtkActor();
          aVoxelActor.SetMapper((vtkMapper)aVoxelMapper);
          aVoxelActor.GetProperty().BackfaceCullingOn();
          // Hexahedron[]
          hexahedronPoints = new vtkPoints();
          hexahedronPoints.SetNumberOfPoints((int)8);
          hexahedronPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)6,(double)1,(double)1,(double)1);
          hexahedronPoints.InsertPoint((int)7,(double)0,(double)1,(double)1);
          aHexahedron = new vtkHexahedron();
          aHexahedron.GetPointIds().SetId((int)0,(int)0);
          aHexahedron.GetPointIds().SetId((int)1,(int)1);
          aHexahedron.GetPointIds().SetId((int)2,(int)2);
          aHexahedron.GetPointIds().SetId((int)3,(int)3);
          aHexahedron.GetPointIds().SetId((int)4,(int)4);
          aHexahedron.GetPointIds().SetId((int)5,(int)5);
          aHexahedron.GetPointIds().SetId((int)6,(int)6);
          aHexahedron.GetPointIds().SetId((int)7,(int)7);
          aHexahedronGrid = new vtkUnstructuredGrid();
          aHexahedronGrid.Allocate((int)1,(int)1);
          aHexahedronGrid.InsertNextCell((int)aHexahedron.GetCellType(),(vtkIdList)aHexahedron.GetPointIds());
          aHexahedronGrid.SetPoints((vtkPoints)hexahedronPoints);
          aHexahedronMapper = new vtkDataSetMapper();
          aHexahedronMapper.SetInput((vtkDataSet)aHexahedronGrid);
          aHexahedronActor = new vtkActor();
          aHexahedronActor.SetMapper((vtkMapper)aHexahedronMapper);
          aHexahedronActor.AddPosition((double)2,(double)0,(double)0);
          aHexahedronActor.GetProperty().BackfaceCullingOn();
          // Tetra[]
          tetraPoints = new vtkPoints();
          tetraPoints.SetNumberOfPoints((int)4);
          tetraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          tetraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          tetraPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          tetraPoints.InsertPoint((int)3,(double)1,(double)1,(double)1);
          aTetra = new vtkTetra();
          aTetra.GetPointIds().SetId((int)0,(int)0);
          aTetra.GetPointIds().SetId((int)1,(int)1);
          aTetra.GetPointIds().SetId((int)2,(int)2);
          aTetra.GetPointIds().SetId((int)3,(int)3);
          aTetraGrid = new vtkUnstructuredGrid();
          aTetraGrid.Allocate((int)1,(int)1);
          aTetraGrid.InsertNextCell((int)aTetra.GetCellType(),(vtkIdList)aTetra.GetPointIds());
          aTetraGrid.SetPoints((vtkPoints)tetraPoints);
          aTetraMapper = new vtkDataSetMapper();
          aTetraMapper.SetInput((vtkDataSet)aTetraGrid);
          aTetraActor = new vtkActor();
          aTetraActor.SetMapper((vtkMapper)aTetraMapper);
          aTetraActor.AddPosition((double)4,(double)0,(double)0);
          aTetraActor.GetProperty().BackfaceCullingOn();
          // Wedge[]
          wedgePoints = new vtkPoints();
          wedgePoints.SetNumberOfPoints((int)6);
          wedgePoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          wedgePoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          wedgePoints.InsertPoint((int)2,(double)0,(double).5,(double).5);
          wedgePoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)0);
          wedgePoints.InsertPoint((int)5,(double)1,(double).5,(double).5);
          aWedge = new vtkWedge();
          aWedge.GetPointIds().SetId((int)0,(int)0);
          aWedge.GetPointIds().SetId((int)1,(int)1);
          aWedge.GetPointIds().SetId((int)2,(int)2);
          aWedge.GetPointIds().SetId((int)3,(int)3);
          aWedge.GetPointIds().SetId((int)4,(int)4);
          aWedge.GetPointIds().SetId((int)5,(int)5);
          aWedgeGrid = new vtkUnstructuredGrid();
          aWedgeGrid.Allocate((int)1,(int)1);
          aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds());
          aWedgeGrid.SetPoints((vtkPoints)wedgePoints);
          aWedgeMapper = new vtkDataSetMapper();
          aWedgeMapper.SetInput((vtkDataSet)aWedgeGrid);
          aWedgeActor = new vtkActor();
          aWedgeActor.SetMapper((vtkMapper)aWedgeMapper);
          aWedgeActor.AddPosition((double)6,(double)0,(double)0);
          aWedgeActor.GetProperty().BackfaceCullingOn();
          // Pyramid[]
          pyramidPoints = new vtkPoints();
          pyramidPoints.SetNumberOfPoints((int)5);
          pyramidPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)4,(double).5,(double).5,(double)1);
          aPyramid = new vtkPyramid();
          aPyramid.GetPointIds().SetId((int)0,(int)0);
          aPyramid.GetPointIds().SetId((int)1,(int)1);
          aPyramid.GetPointIds().SetId((int)2,(int)2);
          aPyramid.GetPointIds().SetId((int)3,(int)3);
          aPyramid.GetPointIds().SetId((int)4,(int)4);
          aPyramidGrid = new vtkUnstructuredGrid();
          aPyramidGrid.Allocate((int)1,(int)1);
          aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds());
          aPyramidGrid.SetPoints((vtkPoints)pyramidPoints);
          aPyramidMapper = new vtkDataSetMapper();
          aPyramidMapper.SetInput((vtkDataSet)aPyramidGrid);
          aPyramidActor = new vtkActor();
          aPyramidActor.SetMapper((vtkMapper)aPyramidMapper);
          aPyramidActor.AddPosition((double)8,(double)0,(double)0);
          aPyramidActor.GetProperty().BackfaceCullingOn();
          // Pixel[]
          pixelPoints = new vtkPoints();
          pixelPoints.SetNumberOfPoints((int)4);
          pixelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pixelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pixelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          pixelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          aPixel = new vtkPixel();
          aPixel.GetPointIds().SetId((int)0,(int)0);
          aPixel.GetPointIds().SetId((int)1,(int)1);
          aPixel.GetPointIds().SetId((int)2,(int)2);
          aPixel.GetPointIds().SetId((int)3,(int)3);
          aPixelGrid = new vtkUnstructuredGrid();
          aPixelGrid.Allocate((int)1,(int)1);
          aPixelGrid.InsertNextCell((int)aPixel.GetCellType(),(vtkIdList)aPixel.GetPointIds());
          aPixelGrid.SetPoints((vtkPoints)pixelPoints);
          aPixelMapper = new vtkDataSetMapper();
          aPixelMapper.SetInput((vtkDataSet)aPixelGrid);
          aPixelActor = new vtkActor();
          aPixelActor.SetMapper((vtkMapper)aPixelMapper);
          aPixelActor.AddPosition((double)0,(double)0,(double)2);
          aPixelActor.GetProperty().BackfaceCullingOn();
          // Quad[]
          quadPoints = new vtkPoints();
          quadPoints.SetNumberOfPoints((int)4);
          quadPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          quadPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          quadPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          quadPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aQuad = new vtkQuad();
          aQuad.GetPointIds().SetId((int)0,(int)0);
          aQuad.GetPointIds().SetId((int)1,(int)1);
          aQuad.GetPointIds().SetId((int)2,(int)2);
          aQuad.GetPointIds().SetId((int)3,(int)3);
          aQuadGrid = new vtkUnstructuredGrid();
          aQuadGrid.Allocate((int)1,(int)1);
          aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds());
          aQuadGrid.SetPoints((vtkPoints)quadPoints);
          aQuadMapper = new vtkDataSetMapper();
          aQuadMapper.SetInput((vtkDataSet)aQuadGrid);
          aQuadActor = new vtkActor();
          aQuadActor.SetMapper((vtkMapper)aQuadMapper);
          aQuadActor.AddPosition((double)2,(double)0,(double)2);
          aQuadActor.GetProperty().BackfaceCullingOn();
          // Triangle[]
          trianglePoints = new vtkPoints();
          trianglePoints.SetNumberOfPoints((int)3);
          trianglePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          trianglePoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          trianglePoints.InsertPoint((int)2,(double).5,(double).5,(double)0);
          triangleTCoords = new vtkFloatArray();
          triangleTCoords.SetNumberOfComponents((int)2);
          triangleTCoords.SetNumberOfTuples((int)3);
          triangleTCoords.InsertTuple2((int)0,(double)1,(double)1);
          triangleTCoords.InsertTuple2((int)1,(double)2,(double)2);
          triangleTCoords.InsertTuple2((int)2,(double)3,(double)3);
          aTriangle = new vtkTriangle();
          aTriangle.GetPointIds().SetId((int)0,(int)0);
          aTriangle.GetPointIds().SetId((int)1,(int)1);
          aTriangle.GetPointIds().SetId((int)2,(int)2);
          aTriangleGrid = new vtkUnstructuredGrid();
          aTriangleGrid.Allocate((int)1,(int)1);
          aTriangleGrid.InsertNextCell((int)aTriangle.GetCellType(),(vtkIdList)aTriangle.GetPointIds());
          aTriangleGrid.SetPoints((vtkPoints)trianglePoints);
          aTriangleGrid.GetPointData().SetTCoords((vtkDataArray)triangleTCoords);
          aTriangleMapper = new vtkDataSetMapper();
          aTriangleMapper.SetInput((vtkDataSet)aTriangleGrid);
          aTriangleActor = new vtkActor();
          aTriangleActor.SetMapper((vtkMapper)aTriangleMapper);
          aTriangleActor.AddPosition((double)4,(double)0,(double)2);
          aTriangleActor.GetProperty().BackfaceCullingOn();
          // Polygon[]
          polygonPoints = new vtkPoints();
          polygonPoints.SetNumberOfPoints((int)4);
          polygonPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polygonPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polygonPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          polygonPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aPolygon = new vtkPolygon();
          aPolygon.GetPointIds().SetNumberOfIds((int)4);
          aPolygon.GetPointIds().SetId((int)0,(int)0);
          aPolygon.GetPointIds().SetId((int)1,(int)1);
          aPolygon.GetPointIds().SetId((int)2,(int)2);
          aPolygon.GetPointIds().SetId((int)3,(int)3);
          aPolygonGrid = new vtkUnstructuredGrid();
          aPolygonGrid.Allocate((int)1,(int)1);
          aPolygonGrid.InsertNextCell((int)aPolygon.GetCellType(),(vtkIdList)aPolygon.GetPointIds());
          aPolygonGrid.SetPoints((vtkPoints)polygonPoints);
          aPolygonMapper = new vtkDataSetMapper();
          aPolygonMapper.SetInput((vtkDataSet)aPolygonGrid);
          aPolygonActor = new vtkActor();
          aPolygonActor.SetMapper((vtkMapper)aPolygonMapper);
          aPolygonActor.AddPosition((double)6,(double)0,(double)2);
          aPolygonActor.GetProperty().BackfaceCullingOn();
          // Triangle strip[]
          triangleStripPoints = new vtkPoints();
          triangleStripPoints.SetNumberOfPoints((int)5);
          triangleStripPoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)3,(double)1,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)4,(double)2,(double)1,(double)0);
          triangleStripTCoords = new vtkFloatArray();
          triangleStripTCoords.SetNumberOfComponents((int)2);
          triangleStripTCoords.SetNumberOfTuples((int)3);
          triangleStripTCoords.InsertTuple2((int)0,(double)1,(double)1);
          triangleStripTCoords.InsertTuple2((int)1,(double)2,(double)2);
          triangleStripTCoords.InsertTuple2((int)2,(double)3,(double)3);
          triangleStripTCoords.InsertTuple2((int)3,(double)4,(double)4);
          triangleStripTCoords.InsertTuple2((int)4,(double)5,(double)5);
          aTriangleStrip = new vtkTriangleStrip();
          aTriangleStrip.GetPointIds().SetNumberOfIds((int)5);
          aTriangleStrip.GetPointIds().SetId((int)0,(int)0);
          aTriangleStrip.GetPointIds().SetId((int)1,(int)1);
          aTriangleStrip.GetPointIds().SetId((int)2,(int)2);
          aTriangleStrip.GetPointIds().SetId((int)3,(int)3);
          aTriangleStrip.GetPointIds().SetId((int)4,(int)4);
          aTriangleStripGrid = new vtkUnstructuredGrid();
          aTriangleStripGrid.Allocate((int)1,(int)1);
          aTriangleStripGrid.InsertNextCell((int)aTriangleStrip.GetCellType(),(vtkIdList)aTriangleStrip.GetPointIds());
          aTriangleStripGrid.SetPoints((vtkPoints)triangleStripPoints);
          aTriangleStripGrid.GetPointData().SetTCoords((vtkDataArray)triangleStripTCoords);
          aTriangleStripMapper = new vtkDataSetMapper();
          aTriangleStripMapper.SetInput((vtkDataSet)aTriangleStripGrid);
          aTriangleStripActor = new vtkActor();
          aTriangleStripActor.SetMapper((vtkMapper)aTriangleStripMapper);
          aTriangleStripActor.AddPosition((double)8,(double)0,(double)2);
          aTriangleStripActor.GetProperty().BackfaceCullingOn();
          // Line[]
          linePoints = new vtkPoints();
          linePoints.SetNumberOfPoints((int)2);
          linePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          linePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          aLine = new vtkLine();
          aLine.GetPointIds().SetId((int)0,(int)0);
          aLine.GetPointIds().SetId((int)1,(int)1);
          aLineGrid = new vtkUnstructuredGrid();
          aLineGrid.Allocate((int)1,(int)1);
          aLineGrid.InsertNextCell((int)aLine.GetCellType(),(vtkIdList)aLine.GetPointIds());
          aLineGrid.SetPoints((vtkPoints)linePoints);
          aLineMapper = new vtkDataSetMapper();
          aLineMapper.SetInput((vtkDataSet)aLineGrid);
          aLineActor = new vtkActor();
          aLineActor.SetMapper((vtkMapper)aLineMapper);
          aLineActor.AddPosition((double)0,(double)0,(double)4);
          aLineActor.GetProperty().BackfaceCullingOn();
          // Polyline[]
          polyLinePoints = new vtkPoints();
          polyLinePoints.SetNumberOfPoints((int)3);
          polyLinePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyLinePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          polyLinePoints.InsertPoint((int)2,(double)1,(double)0,(double)0);
          aPolyLine = new vtkPolyLine();
          aPolyLine.GetPointIds().SetNumberOfIds((int)3);
          aPolyLine.GetPointIds().SetId((int)0,(int)0);
          aPolyLine.GetPointIds().SetId((int)1,(int)1);
          aPolyLine.GetPointIds().SetId((int)2,(int)2);
          aPolyLineGrid = new vtkUnstructuredGrid();
          aPolyLineGrid.Allocate((int)1,(int)1);
          aPolyLineGrid.InsertNextCell((int)aPolyLine.GetCellType(),(vtkIdList)aPolyLine.GetPointIds());
          aPolyLineGrid.SetPoints((vtkPoints)polyLinePoints);
          aPolyLineMapper = new vtkDataSetMapper();
          aPolyLineMapper.SetInput((vtkDataSet)aPolyLineGrid);
          aPolyLineActor = new vtkActor();
          aPolyLineActor.SetMapper((vtkMapper)aPolyLineMapper);
          aPolyLineActor.AddPosition((double)2,(double)0,(double)4);
          aPolyLineActor.GetProperty().BackfaceCullingOn();
          // Vertex[]
          vertexPoints = new vtkPoints();
          vertexPoints.SetNumberOfPoints((int)1);
          vertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          aVertex = new vtkVertex();
          aVertex.GetPointIds().SetId((int)0,(int)0);
          aVertexGrid = new vtkUnstructuredGrid();
          aVertexGrid.Allocate((int)1,(int)1);
          aVertexGrid.InsertNextCell((int)aVertex.GetCellType(),(vtkIdList)aVertex.GetPointIds());
          aVertexGrid.SetPoints((vtkPoints)vertexPoints);
          aVertexMapper = new vtkDataSetMapper();
          aVertexMapper.SetInput((vtkDataSet)aVertexGrid);
          aVertexActor = new vtkActor();
          aVertexActor.SetMapper((vtkMapper)aVertexMapper);
          aVertexActor.AddPosition((double)0,(double)0,(double)6);
          aVertexActor.GetProperty().BackfaceCullingOn();
          // Polyvertex[]
          polyVertexPoints = new vtkPoints();
          polyVertexPoints.SetNumberOfPoints((int)3);
          polyVertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          aPolyVertex = new vtkPolyVertex();
          aPolyVertex.GetPointIds().SetNumberOfIds((int)3);
          aPolyVertex.GetPointIds().SetId((int)0,(int)0);
          aPolyVertex.GetPointIds().SetId((int)1,(int)1);
          aPolyVertex.GetPointIds().SetId((int)2,(int)2);
          aPolyVertexGrid = new vtkUnstructuredGrid();
          aPolyVertexGrid.Allocate((int)1,(int)1);
          aPolyVertexGrid.InsertNextCell((int)aPolyVertex.GetCellType(),(vtkIdList)aPolyVertex.GetPointIds());
          aPolyVertexGrid.SetPoints((vtkPoints)polyVertexPoints);
          aPolyVertexMapper = new vtkDataSetMapper();
          aPolyVertexMapper.SetInput((vtkDataSet)aPolyVertexGrid);
          aPolyVertexActor = new vtkActor();
          aPolyVertexActor.SetMapper((vtkMapper)aPolyVertexMapper);
          aPolyVertexActor.AddPosition((double)2,(double)0,(double)6);
          aPolyVertexActor.GetProperty().BackfaceCullingOn();
          // Pentagonal prism[]
          pentaPoints = new vtkPoints();
          pentaPoints.SetNumberOfPoints((int)10);
          pentaPoints.InsertPoint((int)0,(double)0.25,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)1,(double)0.75,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)3,(double)0.5,(double)1.0,(double)0.0);
          pentaPoints.InsertPoint((int)4,(double)0.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)5,(double)0.25,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)6,(double)0.75,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)7,(double)1.0,(double)0.5,(double)1.0);
          pentaPoints.InsertPoint((int)8,(double)0.5,(double)1.0,(double)1.0);
          pentaPoints.InsertPoint((int)9,(double)0.0,(double)0.5,(double)1.0);
          aPenta = new vtkPentagonalPrism();
          aPenta.GetPointIds().SetId((int)0,(int)0);
          aPenta.GetPointIds().SetId((int)1,(int)1);
          aPenta.GetPointIds().SetId((int)2,(int)2);
          aPenta.GetPointIds().SetId((int)3,(int)3);
          aPenta.GetPointIds().SetId((int)4,(int)4);
          aPenta.GetPointIds().SetId((int)5,(int)5);
          aPenta.GetPointIds().SetId((int)6,(int)6);
          aPenta.GetPointIds().SetId((int)7,(int)7);
          aPenta.GetPointIds().SetId((int)8,(int)8);
          aPenta.GetPointIds().SetId((int)9,(int)9);
          aPentaGrid = new vtkUnstructuredGrid();
          aPentaGrid.Allocate((int)1,(int)1);
          aPentaGrid.InsertNextCell((int)aPenta.GetCellType(),(vtkIdList)aPenta.GetPointIds());
          aPentaGrid.SetPoints((vtkPoints)pentaPoints);
          aPentaMapper = new vtkDataSetMapper();
          aPentaMapper.SetInput((vtkDataSet)aPentaGrid);
          aPentaActor = new vtkActor();
          aPentaActor.SetMapper((vtkMapper)aPentaMapper);
          aPentaActor.AddPosition((double)10,(double)0,(double)0);
          aPentaActor.GetProperty().BackfaceCullingOn();
          // Hexagonal prism[]
          hexaPoints = new vtkPoints();
          hexaPoints.SetNumberOfPoints((int)12);
          hexaPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)1,(double)0.5,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)3,(double)1.0,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)4,(double)0.5,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)5,(double)0.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)6,(double)0.0,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)7,(double)0.5,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)8,(double)1.0,(double)0.5,(double)1.0);
          hexaPoints.InsertPoint((int)9,(double)1.0,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)10,(double)0.5,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)11,(double)0.0,(double)0.5,(double)1.0);
          aHexa = new vtkHexagonalPrism();
          aHexa.GetPointIds().SetId((int)0,(int)0);
          aHexa.GetPointIds().SetId((int)1,(int)1);
          aHexa.GetPointIds().SetId((int)2,(int)2);
          aHexa.GetPointIds().SetId((int)3,(int)3);
          aHexa.GetPointIds().SetId((int)4,(int)4);
          aHexa.GetPointIds().SetId((int)5,(int)5);
          aHexa.GetPointIds().SetId((int)6,(int)6);
          aHexa.GetPointIds().SetId((int)7,(int)7);
          aHexa.GetPointIds().SetId((int)8,(int)8);
          aHexa.GetPointIds().SetId((int)9,(int)9);
          aHexa.GetPointIds().SetId((int)10,(int)10);
          aHexa.GetPointIds().SetId((int)11,(int)11);
          aHexaGrid = new vtkUnstructuredGrid();
          aHexaGrid.Allocate((int)1,(int)1);
          aHexaGrid.InsertNextCell((int)aHexa.GetCellType(),(vtkIdList)aHexa.GetPointIds());
          aHexaGrid.SetPoints((vtkPoints)hexaPoints);
          aHexaMapper = new vtkDataSetMapper();
          aHexaMapper.SetInput((vtkDataSet)aHexaGrid);
          aHexaActor = new vtkActor();
          aHexaActor.SetMapper((vtkMapper)aHexaMapper);
          aHexaActor.AddPosition((double)12,(double)0,(double)0);
          aHexaActor.GetProperty().BackfaceCullingOn();
          ren1.SetBackground((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aVoxelActor);
          aVoxelActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)0);
          ren1.AddActor((vtkProp)aHexahedronActor);
          aHexahedronActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          ren1.AddActor((vtkProp)aTetraActor);
          aTetraActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)0);
          ren1.AddActor((vtkProp)aWedgeActor);
          aWedgeActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPyramidActor);
          aPyramidActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aPixelActor);
          aPixelActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aQuadActor);
          aQuadActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aTriangleActor);
          aTriangleActor.GetProperty().SetDiffuseColor((double).3,(double)1,(double).5);
          ren1.AddActor((vtkProp)aPolygonActor);
          aPolygonActor.GetProperty().SetDiffuseColor((double)1,(double).4,(double).5);
          ren1.AddActor((vtkProp)aTriangleStripActor);
          aTriangleStripActor.GetProperty().SetDiffuseColor((double).3,(double).7,(double)1);
          ren1.AddActor((vtkProp)aLineActor);
          aLineActor.GetProperty().SetDiffuseColor((double).2,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyLineActor);
          aPolyLineActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aVertexActor);
          aVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyVertexActor);
          aPolyVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPentaActor);
          aPentaActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          ren1.AddActor((vtkProp)aHexaActor);
          aHexaActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          //[]
          // get the cell center of each type and put a glyph there[]
          //[]
          ball = new vtkSphereSource();
          ball.SetRadius((double).2);

            bool tryWorked = false;
          aVoxelScalars = new vtkFloatArray();
          N = aVoxelGrid.GetNumberOfPoints();
          aVoxelScalar = new vtkFloatArray();
          aVoxelScalar.SetNumberOfTuples((int)N);
          aVoxelScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aVoxelScalar.SetValue(i,0);
          i = i + 1;
        }

          aVoxelScalar.SetValue(0,4);
          aVoxelGrid.GetPointData().SetScalars(aVoxelScalar);

          aHexahedronScalars = new vtkFloatArray();
          N = aHexahedronGrid.GetNumberOfPoints();
          aHexahedronScalar = new vtkFloatArray();
          aHexahedronScalar.SetNumberOfTuples((int)N);
          aHexahedronScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aHexahedronScalar.SetValue(i,0);
          i = i + 1;
        }

          aHexahedronScalar.SetValue(0,4);
          aHexahedronGrid.GetPointData().SetScalars(aHexahedronScalar);

          aWedgeScalars = new vtkFloatArray();
          N = aWedgeGrid.GetNumberOfPoints();
          aWedgeScalar = new vtkFloatArray();
          aWedgeScalar.SetNumberOfTuples((int)N);
          aWedgeScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aWedgeScalar.SetValue(i,0);
          i = i + 1;
        }

          aWedgeScalar.SetValue(0,4);
          aWedgeGrid.GetPointData().SetScalars(aWedgeScalar);

          aPyramidScalars = new vtkFloatArray();
          N = aPyramidGrid.GetNumberOfPoints();
          aPyramidScalar = new vtkFloatArray();
          aPyramidScalar.SetNumberOfTuples((int)N);
          aPyramidScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPyramidScalar.SetValue(i,0);
          i = i + 1;
        }

          aPyramidScalar.SetValue(0,4);
          aPyramidGrid.GetPointData().SetScalars(aPyramidScalar);

          aTetraScalars = new vtkFloatArray();
          N = aTetraGrid.GetNumberOfPoints();
          aTetraScalar = new vtkFloatArray();
          aTetraScalar.SetNumberOfTuples((int)N);
          aTetraScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aTetraScalar.SetValue(i,0);
          i = i + 1;
        }

          aTetraScalar.SetValue(0,4);
          aTetraGrid.GetPointData().SetScalars(aTetraScalar);

          aQuadScalars = new vtkFloatArray();
          N = aQuadGrid.GetNumberOfPoints();
          aQuadScalar = new vtkFloatArray();
          aQuadScalar.SetNumberOfTuples((int)N);
          aQuadScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aQuadScalar.SetValue(i,0);
          i = i + 1;
        }

          aQuadScalar.SetValue(0,4);
          aQuadGrid.GetPointData().SetScalars(aQuadScalar);

          aTriangleScalars = new vtkFloatArray();
          N = aTriangleGrid.GetNumberOfPoints();
          aTriangleScalar = new vtkFloatArray();
          aTriangleScalar.SetNumberOfTuples((int)N);
          aTriangleScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aTriangleScalar.SetValue(i,0);
          i = i + 1;
        }

          aTriangleScalar.SetValue(0,4);
          aTriangleGrid.GetPointData().SetScalars(aTriangleScalar);

          aTriangleStripScalars = new vtkFloatArray();
          N = aTriangleStripGrid.GetNumberOfPoints();
          aTriangleStripScalar = new vtkFloatArray();
          aTriangleStripScalar.SetNumberOfTuples((int)N);
          aTriangleStripScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aTriangleStripScalar.SetValue(i,0);
          i = i + 1;
        }

          aTriangleStripScalar.SetValue(0,4);
          aTriangleStripGrid.GetPointData().SetScalars(aTriangleStripScalar);

          aLineScalars = new vtkFloatArray();
          N = aLineGrid.GetNumberOfPoints();
          aLineScalar = new vtkFloatArray();
          aLineScalar.SetNumberOfTuples((int)N);
          aLineScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aLineScalar.SetValue(i,0);
          i = i + 1;
        }

          aLineScalar.SetValue(0,4);
          aLineGrid.GetPointData().SetScalars(aLineScalar);

          aPolyLineScalars = new vtkFloatArray();
          N = aPolyLineGrid.GetNumberOfPoints();
          aPolyLineScalar = new vtkFloatArray();
          aPolyLineScalar.SetNumberOfTuples((int)N);
          aPolyLineScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPolyLineScalar.SetValue(i,0);
          i = i + 1;
        }

          aPolyLineScalar.SetValue(0,4);
          aPolyLineGrid.GetPointData().SetScalars(aPolyLineScalar);

          aVertexScalars = new vtkFloatArray();
          N = aVertexGrid.GetNumberOfPoints();
          aVertexScalar = new vtkFloatArray();
          aVertexScalar.SetNumberOfTuples((int)N);
          aVertexScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aVertexScalar.SetValue(i,0);
          i = i + 1;
        }

          aVertexScalar.SetValue(0,4);
          aVertexGrid.GetPointData().SetScalars(aVertexScalar);

          aPolyVertexScalars = new vtkFloatArray();
          N = aPolyVertexGrid.GetNumberOfPoints();
          aPolyVertexScalar = new vtkFloatArray();
          aPolyVertexScalar.SetNumberOfTuples((int)N);
          aPolyVertexScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPolyVertexScalar.SetValue(i,0);
          i = i + 1;
        }

          aPolyVertexScalar.SetValue(0,4);
          aPolyVertexGrid.GetPointData().SetScalars(aPolyVertexScalar);

          aPixelScalars = new vtkFloatArray();
          N = aPixelGrid.GetNumberOfPoints();
          aPixelScalar = new vtkFloatArray();
          aPixelScalar.SetNumberOfTuples((int)N);
          aPixelScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPixelScalar.SetValue(i,0);
          i = i + 1;
        }

          aPixelScalar.SetValue(0,4);
          aPixelGrid.GetPointData().SetScalars(aPixelScalar);

          aPolygonScalars = new vtkFloatArray();
          N = aPolygonGrid.GetNumberOfPoints();
          aPolygonScalar = new vtkFloatArray();
          aPolygonScalar.SetNumberOfTuples((int)N);
          aPolygonScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPolygonScalar.SetValue(i,0);
          i = i + 1;
        }

          aPolygonScalar.SetValue(0,4);
          aPolygonGrid.GetPointData().SetScalars(aPolygonScalar);

          aPentaScalars = new vtkFloatArray();
          N = aPentaGrid.GetNumberOfPoints();
          aPentaScalar = new vtkFloatArray();
          aPentaScalar.SetNumberOfTuples((int)N);
          aPentaScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPentaScalar.SetValue(i,0);
          i = i + 1;
        }

          aPentaScalar.SetValue(0,4);
          aPentaGrid.GetPointData().SetScalars(aPentaScalar);

          aHexaScalars = new vtkFloatArray();
          N = aHexaGrid.GetNumberOfPoints();
          aHexaScalar = new vtkFloatArray();
          aHexaScalar.SetNumberOfTuples((int)N);
          aHexaScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aHexaScalar.SetValue(i,0);
          i = i + 1;
        }

          aHexaScalar.SetValue(0,4);
          aHexaGrid.GetPointData().SetScalars(aHexaScalar);

          // write to the temp directory if possible, otherwise use .[]
          dir = ".";
          dir = TclToCsScriptTestDriver.GetTempDirectory();

        aVoxelderivs = new vtkCellDerivatives();
          aVoxelderivs.SetInput(aVoxelGrid);
          aVoxelderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aVoxel";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aVoxelWriter = new vtkUnstructuredGridWriter();
          aVoxelWriter.SetInputConnection(aVoxelderivs.GetOutputPort());
          aVoxelWriter.SetFileName(FileName);
          aVoxelWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aVoxelCenters = new vtkCellCenters();
          aVoxelCenters.SetInputConnection(aVoxelderivs.GetOutputPort());
          aVoxelCenters.VertexCellsOn();
          aVoxelhog = new vtkHedgeHog();
          aVoxelhog.SetInputConnection(aVoxelCenters.GetOutputPort());
          aVoxelmapHog = vtkPolyDataMapper.New();
          aVoxelmapHog.SetInputConnection(aVoxelhog.GetOutputPort());
          aVoxelmapHog.SetScalarModeToUseCellData();
          aVoxelmapHog.ScalarVisibilityOff();
          aVoxelhogActor = new vtkActor();
          aVoxelhogActor.SetMapper(aVoxelmapHog);
          aVoxelhogActor.GetProperty().SetColor(0,1,0);
          aVoxelGlyph3D = new vtkGlyph3D();
          aVoxelGlyph3D.SetInputConnection(aVoxelCenters.GetOutputPort());
          aVoxelGlyph3D.SetSource(ball.GetOutput());
          aVoxelCentersMapper = vtkPolyDataMapper.New();
          aVoxelCentersMapper.SetInputConnection(aVoxelGlyph3D.GetOutputPort());
          aVoxelCentersActor = new vtkActor();
        aVoxelCentersActor.SetMapper(aVoxelCentersMapper);
        aVoxelhogActor.SetPosition(aVoxelActor.GetPosition()[0],aVoxelActor.GetPosition()[1],aVoxelActor.GetPosition()[2]);
        ren1.AddActor((vtkProp)aVoxelhogActor);
        aVoxelhogActor.GetProperty().SetRepresentationToWireframe();

          aHexahedronderivs = new vtkCellDerivatives();
        aHexahedronderivs.SetInput(aHexahedronGrid);
        aHexahedronderivs.SetVectorModeToComputeGradient();
        FileName = dir;
        FileName += "/aHexahedron";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aHexahedronWriter = new vtkUnstructuredGridWriter();
          aHexahedronWriter.SetInputConnection(aHexahedronderivs.GetOutputPort());
          aHexahedronWriter.SetFileName(FileName);
          aHexahedronWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aHexahedronCenters = new vtkCellCenters();
          aHexahedronCenters.SetInputConnection(aHexahedronderivs.GetOutputPort());
          aHexahedronCenters.VertexCellsOn();
          aHexahedronhog = new vtkHedgeHog();
          aHexahedronhog.SetInputConnection(aHexahedronCenters.GetOutputPort());
          aHexahedronmapHog = vtkPolyDataMapper.New();
          aHexahedronmapHog.SetInputConnection(aHexahedronhog.GetOutputPort());
          aHexahedronmapHog.SetScalarModeToUseCellData();
          aHexahedronmapHog.ScalarVisibilityOff();
          aHexahedronhogActor = new vtkActor();
          aHexahedronhogActor.SetMapper(aHexahedronmapHog);
          aHexahedronhogActor.GetProperty().SetColor(0,1,0);
          aHexahedronGlyph3D = new vtkGlyph3D();
          aHexahedronGlyph3D.SetInputConnection(aHexahedronCenters.GetOutputPort());
          aHexahedronGlyph3D.SetSource(ball.GetOutput());
          aHexahedronCentersMapper = vtkPolyDataMapper.New();
          aHexahedronCentersMapper.SetInputConnection(aHexahedronGlyph3D.GetOutputPort());
          aHexahedronCentersActor = new vtkActor();
          aHexahedronCentersActor.SetMapper(aHexahedronCentersMapper);
          aHexahedronhogActor.SetPosition(aHexahedronActor.GetPosition()[0],aHexahedronActor.GetPosition()[1],aHexahedronActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aHexahedronhogActor);
          aHexahedronhogActor.GetProperty().SetRepresentationToWireframe();

        aWedgederivs = new vtkCellDerivatives();
          aWedgederivs.SetInput(aWedgeGrid);
          aWedgederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aWedge";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aWedgeWriter = new vtkUnstructuredGridWriter();
          aWedgeWriter.SetInputConnection(aWedgederivs.GetOutputPort());
          aWedgeWriter.SetFileName(FileName);
          aWedgeWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aWedgeCenters = new vtkCellCenters();
          aWedgeCenters.SetInputConnection(aWedgederivs.GetOutputPort());
          aWedgeCenters.VertexCellsOn();
          aWedgehog = new vtkHedgeHog();
          aWedgehog.SetInputConnection(aWedgeCenters.GetOutputPort());
          aWedgemapHog = vtkPolyDataMapper.New();
          aWedgemapHog.SetInputConnection(aWedgehog.GetOutputPort());
          aWedgemapHog.SetScalarModeToUseCellData();
          aWedgemapHog.ScalarVisibilityOff();
          aWedgehogActor = new vtkActor();
          aWedgehogActor.SetMapper(aWedgemapHog);
          aWedgehogActor.GetProperty().SetColor(0,1,0);
          aWedgeGlyph3D = new vtkGlyph3D();
          aWedgeGlyph3D.SetInputConnection(aWedgeCenters.GetOutputPort());
          aWedgeGlyph3D.SetSource(ball.GetOutput());
          aWedgeCentersMapper = vtkPolyDataMapper.New();
          aWedgeCentersMapper.SetInputConnection(aWedgeGlyph3D.GetOutputPort());
          aWedgeCentersActor = new vtkActor();
          aWedgeCentersActor.SetMapper(aWedgeCentersMapper);
          aWedgehogActor.SetPosition(aWedgeActor.GetPosition()[0],aWedgeActor.GetPosition()[1],aWedgeActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aWedgehogActor);
          aWedgehogActor.GetProperty().SetRepresentationToWireframe();

        aPyramidderivs = new vtkCellDerivatives();
          aPyramidderivs.SetInput(aPyramidGrid);
          aPyramidderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPyramid";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPyramidWriter = new vtkUnstructuredGridWriter();
          aPyramidWriter.SetInputConnection(aPyramidderivs.GetOutputPort());
          aPyramidWriter.SetFileName(FileName);
          aPyramidWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPyramidCenters = new vtkCellCenters();
          aPyramidCenters.SetInputConnection(aPyramidderivs.GetOutputPort());
          aPyramidCenters.VertexCellsOn();
          aPyramidhog = new vtkHedgeHog();
          aPyramidhog.SetInputConnection(aPyramidCenters.GetOutputPort());
          aPyramidmapHog = vtkPolyDataMapper.New();
          aPyramidmapHog.SetInputConnection(aPyramidhog.GetOutputPort());
          aPyramidmapHog.SetScalarModeToUseCellData();
          aPyramidmapHog.ScalarVisibilityOff();
          aPyramidhogActor = new vtkActor();
          aPyramidhogActor.SetMapper(aPyramidmapHog);
          aPyramidhogActor.GetProperty().SetColor(0,1,0);
          aPyramidGlyph3D = new vtkGlyph3D();
          aPyramidGlyph3D.SetInputConnection(aPyramidCenters.GetOutputPort());
          aPyramidGlyph3D.SetSource(ball.GetOutput());
          aPyramidCentersMapper = vtkPolyDataMapper.New();
          aPyramidCentersMapper.SetInputConnection(aPyramidGlyph3D.GetOutputPort());
          aPyramidCentersActor = new vtkActor();
          aPyramidCentersActor.SetMapper(aPyramidCentersMapper);
          aPyramidhogActor.SetPosition(aPyramidActor.GetPosition()[0],aPyramidActor.GetPosition()[1],aPyramidActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPyramidhogActor);
          aPyramidhogActor.GetProperty().SetRepresentationToWireframe();

        aTetraderivs = new vtkCellDerivatives();
          aTetraderivs.SetInput(aTetraGrid);
          aTetraderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aTetra";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aTetraWriter = new vtkUnstructuredGridWriter();
          aTetraWriter.SetInputConnection(aTetraderivs.GetOutputPort());
          aTetraWriter.SetFileName(FileName);
          aTetraWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aTetraCenters = new vtkCellCenters();
          aTetraCenters.SetInputConnection(aTetraderivs.GetOutputPort());
          aTetraCenters.VertexCellsOn();
          aTetrahog = new vtkHedgeHog();
          aTetrahog.SetInputConnection(aTetraCenters.GetOutputPort());
          aTetramapHog = vtkPolyDataMapper.New();
          aTetramapHog.SetInputConnection(aTetrahog.GetOutputPort());
          aTetramapHog.SetScalarModeToUseCellData();
          aTetramapHog.ScalarVisibilityOff();
          aTetrahogActor = new vtkActor();
          aTetrahogActor.SetMapper(aTetramapHog);
          aTetrahogActor.GetProperty().SetColor(0,1,0);
          aTetraGlyph3D = new vtkGlyph3D();
          aTetraGlyph3D.SetInputConnection(aTetraCenters.GetOutputPort());
          aTetraGlyph3D.SetSource(ball.GetOutput());
          aTetraCentersMapper = vtkPolyDataMapper.New();
          aTetraCentersMapper.SetInputConnection(aTetraGlyph3D.GetOutputPort());
          aTetraCentersActor = new vtkActor();
          aTetraCentersActor.SetMapper(aTetraCentersMapper);
          aTetrahogActor.SetPosition(aTetraActor.GetPosition()[0],aTetraActor.GetPosition()[1],aTetraActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aTetrahogActor);
          aTetrahogActor.GetProperty().SetRepresentationToWireframe();

        aQuadderivs = new vtkCellDerivatives();
          aQuadderivs.SetInput(aQuadGrid);
          aQuadderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aQuad";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aQuadWriter = new vtkUnstructuredGridWriter();
          aQuadWriter.SetInputConnection(aQuadderivs.GetOutputPort());
          aQuadWriter.SetFileName(FileName);
          aQuadWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aQuadCenters = new vtkCellCenters();
          aQuadCenters.SetInputConnection(aQuadderivs.GetOutputPort());
          aQuadCenters.VertexCellsOn();
          aQuadhog = new vtkHedgeHog();
          aQuadhog.SetInputConnection(aQuadCenters.GetOutputPort());
          aQuadmapHog = vtkPolyDataMapper.New();
          aQuadmapHog.SetInputConnection(aQuadhog.GetOutputPort());
          aQuadmapHog.SetScalarModeToUseCellData();
          aQuadmapHog.ScalarVisibilityOff();
          aQuadhogActor = new vtkActor();
          aQuadhogActor.SetMapper(aQuadmapHog);
          aQuadhogActor.GetProperty().SetColor(0,1,0);
          aQuadGlyph3D = new vtkGlyph3D();
          aQuadGlyph3D.SetInputConnection(aQuadCenters.GetOutputPort());
          aQuadGlyph3D.SetSource(ball.GetOutput());
          aQuadCentersMapper = vtkPolyDataMapper.New();
          aQuadCentersMapper.SetInputConnection(aQuadGlyph3D.GetOutputPort());
          aQuadCentersActor = new vtkActor();
          aQuadCentersActor.SetMapper(aQuadCentersMapper);
          aQuadhogActor.SetPosition(aQuadActor.GetPosition()[0],aQuadActor.GetPosition()[1],aQuadActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aQuadhogActor);
          aQuadhogActor.GetProperty().SetRepresentationToWireframe();

        aTrianglederivs = new vtkCellDerivatives();
          aTrianglederivs.SetInput(aTriangleGrid);
          aTrianglederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aTriangle";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aTriangleWriter = new vtkUnstructuredGridWriter();
          aTriangleWriter.SetInputConnection(aTrianglederivs.GetOutputPort());
          aTriangleWriter.SetFileName(FileName);
          aTriangleWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aTriangleCenters = new vtkCellCenters();
          aTriangleCenters.SetInputConnection(aTrianglederivs.GetOutputPort());
          aTriangleCenters.VertexCellsOn();
          aTrianglehog = new vtkHedgeHog();
          aTrianglehog.SetInputConnection(aTriangleCenters.GetOutputPort());
          aTrianglemapHog = vtkPolyDataMapper.New();
          aTrianglemapHog.SetInputConnection(aTrianglehog.GetOutputPort());
          aTrianglemapHog.SetScalarModeToUseCellData();
          aTrianglemapHog.ScalarVisibilityOff();
          aTrianglehogActor = new vtkActor();
          aTrianglehogActor.SetMapper(aTrianglemapHog);
          aTrianglehogActor.GetProperty().SetColor(0,1,0);
          aTriangleGlyph3D = new vtkGlyph3D();
          aTriangleGlyph3D.SetInputConnection(aTriangleCenters.GetOutputPort());
          aTriangleGlyph3D.SetSource(ball.GetOutput());
          aTriangleCentersMapper = vtkPolyDataMapper.New();
          aTriangleCentersMapper.SetInputConnection(aTriangleGlyph3D.GetOutputPort());
          aTriangleCentersActor = new vtkActor();
          aTriangleCentersActor.SetMapper(aTriangleCentersMapper);
          aTrianglehogActor.SetPosition(aTriangleActor.GetPosition()[0],aTriangleActor.GetPosition()[1],aTriangleActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aTrianglehogActor);
          aTrianglehogActor.GetProperty().SetRepresentationToWireframe();

        aTriangleStripderivs = new vtkCellDerivatives();
          aTriangleStripderivs.SetInput(aTriangleStripGrid);
          aTriangleStripderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aTriangleStrip";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aTriangleStripWriter = new vtkUnstructuredGridWriter();
          aTriangleStripWriter.SetInputConnection(aTriangleStripderivs.GetOutputPort());
          aTriangleStripWriter.SetFileName(FileName);
          aTriangleStripWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aTriangleStripCenters = new vtkCellCenters();
          aTriangleStripCenters.SetInputConnection(aTriangleStripderivs.GetOutputPort());
          aTriangleStripCenters.VertexCellsOn();
          aTriangleStriphog = new vtkHedgeHog();
          aTriangleStriphog.SetInputConnection(aTriangleStripCenters.GetOutputPort());
          aTriangleStripmapHog = vtkPolyDataMapper.New();
          aTriangleStripmapHog.SetInputConnection(aTriangleStriphog.GetOutputPort());
          aTriangleStripmapHog.SetScalarModeToUseCellData();
          aTriangleStripmapHog.ScalarVisibilityOff();
          aTriangleStriphogActor = new vtkActor();
          aTriangleStriphogActor.SetMapper(aTriangleStripmapHog);
          aTriangleStriphogActor.GetProperty().SetColor(0,1,0);
          aTriangleStripGlyph3D = new vtkGlyph3D();
          aTriangleStripGlyph3D.SetInputConnection(aTriangleStripCenters.GetOutputPort());
          aTriangleStripGlyph3D.SetSource(ball.GetOutput());
          aTriangleStripCentersMapper = vtkPolyDataMapper.New();
          aTriangleStripCentersMapper.SetInputConnection(aTriangleStripGlyph3D.GetOutputPort());
          aTriangleStripCentersActor = new vtkActor();
          aTriangleStripCentersActor.SetMapper(aTriangleStripCentersMapper);
          aTriangleStriphogActor.SetPosition(aTriangleStripActor.GetPosition()[0],aTriangleStripActor.GetPosition()[1],aTriangleStripActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aTriangleStriphogActor);
          aTriangleStriphogActor.GetProperty().SetRepresentationToWireframe();

        aLinederivs = new vtkCellDerivatives();
          aLinederivs.SetInput(aLineGrid);
          aLinederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aLine";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aLineWriter = new vtkUnstructuredGridWriter();
          aLineWriter.SetInputConnection(aLinederivs.GetOutputPort());
          aLineWriter.SetFileName(FileName);
          aLineWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aLineCenters = new vtkCellCenters();
          aLineCenters.SetInputConnection(aLinederivs.GetOutputPort());
          aLineCenters.VertexCellsOn();
          aLinehog = new vtkHedgeHog();
          aLinehog.SetInputConnection(aLineCenters.GetOutputPort());
          aLinemapHog = vtkPolyDataMapper.New();
          aLinemapHog.SetInputConnection(aLinehog.GetOutputPort());
          aLinemapHog.SetScalarModeToUseCellData();
          aLinemapHog.ScalarVisibilityOff();
          aLinehogActor = new vtkActor();
          aLinehogActor.SetMapper(aLinemapHog);
          aLinehogActor.GetProperty().SetColor(0,1,0);
          aLineGlyph3D = new vtkGlyph3D();
          aLineGlyph3D.SetInputConnection(aLineCenters.GetOutputPort());
          aLineGlyph3D.SetSource(ball.GetOutput());
          aLineCentersMapper = vtkPolyDataMapper.New();
          aLineCentersMapper.SetInputConnection(aLineGlyph3D.GetOutputPort());
          aLineCentersActor = new vtkActor();
          aLineCentersActor.SetMapper(aLineCentersMapper);
          aLinehogActor.SetPosition(aLineActor.GetPosition()[0],aLineActor.GetPosition()[1],aLineActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aLinehogActor);
          aLinehogActor.GetProperty().SetRepresentationToWireframe();

        aPolyLinederivs = new vtkCellDerivatives();
          aPolyLinederivs.SetInput(aPolyLineGrid);
          aPolyLinederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPolyLine";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPolyLineWriter = new vtkUnstructuredGridWriter();
          aPolyLineWriter.SetInputConnection(aPolyLinederivs.GetOutputPort());
          aPolyLineWriter.SetFileName(FileName);
          aPolyLineWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPolyLineCenters = new vtkCellCenters();
          aPolyLineCenters.SetInputConnection(aPolyLinederivs.GetOutputPort());
          aPolyLineCenters.VertexCellsOn();
          aPolyLinehog = new vtkHedgeHog();
          aPolyLinehog.SetInputConnection(aPolyLineCenters.GetOutputPort());
          aPolyLinemapHog = vtkPolyDataMapper.New();
          aPolyLinemapHog.SetInputConnection(aPolyLinehog.GetOutputPort());
          aPolyLinemapHog.SetScalarModeToUseCellData();
          aPolyLinemapHog.ScalarVisibilityOff();
          aPolyLinehogActor = new vtkActor();
          aPolyLinehogActor.SetMapper(aPolyLinemapHog);
          aPolyLinehogActor.GetProperty().SetColor(0,1,0);
          aPolyLineGlyph3D = new vtkGlyph3D();
          aPolyLineGlyph3D.SetInputConnection(aPolyLineCenters.GetOutputPort());
          aPolyLineGlyph3D.SetSource(ball.GetOutput());
          aPolyLineCentersMapper = vtkPolyDataMapper.New();
          aPolyLineCentersMapper.SetInputConnection(aPolyLineGlyph3D.GetOutputPort());
          aPolyLineCentersActor = new vtkActor();
          aPolyLineCentersActor.SetMapper(aPolyLineCentersMapper);
          aPolyLinehogActor.SetPosition(aPolyLineActor.GetPosition()[0],aPolyLineActor.GetPosition()[1],aPolyLineActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPolyLinehogActor);
          aPolyLinehogActor.GetProperty().SetRepresentationToWireframe();

        aVertexderivs = new vtkCellDerivatives();
          aVertexderivs.SetInput(aVertexGrid);
          aVertexderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aVertex";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aVertexWriter = new vtkUnstructuredGridWriter();
          aVertexWriter.SetInputConnection(aVertexderivs.GetOutputPort());
          aVertexWriter.SetFileName(FileName);
          aVertexWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aVertexCenters = new vtkCellCenters();
          aVertexCenters.SetInputConnection(aVertexderivs.GetOutputPort());
          aVertexCenters.VertexCellsOn();
          aVertexhog = new vtkHedgeHog();
          aVertexhog.SetInputConnection(aVertexCenters.GetOutputPort());
          aVertexmapHog = vtkPolyDataMapper.New();
          aVertexmapHog.SetInputConnection(aVertexhog.GetOutputPort());
          aVertexmapHog.SetScalarModeToUseCellData();
          aVertexmapHog.ScalarVisibilityOff();
          aVertexhogActor = new vtkActor();
          aVertexhogActor.SetMapper(aVertexmapHog);
          aVertexhogActor.GetProperty().SetColor(0,1,0);
          aVertexGlyph3D = new vtkGlyph3D();
          aVertexGlyph3D.SetInputConnection(aVertexCenters.GetOutputPort());
          aVertexGlyph3D.SetSource(ball.GetOutput());
          aVertexCentersMapper = vtkPolyDataMapper.New();
          aVertexCentersMapper.SetInputConnection(aVertexGlyph3D.GetOutputPort());
          aVertexCentersActor = new vtkActor();
          aVertexCentersActor.SetMapper(aVertexCentersMapper);
          aVertexhogActor.SetPosition(aVertexActor.GetPosition()[0],aVertexActor.GetPosition()[1],aVertexActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aVertexhogActor);
          aVertexhogActor.GetProperty().SetRepresentationToWireframe();

        aPolyVertexderivs = new vtkCellDerivatives();
          aPolyVertexderivs.SetInput(aPolyVertexGrid);
          aPolyVertexderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPolyVertex";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPolyVertexWriter = new vtkUnstructuredGridWriter();
          aPolyVertexWriter.SetInputConnection(aPolyVertexderivs.GetOutputPort());
          aPolyVertexWriter.SetFileName(FileName);
          aPolyVertexWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPolyVertexCenters = new vtkCellCenters();
          aPolyVertexCenters.SetInputConnection(aPolyVertexderivs.GetOutputPort());
          aPolyVertexCenters.VertexCellsOn();
          aPolyVertexhog = new vtkHedgeHog();
          aPolyVertexhog.SetInputConnection(aPolyVertexCenters.GetOutputPort());
          aPolyVertexmapHog = vtkPolyDataMapper.New();
          aPolyVertexmapHog.SetInputConnection(aPolyVertexhog.GetOutputPort());
          aPolyVertexmapHog.SetScalarModeToUseCellData();
          aPolyVertexmapHog.ScalarVisibilityOff();
          aPolyVertexhogActor = new vtkActor();
          aPolyVertexhogActor.SetMapper(aPolyVertexmapHog);
          aPolyVertexhogActor.GetProperty().SetColor(0,1,0);
          aPolyVertexGlyph3D = new vtkGlyph3D();
          aPolyVertexGlyph3D.SetInputConnection(aPolyVertexCenters.GetOutputPort());
          aPolyVertexGlyph3D.SetSource(ball.GetOutput());
          aPolyVertexCentersMapper = vtkPolyDataMapper.New();
          aPolyVertexCentersMapper.SetInputConnection(aPolyVertexGlyph3D.GetOutputPort());
          aPolyVertexCentersActor = new vtkActor();
          aPolyVertexCentersActor.SetMapper(aPolyVertexCentersMapper);
          aPolyVertexhogActor.SetPosition(aPolyVertexActor.GetPosition()[0],aPolyVertexActor.GetPosition()[1],aPolyVertexActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPolyVertexhogActor);
          aPolyVertexhogActor.GetProperty().SetRepresentationToWireframe();

        aPixelderivs = new vtkCellDerivatives();
          aPixelderivs.SetInput(aPixelGrid);
          aPixelderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPixel";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPixelWriter = new vtkUnstructuredGridWriter();
          aPixelWriter.SetInputConnection(aPixelderivs.GetOutputPort());
          aPixelWriter.SetFileName(FileName);
          aPixelWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPixelCenters = new vtkCellCenters();
          aPixelCenters.SetInputConnection(aPixelderivs.GetOutputPort());
          aPixelCenters.VertexCellsOn();
          aPixelhog = new vtkHedgeHog();
          aPixelhog.SetInputConnection(aPixelCenters.GetOutputPort());
          aPixelmapHog = vtkPolyDataMapper.New();
          aPixelmapHog.SetInputConnection(aPixelhog.GetOutputPort());
          aPixelmapHog.SetScalarModeToUseCellData();
          aPixelmapHog.ScalarVisibilityOff();
          aPixelhogActor = new vtkActor();
          aPixelhogActor.SetMapper(aPixelmapHog);
          aPixelhogActor.GetProperty().SetColor(0,1,0);
          aPixelGlyph3D = new vtkGlyph3D();
          aPixelGlyph3D.SetInputConnection(aPixelCenters.GetOutputPort());
          aPixelGlyph3D.SetSource(ball.GetOutput());
          aPixelCentersMapper = vtkPolyDataMapper.New();
          aPixelCentersMapper.SetInputConnection(aPixelGlyph3D.GetOutputPort());
          aPixelCentersActor = new vtkActor();
          aPixelCentersActor.SetMapper(aPixelCentersMapper);
          aPixelhogActor.SetPosition(aPixelActor.GetPosition()[0],aPixelActor.GetPosition()[1],aPixelActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPixelhogActor);
          aPixelhogActor.GetProperty().SetRepresentationToWireframe();

        aPolygonderivs = new vtkCellDerivatives();
          aPolygonderivs.SetInput(aPolygonGrid);
          aPolygonderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPolygon";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPolygonWriter = new vtkUnstructuredGridWriter();
          aPolygonWriter.SetInputConnection(aPolygonderivs.GetOutputPort());
          aPolygonWriter.SetFileName(FileName);
          aPolygonWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPolygonCenters = new vtkCellCenters();
          aPolygonCenters.SetInputConnection(aPolygonderivs.GetOutputPort());
          aPolygonCenters.VertexCellsOn();
          aPolygonhog = new vtkHedgeHog();
          aPolygonhog.SetInputConnection(aPolygonCenters.GetOutputPort());
          aPolygonmapHog = vtkPolyDataMapper.New();
          aPolygonmapHog.SetInputConnection(aPolygonhog.GetOutputPort());
          aPolygonmapHog.SetScalarModeToUseCellData();
          aPolygonmapHog.ScalarVisibilityOff();
          aPolygonhogActor = new vtkActor();
          aPolygonhogActor.SetMapper(aPolygonmapHog);
          aPolygonhogActor.GetProperty().SetColor(0,1,0);
          aPolygonGlyph3D = new vtkGlyph3D();
          aPolygonGlyph3D.SetInputConnection(aPolygonCenters.GetOutputPort());
          aPolygonGlyph3D.SetSource(ball.GetOutput());
          aPolygonCentersMapper = vtkPolyDataMapper.New();
          aPolygonCentersMapper.SetInputConnection(aPolygonGlyph3D.GetOutputPort());
          aPolygonCentersActor = new vtkActor();
          aPolygonCentersActor.SetMapper(aPolygonCentersMapper);
          aPolygonhogActor.SetPosition(aPolygonActor.GetPosition()[0],aPolygonActor.GetPosition()[1],aPolygonActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPolygonhogActor);
          aPolygonhogActor.GetProperty().SetRepresentationToWireframe();

        aPentaderivs = new vtkCellDerivatives();
          aPentaderivs.SetInput(aPentaGrid);
          aPentaderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPenta";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPentaWriter = new vtkUnstructuredGridWriter();
          aPentaWriter.SetInputConnection(aPentaderivs.GetOutputPort());
          aPentaWriter.SetFileName(FileName);
          aPentaWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPentaCenters = new vtkCellCenters();
          aPentaCenters.SetInputConnection(aPentaderivs.GetOutputPort());
          aPentaCenters.VertexCellsOn();
          aPentahog = new vtkHedgeHog();
          aPentahog.SetInputConnection(aPentaCenters.GetOutputPort());
          aPentamapHog = vtkPolyDataMapper.New();
          aPentamapHog.SetInputConnection(aPentahog.GetOutputPort());
          aPentamapHog.SetScalarModeToUseCellData();
          aPentamapHog.ScalarVisibilityOff();
          aPentahogActor = new vtkActor();
          aPentahogActor.SetMapper(aPentamapHog);
          aPentahogActor.GetProperty().SetColor(0,1,0);
          aPentaGlyph3D = new vtkGlyph3D();
          aPentaGlyph3D.SetInputConnection(aPentaCenters.GetOutputPort());
          aPentaGlyph3D.SetSource(ball.GetOutput());
          aPentaCentersMapper = vtkPolyDataMapper.New();
          aPentaCentersMapper.SetInputConnection(aPentaGlyph3D.GetOutputPort());
          aPentaCentersActor = new vtkActor();
          aPentaCentersActor.SetMapper(aPentaCentersMapper);
          aPentahogActor.SetPosition(aPentaActor.GetPosition()[0],aPentaActor.GetPosition()[1],aPentaActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPentahogActor);
          aPentahogActor.GetProperty().SetRepresentationToWireframe();

        aHexaderivs = new vtkCellDerivatives();
          aHexaderivs.SetInput(aHexaGrid);
          aHexaderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aHexa";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aHexaWriter = new vtkUnstructuredGridWriter();
          aHexaWriter.SetInputConnection(aHexaderivs.GetOutputPort());
          aHexaWriter.SetFileName(FileName);
          aHexaWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aHexaCenters = new vtkCellCenters();
          aHexaCenters.SetInputConnection(aHexaderivs.GetOutputPort());
          aHexaCenters.VertexCellsOn();
          aHexahog = new vtkHedgeHog();
          aHexahog.SetInputConnection(aHexaCenters.GetOutputPort());
          aHexamapHog = vtkPolyDataMapper.New();
          aHexamapHog.SetInputConnection(aHexahog.GetOutputPort());
          aHexamapHog.SetScalarModeToUseCellData();
          aHexamapHog.ScalarVisibilityOff();
          aHexahogActor = new vtkActor();
          aHexahogActor.SetMapper(aHexamapHog);
          aHexahogActor.GetProperty().SetColor(0,1,0);
          aHexaGlyph3D = new vtkGlyph3D();
          aHexaGlyph3D.SetInputConnection(aHexaCenters.GetOutputPort());
          aHexaGlyph3D.SetSource(ball.GetOutput());
          aHexaCentersMapper = vtkPolyDataMapper.New();
          aHexaCentersMapper.SetInputConnection(aHexaGlyph3D.GetOutputPort());
          aHexaCentersActor = new vtkActor();
          aHexaCentersActor.SetMapper(aHexaCentersMapper);
          aHexahogActor.SetPosition(aHexaActor.GetPosition()[0],aHexaActor.GetPosition()[1],aHexaActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aHexahogActor);
          aHexahogActor.GetProperty().SetRepresentationToWireframe();

          ren1.ResetCamera();
          ren1.GetActiveCamera().Azimuth((double)30);
          ren1.GetActiveCamera().Elevation((double)20);
          ren1.GetActiveCamera().Dolly((double)3.0);
          ren1.ResetCameraClippingRange();
          renWin.SetSize((int)300,(int)150);
          renWin.Render();
          // render the image[]
          //[]
          iren.Initialize();

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestFixedPointRayCasterNearest(String [] argv)
    {
        //Prefix Content is: ""

          // Create a gaussian[]
          gs = new vtkImageGaussianSource();
          gs.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          gs.SetMaximum((double)255.0);
          gs.SetStandardDeviation((double)5);
          gs.SetCenter((double)15,(double)15,(double)15);
          // threshold to leave a gap that should show up for[]
          // gradient opacity[]
          t = new vtkImageThreshold();
          t.SetInputConnection((vtkAlgorithmOutput)gs.GetOutputPort());
          t.ReplaceInOn();
          t.SetInValue((double)0);
          t.ThresholdBetween((double)150,(double)200);
          // Use a shift scale to convert to unsigned char[]
          ss = new vtkImageShiftScale();
          ss.SetInputConnection((vtkAlgorithmOutput)t.GetOutputPort());
          ss.SetOutputScalarTypeToUnsignedChar();
          // grid will be used for two component dependent[]
          grid0 = new vtkImageGridSource();
          grid0.SetDataScalarTypeToUnsignedChar();
          grid0.SetGridSpacing((int)10,(int)10,(int)10);
          grid0.SetLineValue((double)200);
          grid0.SetFillValue((double)10);
          grid0.SetDataExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          // use dilation to thicken the grid[]
          d = new vtkImageContinuousDilate3D();
          d.SetInputConnection((vtkAlgorithmOutput)grid0.GetOutputPort());
          d.SetKernelSize((int)3,(int)3,(int)3);
          // Now make a two component dependent[]
          iac = new vtkImageAppendComponents();
          iac.AddInput((vtkDataObject)d.GetOutput());
          iac.AddInput((vtkDataObject)ss.GetOutput());
          // Some more gaussians for the four component indepent case[]
          gs1 = new vtkImageGaussianSource();
          gs1.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          gs1.SetMaximum((double)255.0);
          gs1.SetStandardDeviation((double)4);
          gs1.SetCenter((double)5,(double)5,(double)5);
          t1 = new vtkImageThreshold();
          t1.SetInputConnection((vtkAlgorithmOutput)gs1.GetOutputPort());
          t1.ReplaceInOn();
          t1.SetInValue((double)0);
          t1.ThresholdBetween((double)150,(double)256);
          gs2 = new vtkImageGaussianSource();
          gs2.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          gs2.SetMaximum((double)255.0);
          gs2.SetStandardDeviation((double)4);
          gs2.SetCenter((double)12,(double)12,(double)12);
          gs3 = new vtkImageGaussianSource();
          gs3.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          gs3.SetMaximum((double)255.0);
          gs3.SetStandardDeviation((double)4);
          gs3.SetCenter((double)19,(double)19,(double)19);
          t3 = new vtkImageThreshold();
          t3.SetInputConnection((vtkAlgorithmOutput)gs3.GetOutputPort());
          t3.ReplaceInOn();
          t3.SetInValue((double)0);
          t3.ThresholdBetween((double)150,(double)256);
          gs4 = new vtkImageGaussianSource();
          gs4.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          gs4.SetMaximum((double)255.0);
          gs4.SetStandardDeviation((double)4);
          gs4.SetCenter((double)26,(double)26,(double)26);
          //tk window skipped..
          iac1 = new vtkImageAppendComponents();
          iac1.AddInput((vtkDataObject)t1.GetOutput());
          iac1.AddInput((vtkDataObject)gs2.GetOutput());
          iac2 = new vtkImageAppendComponents();
          iac2.AddInput((vtkDataObject)iac1.GetOutput());
          iac2.AddInput((vtkDataObject)t3.GetOutput());
          iac3 = new vtkImageAppendComponents();
          iac3.AddInput((vtkDataObject)iac2.GetOutput());
          iac3.AddInput((vtkDataObject)gs4.GetOutput());
          // create the four component dependend - []
          // use lines in x, y, z for colors[]
          gridR = new vtkImageGridSource();
          gridR.SetDataScalarTypeToUnsignedChar();
          gridR.SetGridSpacing((int)10,(int)100,(int)100);
          gridR.SetLineValue((double)250);
          gridR.SetFillValue((double)100);
          gridR.SetDataExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          dR = new vtkImageContinuousDilate3D();
          dR.SetInputConnection((vtkAlgorithmOutput)gridR.GetOutputPort());
          dR.SetKernelSize((int)2,(int)2,(int)2);
          gridG = new vtkImageGridSource();
          gridG.SetDataScalarTypeToUnsignedChar();
          gridG.SetGridSpacing((int)100,(int)10,(int)100);
          gridG.SetLineValue((double)250);
          gridG.SetFillValue((double)100);
          gridG.SetDataExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          dG = new vtkImageContinuousDilate3D();
          dG.SetInputConnection((vtkAlgorithmOutput)gridG.GetOutputPort());
          dG.SetKernelSize((int)2,(int)2,(int)2);
          gridB = new vtkImageGridSource();
          gridB.SetDataScalarTypeToUnsignedChar();
          gridB.SetGridSpacing((int)100,(int)100,(int)10);
          gridB.SetLineValue((double)0);
          gridB.SetFillValue((double)250);
          gridB.SetDataExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          dB = new vtkImageContinuousDilate3D();
          dB.SetInputConnection((vtkAlgorithmOutput)gridB.GetOutputPort());
          dB.SetKernelSize((int)2,(int)2,(int)2);
          // need some appending[]
          iacRG = new vtkImageAppendComponents();
          iacRG.AddInput((vtkDataObject)dR.GetOutput());
          iacRG.AddInput((vtkDataObject)dG.GetOutput());
          iacRGB = new vtkImageAppendComponents();
          iacRGB.AddInput((vtkDataObject)iacRG.GetOutput());
          iacRGB.AddInput((vtkDataObject)dB.GetOutput());
          iacRGBA = new vtkImageAppendComponents();
          iacRGBA.AddInput((vtkDataObject)iacRGB.GetOutput());
          iacRGBA.AddInput((vtkDataObject)ss.GetOutput());
          // We need a bunch of opacity functions[]
          // this one is a simple ramp to .2[]
          rampPoint2 = new vtkPiecewiseFunction();
          rampPoint2.AddPoint((double)0,(double)0.0);
          rampPoint2.AddPoint((double)255,(double)0.2);
          // this one is a simple ramp to 1[]
          ramp1 = new vtkPiecewiseFunction();
          ramp1.AddPoint((double)0,(double)0.0);
          ramp1.AddPoint((double)255,(double)1.0);
          // this one shows a sharp surface[]
          surface = new vtkPiecewiseFunction();
          surface.AddPoint((double)0,(double)0.0);
          surface.AddPoint((double)10,(double)0.0);
          surface.AddPoint((double)50,(double)1.0);
          surface.AddPoint((double)255,(double)1.0);
          // this one is constant 1[]
          constant1 = new vtkPiecewiseFunction();
          constant1.AddPoint((double)0,(double)1.0);
          constant1.AddPoint((double)255,(double)1.0);
          // this one is used for gradient opacity[]
          gop = new vtkPiecewiseFunction();
          gop.AddPoint((double)0,(double)0.0);
          gop.AddPoint((double)20,(double)0.0);
          gop.AddPoint((double)60,(double)1.0);
          gop.AddPoint((double)255,(double)1.0);
          // We need a bunch of color functions[]
          // This one is a simple rainbow[]
          rainbow = new vtkColorTransferFunction();
          rainbow.SetColorSpaceToHSV();
          rainbow.HSVWrapOff();
          rainbow.AddHSVPoint((double)0,(double)0.1,(double)1.0,(double)1.0);
          rainbow.AddHSVPoint((double)255,(double)0.9,(double)1.0,(double)1.0);
          // this is constant red[]
          red = new vtkColorTransferFunction();
          red.AddRGBPoint((double)0,(double)1,(double)0,(double)0);
          red.AddRGBPoint((double)255,(double)1,(double)0,(double)0);
          // this is constant green[]
          green = new vtkColorTransferFunction();
          green.AddRGBPoint((double)0,(double)0,(double)1,(double)0);
          green.AddRGBPoint((double)255,(double)0,(double)1,(double)0);
          // this is constant blue[]
          blue = new vtkColorTransferFunction();
          blue.AddRGBPoint((double)0,(double)0,(double)0,(double)1);
          blue.AddRGBPoint((double)255,(double)0,(double)0,(double)1);
          // this is constant yellow[]
          yellow = new vtkColorTransferFunction();
          yellow.AddRGBPoint((double)0,(double)1,(double)1,(double)0);
          yellow.AddRGBPoint((double)255,(double)1,(double)1,(double)0);
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          renWin.SetSize((int)500,(int)500);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          ren1.GetCullers().InitTraversal();
          culler = (vtkFrustumCoverageCuller)ren1.GetCullers().GetNextItem();
          culler.SetSortingStyleToBackToFront();
          // We need 25 mapper / actor pairs which we will render[]
          // in a grid. Going down we will vary the input data[]
          // with the top row unsigned char, then float, then[]
          // two dependent components, then four dependent components[]
          // then four independent components. Going across we[]
          // will vary the rendering method with MIP, Composite,[]
          // Composite Shade, Composite GO, and Composite GO Shade.[]
          j = 0;
          while((j) < 5)
        {
          i = 0;
          while((i) < 5)
        {
          volumeProperty[i,j] = new vtkVolumeProperty();
          volumeMapper[i,j] = new vtkFixedPointVolumeRayCastMapper();
          volumeMapper[i,j].SetSampleDistance((float)0.25);
          volume[i,j] = new vtkVolume();
          volume[i,j].SetMapper((vtkAbstractVolumeMapper)volumeMapper[i,j]);
          volume[i,j].SetProperty((vtkVolumeProperty)volumeProperty[i,j]);
          volume[i,j].AddPosition((double)i*30,(double)j*30,(double)0);
          ren1.AddVolume((vtkProp)volume[i,j]);
          i = i + 1;
        }

          j = j + 1;
        }

          i = 0;
          while((i) < 5)
        {
          volumeMapper[0,i].SetInputConnection(t.GetOutputPort());
          volumeMapper[1,i].SetInputConnection(ss.GetOutputPort());
          volumeMapper[2,i].SetInputConnection(iac.GetOutputPort());
          volumeMapper[3,i].SetInputConnection(iac3.GetOutputPort());
          volumeMapper[4,i].SetInputConnection(iacRGBA.GetOutputPort());
          volumeMapper[i,0].SetBlendModeToMaximumIntensity();
          volumeMapper[i,1].SetBlendModeToComposite();
          volumeMapper[i,2].SetBlendModeToComposite();
          volumeMapper[i,3].SetBlendModeToComposite();
          volumeMapper[i,4].SetBlendModeToComposite();
          volumeProperty[0,i].IndependentComponentsOn();
          volumeProperty[1,i].IndependentComponentsOn();
          volumeProperty[2,i].IndependentComponentsOff();
          volumeProperty[3,i].IndependentComponentsOn();
          volumeProperty[4,i].IndependentComponentsOff();
          volumeProperty[0,i].SetColor(rainbow);
          volumeProperty[0,i].SetScalarOpacity(rampPoint2);
          volumeProperty[0,i].SetGradientOpacity(constant1);
          volumeProperty[1,i].SetColor(rainbow);
          volumeProperty[1,i].SetScalarOpacity(rampPoint2);
          volumeProperty[1,i].SetGradientOpacity(constant1);
          volumeProperty[2,i].SetColor(rainbow);
          volumeProperty[2,i].SetScalarOpacity(rampPoint2);
          volumeProperty[2,i].SetGradientOpacity(constant1);
          volumeProperty[3,i].SetColor(0, red);
          volumeProperty[3,i].SetColor(1, green);
          volumeProperty[3,i].SetColor(2, blue );
          volumeProperty[3,i].SetColor(3, yellow);
          volumeProperty[3,i].SetScalarOpacity(0,rampPoint2);
          volumeProperty[3,i].SetScalarOpacity(1,rampPoint2);
          volumeProperty[3,i].SetScalarOpacity(2,rampPoint2);
          volumeProperty[3,i].SetScalarOpacity(3,rampPoint2);
          volumeProperty[3,i].SetGradientOpacity(0,constant1);
          volumeProperty[3,i].SetGradientOpacity(1,constant1);
          volumeProperty[3,i].SetGradientOpacity(2,constant1);
          volumeProperty[3,i].SetGradientOpacity(3,constant1);
          volumeProperty[3,i].SetComponentWeight(0,1);
          volumeProperty[3,i].SetComponentWeight(1,1);
          volumeProperty[3,i].SetComponentWeight(2,1);
          volumeProperty[3,i].SetComponentWeight(3,1);
          volumeProperty[4,i].SetColor(rainbow);
          volumeProperty[4,i].SetScalarOpacity(rampPoint2);
          volumeProperty[4,i].SetGradientOpacity(constant1);
          volumeProperty[i,2].ShadeOn();
          volumeProperty[i,4].ShadeOn((int)0);
          volumeProperty[i,4].ShadeOn((int)1);
          volumeProperty[i,4].ShadeOn((int)2);
          volumeProperty[i,4].ShadeOn((int)3);
          i = i + 1;
        }

          volumeProperty[0,0].SetScalarOpacity((vtkPiecewiseFunction)ramp1);
          volumeProperty[1,0].SetScalarOpacity((vtkPiecewiseFunction)ramp1);
          volumeProperty[2,0].SetScalarOpacity((vtkPiecewiseFunction)ramp1);
          volumeProperty[3,0].SetScalarOpacity((int)0,(vtkPiecewiseFunction)surface);
          volumeProperty[3,0].SetScalarOpacity((int)1,(vtkPiecewiseFunction)surface);
          volumeProperty[3,0].SetScalarOpacity((int)2,(vtkPiecewiseFunction)surface);
          volumeProperty[3,0].SetScalarOpacity((int)3,(vtkPiecewiseFunction)surface);
          volumeProperty[4,0].SetScalarOpacity((vtkPiecewiseFunction)ramp1);
          volumeProperty[0,2].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[1,2].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[2,2].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[3,2].SetScalarOpacity((int)0,(vtkPiecewiseFunction)surface);
          volumeProperty[3,2].SetScalarOpacity((int)1,(vtkPiecewiseFunction)surface);
          volumeProperty[3,2].SetScalarOpacity((int)2,(vtkPiecewiseFunction)surface);
          volumeProperty[3,2].SetScalarOpacity((int)3,(vtkPiecewiseFunction)surface);
          volumeProperty[4,2].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[0,4].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[1,4].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[2,4].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[3,4].SetScalarOpacity((int)0,(vtkPiecewiseFunction)surface);
          volumeProperty[3,4].SetScalarOpacity((int)1,(vtkPiecewiseFunction)surface);
          volumeProperty[3,4].SetScalarOpacity((int)2,(vtkPiecewiseFunction)surface);
          volumeProperty[3,4].SetScalarOpacity((int)3,(vtkPiecewiseFunction)surface);
          volumeProperty[4,4].SetScalarOpacity((vtkPiecewiseFunction)surface);
          volumeProperty[0,3].SetGradientOpacity((vtkPiecewiseFunction)gop);
          volumeProperty[1,3].SetGradientOpacity((vtkPiecewiseFunction)gop);
          volumeProperty[2,3].SetGradientOpacity((vtkPiecewiseFunction)gop);
          volumeProperty[3,3].SetGradientOpacity((int)0,(vtkPiecewiseFunction)gop);
          volumeProperty[3,3].SetGradientOpacity((int)2,(vtkPiecewiseFunction)gop);
          volumeProperty[4,3].SetGradientOpacity((vtkPiecewiseFunction)gop);
          volumeProperty[3,3].SetScalarOpacity((int)0,(vtkPiecewiseFunction)ramp1);
          volumeProperty[3,3].SetScalarOpacity((int)2,(vtkPiecewiseFunction)ramp1);
          volumeProperty[0,4].SetGradientOpacity((vtkPiecewiseFunction)gop);
          volumeProperty[1,4].SetGradientOpacity((vtkPiecewiseFunction)gop);
          volumeProperty[2,4].SetGradientOpacity((vtkPiecewiseFunction)gop);
          volumeProperty[3,4].SetGradientOpacity((int)0,(vtkPiecewiseFunction)gop);
          volumeProperty[3,4].SetGradientOpacity((int)2,(vtkPiecewiseFunction)gop);
          volumeProperty[4,4].SetGradientOpacity((vtkPiecewiseFunction)gop);
          renWin.Render();
          ren1.GetActiveCamera().Dolly((double)1.3);
          ren1.GetActiveCamera().Azimuth((double)15);
          ren1.GetActiveCamera().Elevation((double)5);
          ren1.ResetCameraClippingRange();
          iren.Initialize();

        //deleteAllVTKObjects();
    }
Beispiel #46
0
        private void Subdivision(string filePath)
        {
            vtkPolyData originalMesh;

            if (filePath != null)
            {
                vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New();
                reader.SetFileName(filePath);
                // Subdivision filters only work on triangles
                vtkTriangleFilter triangles = vtkTriangleFilter.New();
                triangles.SetInputConnection(reader.GetOutputPort());
                triangles.Update();
                originalMesh = triangles.GetOutput();
            }
            else
            {
                vtkSphereSource sphereSource = vtkSphereSource.New();
                sphereSource.Update();
                originalMesh = sphereSource.GetOutput();
            }
            Debug.WriteLine("Before subdivision");
            Debug.WriteLine("    There are " + originalMesh.GetNumberOfPoints()
                            + " points.");
            Debug.WriteLine("    There are " + originalMesh.GetNumberOfPolys()
                            + " triangles.");

            int numberOfViewports = 3;

            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;

            this.Size  = new System.Drawing.Size(200 * numberOfViewports + 12, 252);
            this.Text += " - Subdivision";
            Random rnd = new Random(2);
            int    numberOfSubdivisions = 2;

            // Create one text property for all
            vtkTextProperty textProperty = vtkTextProperty.New();

            textProperty.SetFontSize(14);
            textProperty.SetJustificationToCentered();

            for (int i = 0; i < numberOfViewports; i++)
            {
                // Note: Here we create a superclass pointer (vtkPolyDataAlgorithm) so that we can easily instantiate different
                // types of subdivision filters. Typically you would not want to do this, but rather create the pointer to be the type
                // filter you will actually use, e.g.
                // <vtkLinearSubdivisionFilter>  subdivisionFilter = <vtkLinearSubdivisionFilter>.New();
                vtkPolyDataAlgorithm subdivisionFilter;
                switch (i)
                {
                case 0:
                    subdivisionFilter = vtkLinearSubdivisionFilter.New();
                    ((vtkLinearSubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
                    break;

                case 1:
                    subdivisionFilter = vtkLoopSubdivisionFilter.New();
                    ((vtkLoopSubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
                    break;

                case 2:
                    subdivisionFilter = vtkButterflySubdivisionFilter.New();
                    ((vtkButterflySubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
                    break;

                default:
                    subdivisionFilter = vtkLinearSubdivisionFilter.New();
                    ((vtkLinearSubdivisionFilter)subdivisionFilter).SetNumberOfSubdivisions(numberOfSubdivisions);
                    break;
                }
#if VTK_MAJOR_VERSION_5
                subdivisionFilter.SetInputConnection(originalMesh.GetProducerPort());
#else
                subdivisionFilter.SetInputData(originalMesh);
#endif
                subdivisionFilter.Update();
                vtkRenderer renderer = vtkRenderer.New();
                renderWindow.AddRenderer(renderer);
                renderer.SetViewport((float)i / numberOfViewports, 0, (float)(i + 1) / numberOfViewports, 1);
                renderer.SetBackground(.2 + rnd.NextDouble() / 8, .3 + rnd.NextDouble() / 8, .4 + rnd.NextDouble() / 8);

                vtkTextMapper textMapper = vtkTextMapper.New();
                vtkActor2D    textActor  = vtkActor2D.New();
                textMapper.SetInput(subdivisionFilter.GetClassName());
                textMapper.SetTextProperty(textProperty);

                textActor.SetMapper(textMapper);
                textActor.SetPosition(100, 16);

                //Create a mapper and actor
                vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
                mapper.SetInputConnection(subdivisionFilter.GetOutputPort());
                vtkActor actor = vtkActor.New();
                actor.SetMapper(mapper);
                renderer.AddActor(actor);
                renderer.AddActor(textActor);
                renderer.ResetCamera();
            }
            renderWindow.Render();
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestBranchExtentTranslator(String [] argv)
    {
        //Prefix Content is: ""

          gauss = new vtkImageGaussianSource();
          gauss.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)2);
          gauss.SetCenter((double)18,(double)12,(double)0);
          gauss.SetMaximum((double)1.0);
          gauss.SetStandardDeviation((double)6.0);
          gauss.Update();
          translator = new vtkBranchExtentTranslator();
          translator.SetOriginalSource((vtkImageData)gauss.GetOutput());
          gauss.GetOutput().SetExtentTranslator((vtkExtentTranslator)translator);
          clip1 = new vtkImageClip();
          clip1.SetOutputWholeExtent((int)7,(int)28,(int)0,(int)15,(int)1,(int)1);
          clip1.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort());
          surf1 = new vtkDataSetSurfaceFilter();
          surf1.SetInputConnection((vtkAlgorithmOutput)clip1.GetOutputPort());
          tf1 = new vtkTriangleFilter();
          tf1.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort());
          mapper1 = vtkPolyDataMapper.New();
          mapper1.SetInputConnection((vtkAlgorithmOutput)tf1.GetOutputPort());
          mapper1.SetScalarRange((double)0,(double)1);
          mapper1.SetNumberOfPieces((int)4);
          mapper1.SetPiece((int)1);
          actor1 = new vtkActor();
          actor1.SetMapper((vtkMapper)mapper1);
          actor1.SetPosition((double)0,(double)0,(double)0);
          // For coverage, a case where all four sides get clipped by the whole extent.[]
          clip2 = new vtkImageClip();
          clip2.SetOutputWholeExtent((int)16,(int)18,(int)3,(int)10,(int)0,(int)0);
          clip2.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort());
          surf2 = new vtkDataSetSurfaceFilter();
          surf2.SetInputConnection((vtkAlgorithmOutput)clip2.GetOutputPort());
          tf2 = new vtkTriangleFilter();
          tf2.SetInputConnection((vtkAlgorithmOutput)surf2.GetOutputPort());
          mapper2 = vtkPolyDataMapper.New();
          mapper2.SetInputConnection((vtkAlgorithmOutput)tf2.GetOutputPort());
          mapper2.SetScalarRange((double)0,(double)1);
          mapper2.SetNumberOfPieces((int)4);
          mapper2.SetPiece((int)1);
          actor2 = new vtkActor();
          actor2.SetMapper((vtkMapper)mapper2);
          actor2.SetPosition((double)15,(double)0,(double)0);
          // nothing in intersection (empty case)[]
          clip3 = new vtkImageClip();
          clip3.SetOutputWholeExtent((int)1,(int)10,(int)0,(int)15,(int)0,(int)2);
          clip3.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort());
          surf3 = new vtkDataSetSurfaceFilter();
          surf3.SetInputConnection((vtkAlgorithmOutput)clip3.GetOutputPort());
          tf3 = new vtkTriangleFilter();
          tf3.SetInputConnection((vtkAlgorithmOutput)surf3.GetOutputPort());
          mapper3 = vtkPolyDataMapper.New();
          mapper3.SetInputConnection((vtkAlgorithmOutput)tf3.GetOutputPort());
          mapper3.SetScalarRange((double)0,(double)1);
          mapper3.SetNumberOfPieces((int)4);
          mapper3.SetPiece((int)1);
          actor3 = new vtkActor();
          actor3.SetMapper((vtkMapper)mapper3);
          actor3.SetPosition((double)30,(double)0,(double)0);
          ren = vtkRenderer.New();
          ren.AddActor((vtkProp)actor1);
          ren.AddActor((vtkProp)actor2);
          ren.AddActor((vtkProp)actor3);
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren);
          //set cam [ren GetActiveCamera][]
          //ren ResetCamera[]
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          iren.Initialize();
          renWin.Render();
          // break loop to avoid a memory leak.[]
          translator.SetOriginalSource(null);

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVExtractTensors(String [] argv)
    {
        //Prefix Content is: ""

          // create tensor ellipsoids[]
          // Create the RenderWindow, Renderer and interactive renderer[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)30,(int)30,(int)30);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          extractTensor = new vtkExtractTensorComponents();
          extractTensor.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          extractTensor.ScalarIsEffectiveStress();
          extractTensor.ScalarIsComponent();
          extractTensor.ExtractScalarsOn();
          extractTensor.ExtractVectorsOn();
          extractTensor.ExtractNormalsOff();
          extractTensor.ExtractTCoordsOn();
          contour = new vtkContourFilter();
          contour.SetInputConnection((vtkAlgorithmOutput)extractTensor.GetOutputPort());
          contour.SetValue((int)0,(double)0);
          probe = new vtkProbeFilter();
          probe.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort());
          probe.SetSource((vtkDataObject)ptLoad.GetOutput());
          su = new vtkLoopSubdivisionFilter();
          su.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort());
          su.SetNumberOfSubdivisions((int)1);
          s1Mapper = vtkPolyDataMapper.New();
          s1Mapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort());
          //    s1Mapper SetInputConnection [su GetOutputPort][]
          s1Actor = new vtkActor();
          s1Actor.SetMapper((vtkMapper)s1Mapper);
          //[]
          // plane for context[]
          //[]
          g = new vtkImageDataGeometryFilter();
          g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          g.Update();
          //for scalar range[]
          gm = vtkPolyDataMapper.New();
          gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
          gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
          ga = new vtkActor();
          ga.SetMapper((vtkMapper)gm);
          s1Mapper.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
          //[]
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          //[]
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor((vtkProp)s1Actor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.AddActor((vtkProp)ga);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)300,(int)300);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Beispiel #49
0
        static void Main(string[] args)
        {
            //
            // Next we create an instance of vtkConeSource and set some of its
            // properties. The instance of vtkConeSource "cone" is part of a visualization
            // pipeline (it is a source process object); it produces data (output type is
            // vtkPolyData) which other filters may process.
            //
            vtkConeSource cone = new vtkConeSource();
            cone.SetHeight( 3.0f );
            cone.SetRadius( 1.0f );
            cone.SetResolution( 10 );

            //
            // In this example we terminate the pipeline with a mapper process object.
            // (Intermediate filters such as vtkShrinkPolyData could be inserted in
            // between the source and the mapper.)  We create an instance of
            // vtkPolyDataMapper to map the polygonal data into graphics primitives. We
            // connect the output of the cone souece to the input of this mapper.
            //
            vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
            coneMapper.SetInput( cone.GetOutput() );

            //
            // Create an actor to represent the cone. The actor orchestrates rendering of
            // the mapper's graphics primitives. An actor also refers to properties via a
            // vtkProperty instance, and includes an internal transformation matrix. We
            // set this actor's mapper to be coneMapper which we created above.
            //
            vtkActor coneActor = new vtkActor();
            coneActor.SetMapper( coneMapper );

            //
            // Create the Renderer and assign actors to it. A renderer is like a
            // viewport. It is part or all of a window on the screen and it is
            // responsible for drawing the actors it has.  We also set the background
            // color here
            //
            vtkRenderer ren1 = new vtkRenderer();
            ren1.AddActor( coneActor );
            ren1.SetBackground( 0.1f, 0.2f, 0.4f );

            //
            // Finally we create the render window which will show up on the screen
            // We put our renderer into the render window using AddRenderer. We also
            // set the size to be 300 pixels by 300
            //
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer( ren1 );
            renWin.SetSize( 300, 300 );

            // Add an observer to the render window.
            ren1.AddObserver((uint) EventIds.StartEvent,
                new vtkDotNetCallback(PrintCameraPosition));

            //
            // now we loop over 360 degreeees and render the cone each time
            //
            for ( int i=0; i<360; i++ )
            {
                System.Threading.Thread.Sleep(30);

                renWin.Render();
                ren1.GetActiveCamera().Azimuth( 1 );
            }

            vtkWin32OpenGLRenderWindow win32win =
                vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
            if (null != win32win) win32win.Clean();
        }
Beispiel #50
0
        private void QuadricDecimation()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            vtkPolyData input = vtkPolyData.New();

            input.ShallowCopy(sphereSource.GetOutput());

            Debug.WriteLine("Before decimation" + Environment.NewLine + "------------");
            Debug.WriteLine("There are " + input.GetNumberOfPoints() + " points.");
            Debug.WriteLine("There are " + input.GetNumberOfPolys() + " polygons.");

            vtkQuadricDecimation decimate = vtkQuadricDecimation.New();

#if VTK_MAJOR_VERSION_5
            decimate.SetInputConnection(input.GetProducerPort());
#else
            decimate.SetInputData(input);
#endif
            decimate.Update();

            vtkPolyData decimated = vtkPolyData.New();
            decimated.ShallowCopy(decimate.GetOutput());

            Debug.WriteLine("After decimation" + Environment.NewLine + "------------");

            Debug.WriteLine("There are " + decimated.GetNumberOfPoints() + " points.");
            Debug.WriteLine("There are " + decimated.GetNumberOfPolys() + " polygons.");

            vtkPolyDataMapper inputMapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            inputMapper.SetInputConnection(input.GetProducerPort());
#else
            inputMapper.SetInputData(input);
#endif
            vtkActor inputActor = vtkActor.New();
            inputActor.SetMapper(inputMapper);

            vtkPolyDataMapper decimatedMapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            decimatedMapper.SetInputConnection(decimated.GetProducerPort());
#else
            decimatedMapper.SetInputData(decimated);
#endif
            vtkActor decimatedActor = vtkActor.New();
            decimatedActor.SetMapper(decimatedMapper);

            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            this.Size = new System.Drawing.Size(612, 352);

            // Define viewport ranges
            // (xmin, ymin, xmax, ymax)
            double[] leftViewport  = new double[] { 0.0, 0.0, 0.5, 1.0 };
            double[] rightViewport = new double[] { 0.5, 0.0, 1.0, 1.0 };

            // Setup both renderers
            vtkRenderer leftRenderer = vtkRenderer.New();
            renderWindow.AddRenderer(leftRenderer);
            leftRenderer.SetViewport(leftViewport[0], leftViewport[1], leftViewport[2], leftViewport[3]);
            leftRenderer.SetBackground(.6, .5, .4);

            vtkRenderer rightRenderer = vtkRenderer.New();
            renderWindow.AddRenderer(rightRenderer);
            rightRenderer.SetViewport(rightViewport[0], rightViewport[1], rightViewport[2], rightViewport[3]);
            rightRenderer.SetBackground(.4, .5, .6);

            // Add the sphere to the left and the cube to the right
            leftRenderer.AddActor(inputActor);
            rightRenderer.AddActor(decimatedActor);
            leftRenderer.ResetCamera();
            rightRenderer.ResetCamera();
            renderWindow.Render();
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVgaussian(String [] argv)
    {
        //Prefix Content is: ""

          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          renWin.SetSize((int)300,(int)300);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          camera = new vtkCamera();
          camera.ParallelProjectionOn();
          camera.SetViewUp((double)0,(double)1,(double)0);
          camera.SetFocalPoint((double)12,(double)10.5,(double)15);
          camera.SetPosition((double)-70,(double)15,(double)34);
          camera.ComputeViewPlaneNormal();
          ren1.SetActiveCamera((vtkCamera)camera);
          // Create the reader for the data[]
          //vtkStructuredPointsReader reader[]
          reader = new vtkGaussianCubeReader();
          reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/m4_TotalDensity.cube");
          reader.SetHBScale((double)1.1);
          reader.SetBScale((double)10);
          reader.Update();
          range = reader.GetGridOutput().GetPointData().GetScalars().GetRange();
          min = (double)(lindex(range,0));
          max = (double)(lindex(range,1));
          readerSS = new vtkImageShiftScale();
          readerSS.SetInput((vtkDataObject)reader.GetGridOutput());
          readerSS.SetShift((double)min*-1);
          readerSS.SetScale((double)255/(max-min));
          readerSS.SetOutputScalarTypeToUnsignedChar();
          bounds = new vtkOutlineFilter();
          bounds.SetInput((vtkDataObject)reader.GetGridOutput());
          boundsMapper = vtkPolyDataMapper.New();
          boundsMapper.SetInputConnection((vtkAlgorithmOutput)bounds.GetOutputPort());
          boundsActor = new vtkActor();
          boundsActor.SetMapper((vtkMapper)boundsMapper);
          boundsActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          contour = new vtkContourFilter();
          contour.SetInput((vtkDataObject)reader.GetGridOutput());
          contour.GenerateValues((int)5,(double)0,(double).05);
          contourMapper = vtkPolyDataMapper.New();
          contourMapper.SetInputConnection((vtkAlgorithmOutput)contour.GetOutputPort());
          contourMapper.SetScalarRange((double)0,(double).1);
          ((vtkLookupTable)contourMapper.GetLookupTable()).SetHueRange(0.32,0);
          contourActor = new vtkActor();
          contourActor.SetMapper((vtkMapper)contourMapper);
          contourActor.GetProperty().SetOpacity((double).5);
          // Create transfer mapping scalar value to opacity[]
          opacityTransferFunction = new vtkPiecewiseFunction();
          opacityTransferFunction.AddPoint((double)0,(double)0.01);
          opacityTransferFunction.AddPoint((double)255,(double)0.35);
          opacityTransferFunction.ClampingOn();
          // Create transfer mapping scalar value to color[]
          colorTransferFunction = new vtkColorTransferFunction();
          colorTransferFunction.AddHSVPoint((double)0.0,(double)0.66,(double)1.0,(double)1.0);
          colorTransferFunction.AddHSVPoint((double)50.0,(double)0.33,(double)1.0,(double)1.0);
          colorTransferFunction.AddHSVPoint((double)100.0,(double)0.00,(double)1.0,(double)1.0);
          // The property describes how the data will look[]
          volumeProperty = new vtkVolumeProperty();
          volumeProperty.SetColor((vtkColorTransferFunction)colorTransferFunction);
          volumeProperty.SetScalarOpacity((vtkPiecewiseFunction)opacityTransferFunction);
          volumeProperty.SetInterpolationTypeToLinear();
          // The mapper / ray cast function know how to render the data[]
          compositeFunction = new vtkVolumeRayCastCompositeFunction();
          volumeMapper = new vtkVolumeRayCastMapper();
          //vtkVolumeTextureMapper2D volumeMapper[]
          volumeMapper.SetVolumeRayCastFunction((vtkVolumeRayCastFunction)compositeFunction);
          volumeMapper.SetInputConnection((vtkAlgorithmOutput)readerSS.GetOutputPort());
          // The volume holds the mapper and the property and[]
          // can be used to position/orient the volume[]
          volume = new vtkVolume();
          volume.SetMapper((vtkAbstractVolumeMapper)volumeMapper);
          volume.SetProperty((vtkVolumeProperty)volumeProperty);
          ren1.AddVolume((vtkProp)volume);
          //ren1 AddActor contourActor[]
          ren1.AddActor((vtkProp)boundsActor);
          //#####################################################################[]
          Sphere = new vtkSphereSource();
          Sphere.SetCenter((double)0,(double)0,(double)0);
          Sphere.SetRadius((double)1);
          Sphere.SetThetaResolution((int)16);
          Sphere.SetStartTheta((double)0);
          Sphere.SetEndTheta((double)360);
          Sphere.SetPhiResolution((int)16);
          Sphere.SetStartPhi((double)0);
          Sphere.SetEndPhi((double)180);
          Glyph = new vtkGlyph3D();
          Glyph.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          Glyph.SetOrient((int)1);
          Glyph.SetColorMode((int)1);
          //Glyph ScalingOn[]
          Glyph.SetScaleMode((int)2);
          Glyph.SetScaleFactor((double).6);
          Glyph.SetSource((vtkPolyData)Sphere.GetOutput());
          AtomsMapper = vtkPolyDataMapper.New();
          AtomsMapper.SetInputConnection((vtkAlgorithmOutput)Glyph.GetOutputPort());
          AtomsMapper.SetImmediateModeRendering((int)1);
          AtomsMapper.UseLookupTableScalarRangeOff();
          AtomsMapper.SetScalarVisibility((int)1);
          AtomsMapper.SetScalarModeToDefault();
          Atoms = new vtkActor();
          Atoms.SetMapper((vtkMapper)AtomsMapper);
          Atoms.GetProperty().SetRepresentationToSurface();
          Atoms.GetProperty().SetInterpolationToGouraud();
          Atoms.GetProperty().SetAmbient((double)0.15);
          Atoms.GetProperty().SetDiffuse((double)0.85);
          Atoms.GetProperty().SetSpecular((double)0.1);
          Atoms.GetProperty().SetSpecularPower((double)100);
          Atoms.GetProperty().SetSpecularColor((double)1,(double)1,(double)1);
          Atoms.GetProperty().SetColor((double)1,(double)1,(double)1);
          Tube = new vtkTubeFilter();
          Tube.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          Tube.SetNumberOfSides((int)16);
          Tube.SetCapping((int)0);
          Tube.SetRadius((double)0.2);
          Tube.SetVaryRadius((int)0);
          Tube.SetRadiusFactor((double)10);
          BondsMapper = vtkPolyDataMapper.New();
          BondsMapper.SetInputConnection((vtkAlgorithmOutput)Tube.GetOutputPort());
          BondsMapper.SetImmediateModeRendering((int)1);
          BondsMapper.UseLookupTableScalarRangeOff();
          BondsMapper.SetScalarVisibility((int)1);
          BondsMapper.SetScalarModeToDefault();
          Bonds = new vtkActor();
          Bonds.SetMapper((vtkMapper)BondsMapper);
          Bonds.GetProperty().SetRepresentationToSurface();
          Bonds.GetProperty().SetInterpolationToGouraud();
          Bonds.GetProperty().SetAmbient((double)0.15);
          Bonds.GetProperty().SetDiffuse((double)0.85);
          Bonds.GetProperty().SetSpecular((double)0.1);
          Bonds.GetProperty().SetSpecularPower((double)100);
          Bonds.GetProperty().SetSpecularColor((double)1,(double)1,(double)1);
          Bonds.GetProperty().SetColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)Bonds);
          ren1.AddActor((vtkProp)Atoms);
          //###################################################[]
          ren1.SetBackground((double)1,(double)1,(double)1);
          ren1.ResetCamera();
          renWin.Render();
          //method moved

          renWin.AbortCheckEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(TkCheckAbort_Command.Execute);
          iren.Initialize();

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVfieldToPolyData(String [] argv)
    {
        //Prefix Content is: ""

          // This example demonstrates the reading of a field and conversion to PolyData[]
          // The output should be the same as polyEx.tcl.[]
          // get the interactor ui[]
          // Create a reader and write out the field[]
          reader = new vtkPolyDataReader();
          reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/polyEx.vtk");
          ds2do = new vtkDataSetToDataObjectFilter();
          ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          try
          {
         channel = new StreamWriter("PolyField.vtk");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          writer = new vtkDataObjectWriter();
          writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort());
          writer.SetFileName((string)"PolyField.vtk");
          writer.Write();
          // create pipeline[]
          //[]
          dor = new vtkDataObjectReader();
          dor.SetFileName((string)"PolyField.vtk");
          do2ds = new vtkDataObjectToDataSetFilter();
          do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort());
          do2ds.SetDataSetTypeToPolyData();
          do2ds.SetPointComponent((int)0,(string)"Points",(int)0);
          do2ds.SetPointComponent((int)1,(string)"Points",(int)1);
          do2ds.SetPointComponent((int)2,(string)"Points",(int)2);
          do2ds.SetPolysComponent((string)"Polys",(int)0);
          fd2ad = new vtkFieldDataToAttributeDataFilter();
          fd2ad.SetInput((vtkDataObject)do2ds.GetPolyDataOutput());
          fd2ad.SetInputFieldToDataObjectField();
          fd2ad.SetOutputAttributeDataToPointData();
          fd2ad.SetScalarComponent((int)0,(string)"my_scalars",(int)0);
          mapper = vtkPolyDataMapper.New();
          mapper.SetInput((vtkPolyData)fd2ad.GetPolyDataOutput());
          mapper.SetScalarRange((double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)fd2ad.GetOutput()).GetScalarRange()[1]);
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          // Create the RenderWindow, Renderer and both Actors[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          ren1.AddActor((vtkProp)actor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)300,(int)300);
          ren1.ResetCamera();
          cam1 = ren1.GetActiveCamera();
          cam1.SetClippingRange((double).348,(double)17.43);
          cam1.SetPosition((double)2.92,(double)2.62,(double)-0.836);
          cam1.SetViewUp((double)-0.436,(double)-0.067,(double)-0.897);
          cam1.Azimuth((double)90);
          // render the image[]
          //[]
          renWin.Render();
          File.Delete("PolyField.vtk");

        }

          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestPolygonWriters(String [] argv)
    {
        //Prefix Content is: ""

          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // read data[]
          //[]
          input = new vtkPolyDataReader();
          input.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/brainImageSmooth.vtk");
          //[]
          // generate vectors[]
          clean = new vtkCleanPolyData();
          clean.SetInputConnection((vtkAlgorithmOutput)input.GetOutputPort());
          smooth = new vtkWindowedSincPolyDataFilter();
          smooth.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort());
          smooth.GenerateErrorVectorsOn();
          smooth.GenerateErrorScalarsOn();
          smooth.Update();
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          mapper.SetScalarRange((double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[0],
          (double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[1]);
          brain = new vtkActor();
          brain.SetMapper((vtkMapper)mapper);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)brain);
          renWin.SetSize((int)320,(int)240);
          ren1.GetActiveCamera().SetPosition((double)149.653,(double)-65.3464,(double)96.0401);
          ren1.GetActiveCamera().SetFocalPoint((double)146.003,(double)22.3839,(double)0.260541);
          ren1.GetActiveCamera().SetViewAngle((double)30);
          ren1.GetActiveCamera().SetViewUp((double)-0.255578,(double)-0.717754,(double)-0.647695);
          ren1.GetActiveCamera().SetClippingRange((double)79.2526,(double)194.052);
          iren.Initialize();
          renWin.Render();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]
          //[]
          // If the current directory is writable, then test the witers[]
          //[]
          try
          {
         channel = new StreamWriter("test.tmp");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          File.Delete("test.tmp");
          //[]
          //[]
          // test the writers[]
          dsw = new vtkDataSetWriter();
          dsw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          dsw.SetFileName((string)"brain.dsw");
          dsw.Write();
          File.Delete("brain.dsw");
          pdw = new vtkPolyDataWriter();
          pdw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          pdw.SetFileName((string)"brain.pdw");
          pdw.Write();
          File.Delete("brain.pdw");
          iv = new vtkIVWriter();
          iv.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          iv.SetFileName((string)"brain.iv");
          iv.Write();
          File.Delete("brain.iv");

          //[]
          // the next writers only handle triangles[]
          triangles = new vtkTriangleFilter();
          triangles.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          iv2 = new vtkIVWriter();
          iv2.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          iv2.SetFileName((string)"brain2.iv");
          iv2.Write();
          File.Delete("brain2.iv");

          edges = new vtkExtractEdges();
          edges.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          iv3 = new vtkIVWriter();
          iv3.SetInputConnection((vtkAlgorithmOutput)edges.GetOutputPort());
          iv3.SetFileName((string)"brain3.iv");
          iv3.Write();
          File.Delete("brain3.iv");

          byu = new vtkBYUWriter();
          byu.SetGeometryFileName((string)"brain.g");
          byu.SetScalarFileName((string)"brain.s");
          byu.SetDisplacementFileName((string)"brain.d");
          byu.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          byu.Write();
          File.Delete("brain.g");
          File.Delete("brain.s");
          File.Delete("brain.d");
          mcubes = new vtkMCubesWriter();
          mcubes.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          mcubes.SetFileName((string)"brain.tri");
          mcubes.SetLimitsFileName((string)"brain.lim");
          mcubes.Write();
          File.Delete("brain.lim");
          File.Delete("brain.tri");
          stl = new vtkSTLWriter();
          stl.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          stl.SetFileName((string)"brain.stl");
          stl.Write();
          File.Delete("brain.stl");
          stlBinary = new vtkSTLWriter();
          stlBinary.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          stlBinary.SetFileName((string)"brainBinary.stl");
          stlBinary.SetFileType((int)2);
          stlBinary.Write();
          File.Delete("brainBinary.stl");
        }

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVPlot3DVectors(String [] argv)
    {
        //Prefix Content is: ""

          //[]
          // All Plot3D vector functions[]
          //[]
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          renWin = vtkRenderWindow.New();
          ren1 = vtkRenderer.New();
          ren1.SetBackground((double).8,(double).8,(double).2);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          vectorLabels = "Velocity Vorticity Momentum Pressure_Gradient";
          vectorFunctions = "200 201 202 210";
          camera = new vtkCamera();
          light = new vtkLight();
          // All text actors will share the same text prop[]
          textProp = new vtkTextProperty();
          textProp.SetFontSize((int)10);
          textProp.SetFontFamilyToArial();
          textProp.SetColor((double).3,(double)1,(double)1);
          i = 0;
          foreach (string vectorFunction in vectorFunctions.Split(new char[]{' '}))
          {
          pl3d[getArrayIndex(vectorFunction)] = new vtkPLOT3DReader();
          pl3d[getArrayIndex(vectorFunction)].SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinxyz.bin");
          pl3d[getArrayIndex(vectorFunction)].SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinq.bin");
          pl3d[getArrayIndex(vectorFunction)].SetVectorFunctionNumber((int)(int)(getArrayIndex(vectorFunction)));
          pl3d[getArrayIndex(vectorFunction)].Update();
          plane[getArrayIndex(vectorFunction)] = new vtkStructuredGridGeometryFilter();
          plane[getArrayIndex(vectorFunction)].SetInputConnection((vtkAlgorithmOutput)pl3d[getArrayIndex(vectorFunction)].GetOutputPort());
          plane[getArrayIndex(vectorFunction)].SetExtent((int)25,(int)25,(int)0,(int)100,(int)0,(int)100);
          hog[getArrayIndex(vectorFunction)] = new vtkHedgeHog();
          hog[getArrayIndex(vectorFunction)].SetInputConnection((vtkAlgorithmOutput)plane[getArrayIndex(vectorFunction)].GetOutputPort());
          maxnorm = pl3d[getArrayIndex(vectorFunction)].GetOutput().GetPointData().GetVectors().GetMaxNorm();
          hog[getArrayIndex(vectorFunction)].SetScaleFactor((double)1.0/maxnorm);
          mapper[getArrayIndex(vectorFunction)] = vtkPolyDataMapper.New();
          mapper[getArrayIndex(vectorFunction)].SetInputConnection((vtkAlgorithmOutput)hog[getArrayIndex(vectorFunction)].GetOutputPort());
          actor[getArrayIndex(vectorFunction)] = new vtkActor();
          actor[getArrayIndex(vectorFunction)].SetMapper((vtkMapper)mapper[getArrayIndex(vectorFunction)]);
          ren[getArrayIndex(vectorFunction)] = vtkRenderer.New();
          ren[getArrayIndex(vectorFunction)].SetBackground((double)0.5,(double).5,(double).5);
          ren[getArrayIndex(vectorFunction)].SetActiveCamera((vtkCamera)camera);
          ren[getArrayIndex(vectorFunction)].AddLight((vtkLight)light);
          renWin.AddRenderer(ren[getArrayIndex(vectorFunction)]);
          ren[getArrayIndex(vectorFunction)].AddActor((vtkProp)actor[getArrayIndex(vectorFunction)]);
          textMapper[getArrayIndex(vectorFunction)] = new vtkTextMapper();
          textMapper[getArrayIndex(vectorFunction)].SetInput(vectorLabels.Split(new char[] { ' ' })[i]);
          textMapper[getArrayIndex(vectorFunction)].SetTextProperty((vtkTextProperty)textProp);
          text[getArrayIndex(vectorFunction)] = new vtkActor2D();
          text[getArrayIndex(vectorFunction)].SetMapper((vtkMapper2D)textMapper[getArrayIndex(vectorFunction)]);
          text[getArrayIndex(vectorFunction)].SetPosition((double)2,(double)5);

          ren[getArrayIndex(vectorFunction)].AddActor2D((vtkProp)text[getArrayIndex(vectorFunction)]);

          i = i + 1;

          }
          //[]
          // now layout renderers[]
          column = 1;
          row = 1;
          deltaX = 1.0/2.0;
          deltaY = 1.0/2.0;
          foreach (string vectorFunction in vectorFunctions.Split(new char[]{' '}))
          {
          ren[getArrayIndex(vectorFunction)].SetViewport((double)(column - 1) * deltaX + (deltaX * .05), (double)(row - 1) * deltaY + (deltaY * .05), (double)column * deltaX - (deltaX * .05), (double)row * deltaY - (deltaY * .05));
          column = column + 1;
          if ((column) > 2)
        {
          column = 1;
          row = row + 1;
        }

          }
          camera.SetViewUp((double)1,(double)0,(double)0);
          camera.SetFocalPoint((double)0,(double)0,(double)0);
          camera.SetPosition((double).4,(double)-.5,(double)-.75);
          ren[200].ResetCamera();
          camera.Dolly((double)1.25);
          ren[200].ResetCameraClippingRange();
          ren[201].ResetCameraClippingRange();
          ren[202].ResetCameraClippingRange();
          ren[210].ResetCameraClippingRange();
          light.SetPosition(camera.GetPosition()[0],camera.GetPosition()[1],camera.GetPosition()[2]);
          light.SetFocalPoint(camera.GetFocalPoint()[0],camera.GetFocalPoint()[1],camera.GetFocalPoint()[2]);
          renWin.SetSize(350,350);
          renWin.Render();
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
 /// <summary>
 /// Callback function for lineWidget2.InteractionEvt
 /// </summary>
 public static void GenerateStreamlines2(vtkObject sender, vtkObjectEventArgs e)
 {
     lineWidget2.GetPolyData(seeds2);
     renWin.Render();
 }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVcombStreamers2(String [] argv)
    {
        //Prefix Content is: ""

          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // create pipeline[]
          //[]
          pl3d = new vtkPLOT3DReader();
          pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin");
          pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin");
          pl3d.SetScalarFunctionNumber((int)100);
          pl3d.SetVectorFunctionNumber((int)202);
          pl3d.Update();
          ps = new vtkPlaneSource();
          ps.SetXResolution((int)4);
          ps.SetYResolution((int)4);
          ps.SetOrigin((double)2,(double)-2,(double)26);
          ps.SetPoint1((double)2,(double)2,(double)26);
          ps.SetPoint2((double)2,(double)-2,(double)32);
          psMapper = vtkPolyDataMapper.New();
          psMapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort());
          psActor = new vtkActor();
          psActor.SetMapper((vtkMapper)psMapper);
          psActor.GetProperty().SetRepresentationToWireframe();
          streamer = new vtkDashedStreamLine();
          streamer.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort());
          streamer.SetSource((vtkDataSet)ps.GetOutput());
          streamer.SetMaximumPropagationTime((double)100);
          streamer.SetIntegrationStepLength((double).2);
          streamer.SetStepLength((double).001);
          streamer.SetNumberOfThreads((int)1);
          streamer.SetIntegrationDirectionToForward();
          streamMapper = vtkPolyDataMapper.New();
          streamMapper.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          streamMapper.SetScalarRange(
          (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput()).GetScalarRange()[1]);
          streamline = new vtkActor();
          streamline.SetMapper((vtkMapper)streamMapper);
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)psActor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)streamline);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)300,(int)300);
          ren1.SetBackground((double)0.1,(double)0.2,(double)0.4);
          cam1 = ren1.GetActiveCamera();
          cam1.SetClippingRange((double)3.95297,(double)50);
          cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999);
          cam1.SetPosition((double)2.7439,(double)-37.3196,(double)38.7167);
          cam1.SetViewUp((double)-0.16123,(double)0.264271,(double)0.950876);
          // render the image[]
          //[]
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
        private void WindowedSincPolyDataFilter()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            vtkWindowedSincPolyDataFilter smoother = vtkWindowedSincPolyDataFilter.New();

            smoother.SetInputConnection(sphereSource.GetOutputPort());
            smoother.SetNumberOfIterations(15);
            smoother.BoundarySmoothingOff();
            smoother.FeatureEdgeSmoothingOff();
            smoother.SetFeatureAngle(120.0);
            smoother.SetPassBand(.001);
            smoother.NonManifoldSmoothingOn();
            smoother.NormalizeCoordinatesOn();
            smoother.Update();

            vtkPolyDataMapper smoothedMapper = vtkPolyDataMapper.New();

#if VTK_MAJOR_VERSION_5
            smoothedMapper.SetInputConnection(smoother.GetOutputPort());
#else
            smoothedMapper.SetInputData(smoother);
#endif
            vtkActor smoothedActor = vtkActor.New();
            smoothedActor.SetMapper(smoothedMapper);

            vtkPolyDataMapper inputMapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            inputMapper.SetInputConnection(sphereSource.GetOutputPort());
#else
            inputMapper.SetInputData(sphereSource);
#endif
            vtkActor inputActor = vtkActor.New();
            inputActor.SetMapper(inputMapper);

            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            this.Size = new System.Drawing.Size(612, 352);

            // Define viewport ranges
            // (xmin, ymin, xmax, ymax)
            double[] leftViewport  = new double[] { 0.0, 0.0, 0.5, 1.0 };
            double[] rightViewport = new double[] { 0.5, 0.0, 1.0, 1.0 };

            // Setup both renderers
            vtkRenderer leftRenderer = vtkRenderer.New();
            renderWindow.AddRenderer(leftRenderer);
            leftRenderer.SetViewport(leftViewport[0], leftViewport[1], leftViewport[2], leftViewport[3]);
            leftRenderer.SetBackground(.6, .5, .4);

            vtkRenderer rightRenderer = vtkRenderer.New();
            renderWindow.AddRenderer(rightRenderer);
            rightRenderer.SetViewport(rightViewport[0], rightViewport[1], rightViewport[2], rightViewport[3]);
            rightRenderer.SetBackground(.4, .5, .6);

            // Add the sphere to the left and the cube to the right
            leftRenderer.AddActor(inputActor);
            rightRenderer.AddActor(smoothedActor);
            leftRenderer.ResetCamera();
            rightRenderer.ResetCamera();
            renderWindow.Render();
        }
        static void Main(string[] args)
        {
            // create a sphere source, mapper, and actor
            vtkSphereSource sphere = new vtkSphereSource();
            vtkPolyDataMapper sphereMapper = new vtkPolyDataMapper();
            sphereMapper.SetInputConnection(sphere.GetOutputPort());
            vtkPolyDataMapper.GlobalImmediateModeRenderingOn();
            vtkLODActor sphereActor = new vtkLODActor();
            sphereActor.SetMapper(sphereMapper);

            // create the spikes by glyphing the sphere with a cone.  Create the
            // mapper and actor for the glyphs.
            vtkConeSource cone = new vtkConeSource();
            vtkGlyph3D glyph = new vtkGlyph3D();
            glyph.SetInputConnection(sphere.GetOutputPort());
            glyph.SetSource(cone.GetOutput());
            glyph.SetVectorModeToUseNormal();
            glyph.SetScaleModeToScaleByVector();
            glyph.SetScaleFactor(0.25);
            vtkPolyDataMapper spikeMapper = new vtkPolyDataMapper();
            spikeMapper.SetInputConnection(glyph.GetOutputPort());
            vtkLODActor spikeActor = new vtkLODActor();
            spikeActor.SetMapper(spikeMapper);

            // Create a text mapper and actor to display the results of picking.
            vtkTextMapper textMapper = new vtkTextMapper();
            vtkTextProperty tprop = textMapper.GetTextProperty();
            tprop.SetFontFamilyToArial();
            tprop.SetFontSize(10);
            tprop.BoldOn();
            tprop.ShadowOn();
            tprop.SetColor(1, 0, 0);
            vtkActor2D textActor = new vtkActor2D();
            textActor.VisibilityOff();
            textActor.SetMapper(textMapper);

            // Create a cell picker.
            vtkCellPicker picker = new vtkCellPicker();

            PickData pd = new PickData();
            pd.textActor = textActor;
            pd.textMapper = textMapper;
            vtkDotNetCallback cb = new vtkDotNetCallback(pd.annotatePickCallback);
            // Now at the end of the pick event call the above function.
            picker.AddObserver((uint) EventIds.EndPickEvent, cb);

            // Create the Renderer, RenderWindow, etc. and set the Picker.
            vtkRenderer ren = new vtkRenderer();
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer(ren);
            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);
            iren.SetPicker(picker);

            // Add the actors to the renderer, set the background and size
            ren.AddActor2D(textActor);
            ren.AddActor(sphereActor);
            ren.AddActor(spikeActor);
            ren.SetBackground(1, 1, 1);
            renWin.SetSize(300, 300);

            // Get the camera and zoom in closer to the image.
            ren.ResetCamera();
            vtkCamera cam1 = ren.GetActiveCamera();
            cam1.Zoom(1.4);

            iren.Initialize();
            // Initially pick the cell at this location.
            picker.Pick(85, 126, 0, ren);
            renWin.Render();

            iren.Start();

            vtkWin32OpenGLRenderWindow win32win =
                vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
            if (null != win32win) win32win.Clean();
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyperScalarBar(String [] argv)
    {
        //Prefix Content is: ""

          // Test the scalar bar actor using a logarithmic lookup table[]
          //[]
          VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
          //[]
          // generate tensors[]
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)20,(int)20,(int)20);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          // Generate hyperstreamlines[]
          s1 = new vtkHyperStreamline();
          s1.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s1.SetStartPosition((double)9,(double)9,(double)-9);
          s1.IntegrateMinorEigenvector();
          s1.SetMaximumPropagationDistance((double)18.0);
          s1.SetIntegrationStepLength((double)0.1);
          s1.SetStepLength((double)0.01);
          s1.SetRadius((double)0.25);
          s1.SetNumberOfSides((int)18);
          s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s1.Update();
          // Map hyperstreamlines[]
          lut = new vtkLogLookupTable();
          lut.SetHueRange((double).6667,(double)0.0);
          scalarBar = new vtkScalarBarActor();
          scalarBar.SetLookupTable((vtkScalarsToColors)lut);
          scalarBar.SetTitle((string)"Stress");
          scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport();
          scalarBar.GetPositionCoordinate().SetValue((double)0.1,(double)0.05);
          scalarBar.SetOrientationToVertical();
          scalarBar.SetWidth((double)0.1);
          scalarBar.SetHeight((double)0.9);
          scalarBar.SetPosition((double)0.01,(double)0.1);
          scalarBar.SetLabelFormat((string)"%-#6.3f");
          scalarBar.GetLabelTextProperty().SetColor((double)1,(double)0,(double)0);
          scalarBar.GetTitleTextProperty().SetColor((double)1,(double)0,(double)0);
          s1Mapper = vtkPolyDataMapper.New();
          s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
          s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
          ptLoad.Update();
          //force update for scalar range[]
          s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s1Actor = new vtkActor();
          s1Actor.SetMapper((vtkMapper)s1Mapper);
          s2 = new vtkHyperStreamline();
          s2.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s2.SetStartPosition((double)-9,(double)-9,(double)-9);
          s2.IntegrateMinorEigenvector();
          s2.SetMaximumPropagationDistance((double)18.0);
          s2.SetIntegrationStepLength((double)0.1);
          s2.SetStepLength((double)0.01);
          s2.SetRadius((double)0.25);
          s2.SetNumberOfSides((int)18);
          s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s2.Update();
          s2Mapper = vtkPolyDataMapper.New();
          s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
          s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s2Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s2Actor = new vtkActor();
          s2Actor.SetMapper((vtkMapper)s2Mapper);
          s3 = new vtkHyperStreamline();
          s3.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s3.SetStartPosition((double)9,(double)-9,(double)-9);
          s3.IntegrateMinorEigenvector();
          s3.SetMaximumPropagationDistance((double)18.0);
          s3.SetIntegrationStepLength((double)0.1);
          s3.SetStepLength((double)0.01);
          s3.SetRadius((double)0.25);
          s3.SetNumberOfSides((int)18);
          s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s3.Update();
          s3Mapper = vtkPolyDataMapper.New();
          s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
          s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s3Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s3Actor = new vtkActor();
          s3Actor.SetMapper((vtkMapper)s3Mapper);
          s4 = new vtkHyperStreamline();
          s4.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          s4.SetStartPosition((double)-9,(double)9,(double)-9);
          s4.IntegrateMinorEigenvector();
          s4.SetMaximumPropagationDistance((double)18.0);
          s4.SetIntegrationStepLength((double)0.1);
          s4.SetStepLength((double)0.01);
          s4.SetRadius((double)0.25);
          s4.SetNumberOfSides((int)18);
          s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s4.Update();
          s4Mapper = vtkPolyDataMapper.New();
          s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
          s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s4Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s4Actor = new vtkActor();
          s4Actor.SetMapper((vtkMapper)s4Mapper);
          // plane for context[]
          //[]
          g = new vtkImageDataGeometryFilter();
          g.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          g.Update();
          //for scalar range[]
          gm = vtkPolyDataMapper.New();
          gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
          gm.SetScalarRange((double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[0], (double)((vtkImageDataGeometryFilter)g).GetOutput().GetScalarRange()[1]);
          ga = new vtkActor();
          ga.SetMapper((vtkMapper)gm);
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          // Create the rendering infrastructure[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor2D((vtkProp)scalarBar);
          ren1.AddActor((vtkProp)s1Actor);
          ren1.AddActor((vtkProp)s2Actor);
          ren1.AddActor((vtkProp)s3Actor);
          ren1.AddActor((vtkProp)s4Actor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.AddActor((vtkProp)ga);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)300,(int)300);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }