Example #1
0
        public Sphere(ARenderable parent)
            : base(parent)
        {
            Name   = "Sphere";
            sphere = vtkSphereSource.New();
            sphere.SetThetaResolution(8);
            sphere.SetPhiResolution(16);

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

            move = vtkTransform.New();
            move.Translate(_random.NextDouble(), _random.NextDouble(), _random.NextDouble());
            moveFilter = vtkTransformPolyDataFilter.New();
            moveFilter.SetTransform(move);

            moveFilter.SetInputConnection(shrink.GetOutputPort());

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

            Actors = new ObservableCollection <vtkActor>();
            // The actor links the data pipeline to the rendering subsystem
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            actor.GetProperty().SetColor(1, 0, 0);
            Actors.Add(actor);
        }
Example #2
0
        private static void ClosedSurface()
        {
            // Create a sphere
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            vtkFeatureEdges featureEdges = vtkFeatureEdges.New();

            featureEdges.FeatureEdgesOff();
            featureEdges.BoundaryEdgesOn();
            featureEdges.NonManifoldEdgesOn();
            featureEdges.SetInputConnection(sphereSource.GetOutputPort());
            featureEdges.Update();

            int numberOfOpenEdges = featureEdges.GetOutput().GetNumberOfCells();

            if (numberOfOpenEdges > 0)
            {
                Console.WriteLine("Surface is not closed");
            }
            else
            {
                Console.WriteLine("Surface is closed");
            }
            // nothing to show graphically
            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }
Example #3
0
        private void ShrinkPolyData()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.SetRadius(10);
            sphereSource.SetPhiResolution(12);
            sphereSource.SetThetaResolution(12);
            sphereSource.Update();

            vtkShrinkPolyData shrinkFilter = vtkShrinkPolyData.New();

            shrinkFilter.SetInputConnection(sphereSource.GetOutputPort());
            shrinkFilter.Update();

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(shrinkFilter.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(.2, .3, .4);
            //Add the actors to the renderer, set the background and size
            renderer.AddActor(actor);
        }
Example #4
0
        private void Sphere()
        {
            // Create a sphere.
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.SetRadius(0.5);
            // a more smoother sphere
            //sphereSource.SetPhiResolution(36);
            //sphereSource.SetThetaResolution(36);

            //not a complete sphere, only a spherical shell
            //sphereSource.SetEndPhi(120);
            //sphereSource.SetEndTheta(90);

            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

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

            actor.SetMapper(mapper);
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.3, 0.2, 0.1);
            renderer.AddActor(actor);
        }
Example #5
0
        private void DrawSphere(double radius)
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.SetThetaResolution(8);
            sphereSource.SetPhiResolution(16);
            sphereSource.SetRadius(radius);

            vtkShrinkPolyData shrink = vtkShrinkPolyData.New();

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

            vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New();

            //sphereMapper.SetInputConnection(sphereSource.GetOutputPort());
            sphereMapper.SetInputConnection(shrink.GetOutputPort());

            vtkActor sphereActor = vtkActor.New();

            sphereActor.SetMapper(sphereMapper);
            sphereActor.GetProperty().SetColor(1, 0, 0);

            vtkRenderer     sphereRender = vtkRenderer.New();
            vtkRenderWindow renWin       = myRenderWindowControl.RenderWindow;

            renWin.AddRenderer(sphereRender);

            sphereRender.AddActor(sphereActor);
            sphereRender.SetBackground(0.0, 0.0, 1.0);
        }
        private void vtkPolyDataConnectivityFilter_LargestRegion()
        {
            // Small sphere
            vtkSphereSource sphereSource1 = vtkSphereSource.New();

            sphereSource1.Update();

            // Large sphere
            vtkSphereSource sphereSource2 = vtkSphereSource.New();

            sphereSource2.SetRadius(10);
            sphereSource2.SetCenter(25, 0, 0);
            sphereSource2.SetThetaResolution(10);
            sphereSource2.SetPhiResolution(10);
            sphereSource2.Update();

            vtkAppendPolyData appendFilter = vtkAppendPolyData.New();

            appendFilter.AddInputConnection(sphereSource1.GetOutputPort());
            appendFilter.AddInputConnection(sphereSource2.GetOutputPort());
            appendFilter.Update();

            vtkPolyDataConnectivityFilter connectivityFilter = vtkPolyDataConnectivityFilter.New();

            connectivityFilter.SetInputConnection(appendFilter.GetOutputPort());
            connectivityFilter.SetExtractionModeToLargestRegion();
            connectivityFilter.Update();

            // Create a mapper and actor for original data
            vtkPolyDataMapper originalMapper = vtkPolyDataMapper.New();

            originalMapper.SetInputConnection(appendFilter.GetOutputPort());
            originalMapper.Update();

            vtkActor originalActor = vtkActor.New();

            originalActor.SetMapper(originalMapper);

            // Create a mapper and actor for extracted data
            vtkPolyDataMapper extractedMapper = vtkPolyDataMapper.New();

            extractedMapper.SetInputConnection(connectivityFilter.GetOutputPort());
            extractedMapper.Update();

            vtkActor extractedActor = vtkActor.New();

            extractedActor.GetProperty().SetColor(1, 0, 0);
            extractedActor.SetMapper(extractedMapper);
            // 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.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(originalActor);
            renderer.AddActor(extractedActor);
        }
Example #7
0
        private void MarchingCubes()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

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

            double[] bounds = sphereSource.GetOutput().GetBounds();
            for (int i = 0; i < 6; i += 2)
            {
                double range = bounds[i + 1] - bounds[i];
                bounds[i]     = bounds[i] - .1 * range;
                bounds[i + 1] = bounds[i + 1] + .1 * range;
            }
            vtkVoxelModeller voxelModeller = vtkVoxelModeller.New();

            voxelModeller.SetSampleDimensions(50, 50, 50);
            voxelModeller.SetModelBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
            voxelModeller.SetScalarTypeToFloat();
            voxelModeller.SetMaximumDistance(.1);

#if VTK_MAJOR_VERSION_5
            voxelModeller.SetInputConnection(sphereSource.GetOutputPort());
#else
            voxelModeller.SetInputData(sphereSource);
#endif
            vtkMarchingCubes surface = vtkMarchingCubes.New();

#if VTK_MAJOR_VERSION_5
            surface.SetInputConnection(voxelModeller.GetOutputPort());
#else
            surface.SetInputData(voxelModeller);
#endif
            surface.ComputeNormalsOn();
            surface.SetValue(0, 0.5);
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            mapper.SetInputConnection(surface.GetOutputPort());
#else
            mapper.SetInputData(surface);
#endif
            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(.2, .3, .4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
Example #8
0
        private void ExtractEdges()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            Debug.WriteLine("Sphere" + Environment.NewLine + "----------");
            Debug.WriteLine("There are " + sphereSource.GetOutput().GetNumberOfCells() + " cells.");
            Debug.WriteLine("There are " + sphereSource.GetOutput().GetNumberOfPoints() + " points.");

            vtkExtractEdges extractEdges = vtkExtractEdges.New();

#if VTK_MAJOR_VERSION_5
            extractEdges.SetInputConnection(sphereSource.GetOutputPort());
#else
            extractEdges.SetInputData(sphereSource);
#endif
            extractEdges.Update();

            vtkCellArray lines  = extractEdges.GetOutput().GetLines();
            vtkPoints    points = extractEdges.GetOutput().GetPoints();

            Debug.WriteLine(Environment.NewLine + "Edges" + Environment.NewLine + "----------");
            Debug.WriteLine("There are " + lines.GetNumberOfCells() + " cells.");
            Debug.WriteLine("There are " + points.GetNumberOfPoints() + " points.");

            // Traverse all of the edges
            for (int i = 0; i < extractEdges.GetOutput().GetNumberOfCells(); i++)
            {
                //Debug.WriteLine("Type: " + extractEdges.GetOutput().GetCell(i).GetClassName() );
                vtkLine line = vtkLine.SafeDownCast(extractEdges.GetOutput().GetCell(i));
                Debug.WriteLine("Line " + i + " : " + line);
            }

            // Visualize the edges

            // Create a mapper and actor
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            mapper.SetInputConnection(extractEdges.GetOutputPort());
#else
            mapper.SetInputData(extractEdges);
#endif
            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(1, 1, 1);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
Example #9
0
        private void ColorDisconnectedRegions()
        {
            // Create some spheres
            vtkSphereSource sphereSource1 = vtkSphereSource.New();

            sphereSource1.Update();

            vtkSphereSource sphereSource2 = vtkSphereSource.New();

            sphereSource2.SetCenter(5, 0, 0);
            sphereSource2.Update();

            vtkSphereSource sphereSource3 = vtkSphereSource.New();

            sphereSource3.SetCenter(10, 0, 0);
            sphereSource3.Update();

            vtkAppendPolyData appendFilter = vtkAppendPolyData.New();

            appendFilter.AddInputConnection(sphereSource1.GetOutputPort());
            appendFilter.AddInputConnection(sphereSource2.GetOutputPort());
            appendFilter.AddInputConnection(sphereSource3.GetOutputPort());

            vtkPolyDataConnectivityFilter connectivityFilter = vtkPolyDataConnectivityFilter.New();

            connectivityFilter.SetInputConnection(appendFilter.GetOutputPort());
            connectivityFilter.SetExtractionModeToAllRegions();
            connectivityFilter.ColorRegionsOn();
            connectivityFilter.Update();

            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(connectivityFilter.GetOutputPort());
            double[] range = connectivityFilter.GetOutput().GetPointData().GetArray("RegionId").GetRange();
            mapper.SetScalarRange(range[0], range[1]);

            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.0, 0.0, 0.0);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestExtractVOI(String [] argv)
    {
        //Prefix Content is: ""

          // to mark the origin[]
          sphere = new vtkSphereSource();
          sphere.SetRadius((double)2.0);
          sphereMapper = vtkPolyDataMapper.New();
          sphereMapper.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          sphereMapper.ImmediateModeRenderingOn();
          sphereActor = new vtkActor();
          sphereActor.SetMapper((vtkMapper)sphereMapper);
          rt = new vtkRTAnalyticSource();
          rt.SetWholeExtent((int)-50,(int)50,(int)-50,(int)50,(int)0,(int)0);
          voi = new vtkExtractVOI();
          voi.SetInputConnection((vtkAlgorithmOutput)rt.GetOutputPort());
          voi.SetVOI((int)-11,(int)39,(int)5,(int)45,(int)0,(int)0);
          voi.SetSampleRate((int)5,(int)5,(int)1);
          // Get rid ambiguous triagulation issues.[]
          surf = new vtkDataSetSurfaceFilter();
          surf.SetInputConnection((vtkAlgorithmOutput)voi.GetOutputPort());
          tris = new vtkTriangleFilter();
          tris.SetInputConnection((vtkAlgorithmOutput)surf.GetOutputPort());
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort());
          mapper.ImmediateModeRenderingOn();
          mapper.SetScalarRange((double)130,(double)280);
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          ren = vtkRenderer.New();
          ren.AddActor((vtkProp)actor);
          ren.AddActor((vtkProp)sphereActor);
          ren.ResetCamera();
          camera = ren.GetActiveCamera();
          //$camera SetPosition 68.1939 -23.4323 12.6465[]
          //$camera SetViewUp 0.46563 0.882375 0.0678508  []
          //$camera SetFocalPoint 3.65707 11.4552 1.83509 []
          //$camera SetClippingRange 59.2626 101.825 []
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          iren.Initialize();

        //deleteAllVTKObjects();
    }
        private void PolyDataGetPoint()
        {
            // Create a sphere
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();
            vtkPolyData polydata = sphereSource.GetOutput();

            // Write all of the coordinates of the points in the vtkPolyData to the console.
            for (int i = 0; i < polydata.GetNumberOfPoints(); i++)
            {
                double[] p = polydata.GetPoint(i);
                // This is identical to:
                // double[] p = polydata.GetPoints().GetPoint(i);
                Console.WriteLine("Point " + i + " : (" + p[0] + " " + p[1] + " " + p[2] + ")");
            }
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestExtractVOI(String [] argv)
    {
        //Prefix Content is: ""

        // to mark the origin[]
        sphere = new vtkSphereSource();
        sphere.SetRadius((double)2.0);
        sphereMapper = vtkPolyDataMapper.New();
        sphereMapper.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
        sphereMapper.ImmediateModeRenderingOn();
        sphereActor = new vtkActor();
        sphereActor.SetMapper((vtkMapper)sphereMapper);
        rt = new vtkRTAnalyticSource();
        rt.SetWholeExtent((int)-50, (int)50, (int)-50, (int)50, (int)0, (int)0);
        voi = new vtkExtractVOI();
        voi.SetInputConnection((vtkAlgorithmOutput)rt.GetOutputPort());
        voi.SetVOI((int)-11, (int)39, (int)5, (int)45, (int)0, (int)0);
        voi.SetSampleRate((int)5, (int)5, (int)1);
        // Get rid ambiguous triagulation issues.[]
        surf = new vtkDataSetSurfaceFilter();
        surf.SetInputConnection((vtkAlgorithmOutput)voi.GetOutputPort());
        tris = new vtkTriangleFilter();
        tris.SetInputConnection((vtkAlgorithmOutput)surf.GetOutputPort());
        mapper = vtkPolyDataMapper.New();
        mapper.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort());
        mapper.ImmediateModeRenderingOn();
        mapper.SetScalarRange((double)130, (double)280);
        actor = new vtkActor();
        actor.SetMapper((vtkMapper)mapper);
        ren = vtkRenderer.New();
        ren.AddActor((vtkProp)actor);
        ren.AddActor((vtkProp)sphereActor);
        ren.ResetCamera();
        camera = ren.GetActiveCamera();
        //$camera SetPosition 68.1939 -23.4323 12.6465[]
        //$camera SetViewUp 0.46563 0.882375 0.0678508  []
        //$camera SetFocalPoint 3.65707 11.4552 1.83509 []
        //$camera SetClippingRange 59.2626 101.825 []
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        iren.Initialize();

//deleteAllVTKObjects();
    }
Example #13
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();
        }
        private void DijkstraGraphGeodesicPath()
        {
            // Create a sphere
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            vtkDijkstraGraphGeodesicPath dijkstra = vtkDijkstraGraphGeodesicPath.New();

            dijkstra.SetInputConnection(sphereSource.GetOutputPort());
            dijkstra.SetStartVertex(0);
            dijkstra.SetEndVertex(10);
            dijkstra.Update();

            // Create a mapper and actor
            vtkPolyDataMapper pathMapper = vtkPolyDataMapper.New();

            pathMapper.SetInputConnection(dijkstra.GetOutputPort());

            vtkActor pathActor = vtkActor.New();

            pathActor.SetMapper(pathMapper);
            pathActor.GetProperty().SetColor(1, 0, 0); // Red
            pathActor.GetProperty().SetLineWidth(4);

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

            mapper.SetInputConnection(sphereSource.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);
            renderer.AddActor(pathActor);
        }
Example #15
0
        void GenerateData(ref vtkPolyData input)
        {
            // Create a sphere
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            // Remove some cells
            vtkIdTypeArray ids = vtkIdTypeArray.New();

            ids.SetNumberOfComponents(1);

            // Set values
            ids.InsertNextValue(2);
            ids.InsertNextValue(10);

            vtkSelectionNode selectionNode = vtkSelectionNode.New();

            selectionNode.SetFieldType((int)vtkSelectionNode.SelectionField.CELL);
            selectionNode.SetContentType((int)vtkSelectionNode.SelectionContent.INDICES);
            selectionNode.SetSelectionList(ids);
            selectionNode.GetProperties().Set(vtkSelectionNode.INVERSE(), 1); //invert the selection

            vtkSelection selection = vtkSelection.New();

            selection.AddNode(selectionNode);

            vtkExtractSelection extractSelection = vtkExtractSelection.New();

            extractSelection.SetInputConnection(0, sphereSource.GetOutputPort());
#if VTK_MAJOR_VERSION_5
            extractSelection.SetInput(1, selection);
#else
            extractSelection.SetInputData(1, selection);
#endif
            extractSelection.Update();

            // In selection
            vtkDataSetSurfaceFilter surfaceFilter = vtkDataSetSurfaceFilter.New();
            surfaceFilter.SetInputConnection(extractSelection.GetOutputPort());
            surfaceFilter.Update();

            input.ShallowCopy(surfaceFilter.GetOutput());
        }
Example #16
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();
        }
Example #17
0
        private void Planes()
        {
            // in this example we need the renderer first to retrieve the active camera
            // in order to get camera's frustum planes and renderer's aspectratio
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = vtkRenderer.New();

            renderer = renderWindow.GetRenderers().GetFirstRenderer();
            vtkCamera camera = renderer.GetActiveCamera();

            double[] aspect      = renderer.GetAspect();
            double   aspectRatio = aspect[0] / aspect[1];

            vtkPlanes planes = vtkPlanes.New();
            // one way
            {
                // allocate memory for 24 unmanaged doubles
                int    size = Marshal.SizeOf(typeof(double)) * 24;
                IntPtr ptr  = Marshal.AllocHGlobal(size);
                camera.GetFrustumPlanes(aspectRatio, ptr);
                // in case we would need this values diectly we could copy
                // the unmanaged double array to a managed array like so:

                // double[] planesArray = new double[24];
                // Marshal.Copy(ptr, planesArray, 0, 24);

                // but fortunately we can forward the IntPtr directly to the function
                // SetFrustumPlanes()
                planes.SetFrustumPlanes(ptr);
                // free unmanaged memory
                Marshal.FreeHGlobal(ptr);
            }
            // another way
            {
                vtkSphereSource sphereSource = vtkSphereSource.New();
                sphereSource.Update();
                double[] bounds = new double[6];
                bounds = sphereSource.GetOutput().GetBounds();
                planes.SetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
            }
            // nothing to visualize
        }
Example #18
0
        private vtkActor CreateSphereActor(double radius)
        {
            Kitware.VTK.vtkActor a = new Kitware.VTK.vtkActor();

            vtkSphereSource sphereSource3D = new vtkSphereSource();

            sphereSource3D.SetCenter(0.0, 0.0, 0.0);
            sphereSource3D.SetRadius(radius);
            sphereSource3D.SetThetaResolution(10);
            sphereSource3D.SetPhiResolution(10);

            vtkPolyDataMapper sphereMapper3D = vtkPolyDataMapper.New();

            sphereMapper3D.SetInputConnection(sphereSource3D.GetOutputPort());
            a.SetMapper(sphereMapper3D);
            a.GetProperty().SetColor(0.95, 0.5, 0.3);
            a.GetProperty().SetOpacity(0.5);

            return(a);
        }
        public SpherePackage(vtkRenderer aRender)
        {
            _aRender = aRender;

            _sphereSource = vtkSphereSource.New();
            _sphereSource.SetRadius(3);
            _sphereSource.SetRadius(0.5);
            _sphereSource.SetThetaResolution(26);
            _sphereSource.SetPhiResolution(26);
            _sphereSource.ModifiedEvt += _sphereSource_ModifiedEvt;

            SphereMapper = vtkPolyDataMapper.New();
            SphereMapper.SetInputConnection(_sphereSource.GetOutputPort());

            _sphereActor = vtkActor.New();
            _sphereActor.SetMapper(SphereMapper);
            aRender.AddActor(_sphereActor);

            _aText = vtkVectorText.New();
            _aText.SetText("");

            vtkPolyDataMapper textMapper = vtkPolyDataMapper.New();

            textMapper.SetInputConnection(_aText.GetOutputPort());
            _textActor = vtkFollower.New();
            //textActor.GetProperty().SetColor(point.Color.X, point.Color.Y, point.Color.Z);
            _textActor.SetMapper(textMapper);
            //textActor.SetScale(0.2, 0.2, 0.2);
            //textActor.SetScale(4);
            _textActor.SetCamera(aRender.GetActiveCamera());
            aRender.AddActor(_textActor);

            //SetOpacity(0.5f);

            //VisOff();

            RandColor();
        }
Example #20
0
        private static void FindAllArrayNames(string filePath)
        {
            vtkPolyData polydata = vtkPolyData.New();

            if (filePath == null)
            {
                vtkSphereSource sphereSource = vtkSphereSource.New();
                sphereSource.Update();
                vtkXMLPolyDataWriter writer = vtkXMLPolyDataWriter.New();
                writer.SetFileName(@"c:\vtk\vtkdata-5.8.0\Data\testFindAllArrayNames.vtp");
                writer.SetInputConnection(sphereSource.GetOutputPort());
                writer.Write();
                polydata = sphereSource.GetOutput();
            }
            else
            {
                vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New();
                reader.SetFileName(filePath);
                reader.Update();
                polydata = reader.GetOutput();
            }
            FindAllData(ref polydata);
        }
Example #21
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;
        }
Example #22
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);
        }
        private void PlanesIntersection()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            double[] bounds = new double[6];
            bounds = sphereSource.GetOutput().GetBounds();

            vtkPoints box = vtkPoints.New();

            box.SetNumberOfPoints(8);

            double xMin, xMax, yMin, yMax, zMin, zMax;

            xMin = bounds[0]; xMax = bounds[1];
            yMin = bounds[2]; yMax = bounds[3];
            zMin = bounds[4]; zMax = bounds[5];

            box.SetPoint(0, xMax, yMin, zMax);
            box.SetPoint(1, xMax, yMin, zMin);
            box.SetPoint(2, xMax, yMax, zMin);
            box.SetPoint(3, xMax, yMax, zMax);
            box.SetPoint(4, xMin, yMin, zMax);
            box.SetPoint(5, xMin, yMin, zMin);
            box.SetPoint(6, xMin, yMax, zMin);
            box.SetPoint(7, xMin, yMax, zMax);

            vtkPlanesIntersection planesIntersection = vtkPlanesIntersection.New();

            planesIntersection.SetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
            int intersects = planesIntersection.IntersectsRegion(box);

            Debug.WriteLine("Intersects? " + ((intersects == 1) ? true : false).ToString());
            // nothing to visualize
        }
        private static void MultiBlockMergeFilter()
        {
            vtkSphereSource sphereSource1 = vtkSphereSource.New();

            sphereSource1.Update();

            vtkSphereSource sphereSource2 = vtkSphereSource.New();

            sphereSource2.SetCenter(10, 10, 10);
            sphereSource2.Update();

            vtkMultiBlockDataSet multiBlockDataSet1 = vtkMultiBlockDataSet.New();

            multiBlockDataSet1.SetNumberOfBlocks(1);
            multiBlockDataSet1.SetBlock(0, sphereSource1.GetOutput());
#if VTK_MAJOR_VERSION_5
            multiBlockDataSet1.Update();
#endif

            vtkMultiBlockDataSet multiBlockDataSet2 = vtkMultiBlockDataSet.New();
            multiBlockDataSet2.SetNumberOfBlocks(1);
            multiBlockDataSet2.SetBlock(0, sphereSource2.GetOutput());
#if VTK_MAJOR_VERSION_5
            multiBlockDataSet2.Update();
#endif

            vtkMultiBlockMergeFilter multiBlockMergeFilter = vtkMultiBlockMergeFilter.New();
#if VTK_MAJOR_VERSION_5
            multiBlockMergeFilter.AddInput(multiBlockDataSet1);
            multiBlockMergeFilter.AddInput(multiBlockDataSet2);
#else
            multiBlockMergeFilter.AddInputData(multiBlockDataSet1);
            multiBlockMergeFilter.AddInputData(multiBlockDataSet2);
#endif
            multiBlockMergeFilter.Update();
        }
Example #25
0
        private void ReadPDB()
        {
            // 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\caffeine.pdb");

            vtkPDBReader pdb = vtkPDBReader.New();

            pdb.SetFileName(filePath);
            pdb.SetHBScale(1.0);
            pdb.SetBScale(1.0);
            pdb.Update();
            Debug.WriteLine("# of atoms is: " + pdb.GetNumberOfAtoms());
            // if molecule contains a lot of atoms, reduce the resolution of the sphere (represents an atom) for faster rendering
            int resolution = (int)Math.Floor(Math.Sqrt(300000.0 / pdb.GetNumberOfAtoms())); // 300000.0 is an empriric value

            if (resolution > 20)
            {
                resolution = 20;
            }
            else if (resolution < 4)
            {
                resolution = 4;
            }

            Debug.WriteLine("Resolution is: " + resolution);
            vtkSphereSource sphere = vtkSphereSource.New();

            sphere.SetCenter(0, 0, 0);
            sphere.SetRadius(1);
            sphere.SetThetaResolution(resolution);
            sphere.SetPhiResolution(resolution);

            vtkGlyph3D glyph = vtkGlyph3D.New();

            glyph.SetInputConnection(pdb.GetOutputPort());
            glyph.SetOrient(1);
            glyph.SetColorMode(1);
            // glyph.ScalingOn();
            glyph.SetScaleMode(2);
            glyph.SetScaleFactor(.25);
            glyph.SetSourceConnection(sphere.GetOutputPort());

            vtkPolyDataMapper atomMapper = vtkPolyDataMapper.New();

            atomMapper.SetInputConnection(glyph.GetOutputPort());
            atomMapper.UseLookupTableScalarRangeOff();
            atomMapper.ScalarVisibilityOn();
            atomMapper.SetScalarModeToDefault();

            vtkLODActor atom = vtkLODActor.New();

            atom.SetMapper(atomMapper);
            atom.GetProperty().SetRepresentationToSurface();
            atom.GetProperty().SetInterpolationToGouraud();
            atom.GetProperty().SetAmbient(0.15);
            atom.GetProperty().SetDiffuse(0.85);
            atom.GetProperty().SetSpecular(0.1);
            atom.GetProperty().SetSpecularPower(30);
            atom.GetProperty().SetSpecularColor(1, 1, 1);
            atom.SetNumberOfCloudPoints(30000);


            vtkTubeFilter tube = vtkTubeFilter.New();

            tube.SetInputConnection(pdb.GetOutputPort());
            tube.SetNumberOfSides(resolution);
            tube.CappingOff();
            tube.SetRadius(0.2);
            // turn off variation of tube radius with scalar values
            tube.SetVaryRadius(0);
            tube.SetRadiusFactor(10);

            vtkPolyDataMapper bondMapper = vtkPolyDataMapper.New();

            bondMapper.SetInputConnection(tube.GetOutputPort());
            bondMapper.UseLookupTableScalarRangeOff();
            bondMapper.ScalarVisibilityOff();
            bondMapper.SetScalarModeToDefault();

            vtkLODActor bond = vtkLODActor.New();

            bond.SetMapper(bondMapper);
            bond.GetProperty().SetRepresentationToSurface();
            bond.GetProperty().SetInterpolationToGouraud();
            bond.GetProperty().SetAmbient(0.15);
            bond.GetProperty().SetDiffuse(0.85);
            bond.GetProperty().SetSpecular(0.1);
            bond.GetProperty().SetSpecularPower(30);
            bond.GetProperty().SetSpecularColor(1, 1, 1);
            bond.GetProperty().SetDiffuseColor(1.0000, 0.8941, 0.70981);


            // 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.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(atom);
            renderer.AddActor(bond);
        }
Example #26
0
        /// <summary>
        /// Generate a 3D mesh using marching-cubes algorithm. If voxel value is lower than 1 it is consider as background, else as object
        /// </summary>
        /// <param name="BinarySubImageSeq">The binary image</param>
        /// <param name="Colour">Mesh color</param>
        /// <param name="Pos">Postion of the object in the world</param>
        public cBiologicalSpot(Color Colour, cPoint3D Pos, double Intensity, double Radius)
        {
            this.Intensity = Intensity;
            VTK_Sphere = vtkSphereSource.New();
            VTK_Sphere.SetThetaResolution(6);
            VTK_Sphere.SetPhiResolution(6);
            VTK_Sphere.SetRadius(Radius);
            vtk_PolyDataMapper = vtkPolyDataMapper.New();
            vtk_PolyDataMapper.SetInputConnection(VTK_Sphere.GetOutputPort());

            this.SetPosition(new cPoint3D(Pos.X, Pos.Y, Pos.Z));
            this.Colour = Colour;

            CreateVTK3DObject(1);
            Information = new cInformation(this);
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVStreamPolyData(String [] argv)
    {
        //Prefix Content is: ""

          NUMBER_OF_PIECES = 5;
          // Generate implicit model of a sphere[]
          //[]
          // Create renderer stuff[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // create pipeline that handles ghost cells[]
          sphere = new vtkSphereSource();
          sphere.SetRadius((double)3);
          sphere.SetPhiResolution((int)100);
          sphere.SetThetaResolution((int)150);
          // sphere AddObserver StartEvent {tk_messageBox -message "Executing with piece [[sphere GetOutput] GetUpdatePiece]"}[]
          // Just playing with an alternative that is not currently used.[]
          //method moved
          // Just playing with an alternative that is not currently used.[]
          deci = new vtkDecimatePro();
          deci.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          // this did not remove seams as I thought it would[]
          deci.BoundaryVertexDeletionOff();
          //deci PreserveTopologyOn[]
          // Since quadric Clustering does not handle borders properly yet,[]
          // the pieces will have dramatic "eams"[]
          q = new vtkQuadricClustering();
          q.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          q.SetNumberOfXDivisions((int)5);
          q.SetNumberOfYDivisions((int)5);
          q.SetNumberOfZDivisions((int)10);
          q.UseInputPointsOn();
          streamer = new vtkPolyDataStreamer();
          //streamer SetInputConnection [deci GetOutputPort][]
          streamer.SetInputConnection((vtkAlgorithmOutput)q.GetOutputPort());
          //streamer SetInputConnection [pdn GetOutputPort][]
          streamer.SetNumberOfStreamDivisions((int)NUMBER_OF_PIECES);
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          mapper.ScalarVisibilityOff();
          mapper.SetPiece((int)0);
          mapper.SetNumberOfPieces((int)2);
          mapper.ImmediateModeRenderingOn();
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          actor.GetProperty().SetColor((double) 0.8300, 0.2400, 0.1000 );
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.GetActiveCamera().SetPosition((double)5,(double)5,(double)10);
          ren1.GetActiveCamera().SetFocalPoint((double)0,(double)0,(double)0);
          ren1.AddActor((vtkProp)actor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)300,(int)300);
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Example #28
0
        private void CreateSphere(cPoint3D Center, double Radius, Color Colour, int Precision)
        {
            Position = new cPoint3D(Center.X, Center.Y, Center.Z);

            this.Radius = Radius;
            this.Colour = Colour;

            sphere = vtkSphereSource.New();
            sphere.SetThetaResolution(Precision);
            sphere.SetPhiResolution(Precision);
            sphere.SetRadius(Radius);
            vtk_PolyDataMapper = vtkPolyDataMapper.New();
            vtk_PolyDataMapper.SetInputConnection(sphere.GetOutputPort());

            CreateVTK3DObject(2);
        }
Example #29
0
    /// <summary>
    /// A console application that creates a 
    /// vtkRenderWindow without a Windows Form
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        // Demonstrate how to use the vtkBoxWidget 3D widget,
        // This script uses a 3D box widget to define a "clipping box" to clip some
        // simple geometry (a mace). Make sure that you hit the "W" key to activate the widget.
        // Create a mace out of filters.
        sphere = vtkSphereSource.New();
        cone = vtkConeSource.New();
        glyph = vtkGlyph3D.New();

        glyph.SetInputConnection(sphere.GetOutputPort());
        glyph.SetSource(cone.GetOutput());
        glyph.SetVectorModeToUseNormal();
        glyph.SetScaleModeToScaleByVector();
        glyph.SetScaleFactor(0.25);

        // The sphere and spikes are appended into a single polydata. This just makes things
        // simpler to manage.
        apd = vtkAppendPolyData.New();
        apd.AddInput(glyph.GetOutput());
        apd.AddInput(sphere.GetOutput());

        maceMapper = vtkPolyDataMapper.New();
        maceMapper.SetInputConnection(apd.GetOutputPort());

        maceActor = vtkLODActor.New();
        maceActor.SetMapper(maceMapper);
        maceActor.VisibilityOn();

        // This portion of the code clips the mace with the vtkPlanes implicit function.
        // The clipped region is colored green.
        planes = vtkPlanes.New();
        clipper = vtkClipPolyData.New();

        clipper.SetInputConnection(apd.GetOutputPort());
        clipper.SetClipFunction(planes);
        clipper.InsideOutOn();

        selectMapper = vtkPolyDataMapper.New();
        selectMapper.SetInputConnection(clipper.GetOutputPort());

        selectActor = vtkLODActor.New();
        selectActor.SetMapper(selectMapper);
        selectActor.GetProperty().SetColor(0, 1, 0);
        selectActor.VisibilityOff();
        selectActor.SetScale(1.01, 1.01, 1.01);

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

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

        // Add the actors to the renderer, set the background and size
        ren1.SetBackground(0.1, 0.2, 0.4);
        renWin.SetSize(300, 300);

        // Place the interactor initially. The input to a 3D widget is used to
        // initially position and scale the widget. The EndInteractionEvent is
        // observed which invokes the SelectPolygons callback.
        boxWidget.SetInput(glyph.GetOutput());
        boxWidget.PlaceWidget();
        boxWidget.EndInteractionEvt += new vtkObject.vtkObjectEventHandler(SelectPolygons);

        // render the image
        iren.Initialize();
        iren.Start();
        //Clean up
        deleteAllVTKObjects();
    }
Example #30
0
    /// <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 AVTestPolyDataPieces(String [] argv)
    {
        //Prefix Content is: ""

          math = new vtkMath();
          vtkMath.RandomSeed((int)22);
          pf = new vtkParallelFactory();
          vtkParallelFactory.RegisterFactory((vtkObjectFactory)pf);
          sphere = new vtkSphereSource();
          sphere.SetPhiResolution((int)32);
          sphere.SetThetaResolution((int)32);
          extract = new vtkExtractPolyDataPiece();
          extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          normals = new vtkPolyDataNormals();
          normals.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort());
          ps = new vtkPieceScalars();
          ps.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort());
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort());
          mapper.SetNumberOfPieces((int)2);
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          sphere2 = new vtkSphereSource();
          sphere2.SetPhiResolution((int)32);
          sphere2.SetThetaResolution((int)32);
          extract2 = new vtkExtractPolyDataPiece();
          extract2.SetInputConnection((vtkAlgorithmOutput)sphere2.GetOutputPort());
          mapper2 = vtkPolyDataMapper.New();
          mapper2.SetInputConnection((vtkAlgorithmOutput)extract2.GetOutputPort());
          mapper2.SetNumberOfPieces((int)2);
          mapper2.SetPiece((int)1);
          mapper2.SetScalarRange((double)0,(double)4);
          mapper2.SetScalarModeToUseCellFieldData();
          mapper2.SetColorModeToMapScalars();
          mapper2.ColorByArrayComponent((string)"vtkGhostLevels",(int)0);
          mapper2.SetGhostLevel((int)4);
          // check the pipeline size[]
          extract2.UpdateInformation();
          psize = new vtkPipelineSize();
          if ((psize.GetEstimatedSize((vtkAlgorithm)extract2,(int)0,(int)0)) > 100)
        {
          //puts skipedputs ['stderr', '"ERROR: Pipeline Size increased"']
        }

          if ((psize.GetNumberOfSubPieces((uint)10,(vtkPolyDataMapper)mapper2)) != 2)
        {
          //puts skipedputs ['stderr', '"ERROR: Number of sub pieces changed"']
        }

          actor2 = new vtkActor();
          actor2.SetMapper((vtkMapper)mapper2);
          actor2.SetPosition((double)1.5,(double)0,(double)0);
          sphere3 = new vtkSphereSource();
          sphere3.SetPhiResolution((int)32);
          sphere3.SetThetaResolution((int)32);
          extract3 = new vtkExtractPolyDataPiece();
          extract3.SetInputConnection((vtkAlgorithmOutput)sphere3.GetOutputPort());
          ps3 = new vtkPieceScalars();
          ps3.SetInputConnection((vtkAlgorithmOutput)extract3.GetOutputPort());
          mapper3 = vtkPolyDataMapper.New();
          mapper3.SetInputConnection((vtkAlgorithmOutput)ps3.GetOutputPort());
          mapper3.SetNumberOfSubPieces((int)8);
          mapper3.SetScalarRange((double)0,(double)8);
          actor3 = new vtkActor();
          actor3.SetMapper((vtkMapper)mapper3);
          actor3.SetPosition((double)0,(double)-1.5,(double)0);
          sphere4 = new vtkSphereSource();
          sphere4.SetPhiResolution((int)32);
          sphere4.SetThetaResolution((int)32);
          extract4 = new vtkExtractPolyDataPiece();
          extract4.SetInputConnection((vtkAlgorithmOutput)sphere4.GetOutputPort());
          ps4 = new vtkPieceScalars();
          ps4.RandomModeOn();
          ps4.SetScalarModeToCellData();
          ps4.SetInputConnection((vtkAlgorithmOutput)extract4.GetOutputPort());
          mapper4 = vtkPolyDataMapper.New();
          mapper4.SetInputConnection((vtkAlgorithmOutput)ps4.GetOutputPort());
          mapper4.SetNumberOfSubPieces((int)8);
          mapper4.SetScalarRange((double)0,(double)8);
          actor4 = new vtkActor();
          actor4.SetMapper((vtkMapper)mapper4);
          actor4.SetPosition((double)1.5,(double)-1.5,(double)0);
          ren = vtkRenderer.New();
          ren.AddActor((vtkProp)actor);
          ren.AddActor((vtkProp)actor2);
          ren.AddActor((vtkProp)actor3);
          ren.AddActor((vtkProp)actor4);
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          iren.Initialize();

        //deleteAllVTKObjects();
    }
Example #32
0
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            if (pick_trigger == false)
            {
                MessageBox.Show("请先选择靶点或穿刺点!");
                return;
            }
            if (pick_tag == true)
            {
                control_renderer.RemoveActor(this.spheres[this.sphere_num - 1]);
                this.point_num  -= 1;
                this.sphere_num -= 1;
            }
            if (this.sphere_num >= 6)
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult      dr         = MessageBox.Show("点数已满,是否清空?", "系统提示", messButton);
                if (dr == DialogResult.OK)
                {
                    for (int i = 0; i < this.sphere_num; i++)
                    {
                        control_renderer.RemoveActor(this.spheres[i]);
                        this.points = new double[20, 3];
                    }
                    this.point_num  = 0;
                    this.sphere_num = 0;
                }
                return;
            }
            //vtkRenderWindowInteractor inter_ren = this.GetInteractor();
            Console.WriteLine(this.point_num.ToString());
            double[] temp   = new double[2];
            double[] picked = new double[3];
            temp[0] = this.GetInteractor().GetEventPosition()[0];
            temp[1] = this.GetInteractor().GetEventPosition()[1];
            Console.WriteLine("picked position" + temp[0].ToString() + " , " + temp[1].ToString());
            this.GetInteractor().GetPicker().Pick(temp[0], temp[1], 0, this.GetInteractor().GetRenderWindow().GetRenderers().GetFirstRenderer());
            picked = this.GetInteractor().GetPicker().GetPickPosition();
            Console.WriteLine("picked point:" + picked[0].ToString() + " , " + picked[1].ToString() + " , " + picked[2].ToString());
            for (int i = 0; i < 3; i++)
            {
                this.points[point_num, i] = picked[i];
            }
            this.point_num++;
            base.OnMouseDoubleClick(e);

            //import a sphere object into scence
            vtkSphereSource sphere = new vtkSphereSource();

            sphere.SetCenter(picked[0], picked[1], picked[2]);
            sphere.SetRadius(3.0);

            vtkPolyDataMapper mapper = new vtkPolyDataMapper();

            mapper.SetInputConnection(sphere.GetOutputPort());

            vtkProperty property = new vtkProperty();

            property.SetColor(color[0], color[1], color[2]);
            property.SetOpacity(1);

            this.spheres[this.sphere_num] = new vtkActor();
            this.spheres[this.sphere_num].SetMapper(mapper);
            this.spheres[this.sphere_num].SetProperty(property);

            this.control_renderer.AddActor(this.spheres[this.sphere_num]);

            this.sphere_num++;
            this.pick_tag = true;
            //点数越界后弹窗确定是否清空
        }
Example #33
0
        public cBiologicalSpot(Color Colour, cPoint3D Pos, double Intensity, double Radius, List<cInteractive3DObject> Containers, int ContainerMode)
        {
            this.Intensity = Intensity;

            this.Detected = true;

            this.Intensity = Intensity;
            VTK_Sphere = vtkSphereSource.New();
            VTK_Sphere.SetThetaResolution(10);
            VTK_Sphere.SetPhiResolution(10);
            VTK_Sphere.SetRadius(Radius);
            vtk_PolyDataMapper = vtkPolyDataMapper.New();
            vtk_PolyDataMapper.SetInputConnection(VTK_Sphere.GetOutputPort());

            this.SetPosition(new cPoint3D(Pos.X, Pos.Y, Pos.Z));
            this.Colour = Colour;

            CreateVTK3DObject(1);
            Information = new cInformation(this);

            this.Detected = true;

            /*
            vtkActor TmpActor = vtkActor.New();
            TmpActor.SetMapper(vtk_PolyDataMapper);
            TmpActor.SetPosition(Pos.X, Pos.Y, Pos.Z);

            //Console.WriteLine("PosX"+Pos.X+" PosY"+Pos.Y+" PosZ"+Pos.Z);
            cPoint3D Centroid = new cPoint3D((float)TmpActor.GetCenter()[0], (float)TmpActor.GetCenter()[1], (float)TmpActor.GetCenter()[2]);

            bool IsInside = false;
            for (int Idx = 0; Idx < Containers.Count; Idx++)
            {
                cBiological3DVolume CurrentContainer = (cBiological3DVolume)(Containers[Idx]);

                if (CurrentContainer.IsPointInside(Centroid))
                {
                    IsInside = true;
                    ContainerIdx = Idx;
                    break;
                }
            }
            if (IsInside)
            {
                this.Position = new cPoint3D(Pos.X, Pos.Y, Pos.Z);
                this.Colour = Colour;

                CreateVTK3DObject(1);

                vtk_PolyData = ContourObject.GetOutput();
                //  this.BackfaceCulling(false);

                Information = new cInformation(ContourObject, this);
                this.Detected = true;
            }
            else
            {
                this.Detected = false;
            }*/
        }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setball(vtkSphereSource toSet)
 {
     ball = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setsphere(vtkSphereSource toSet)
 {
     sphere = toSet;
 }
Example #36
0
    /// <summary>
    /// Entry Point
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        // This example demonstrates how to use 2D Delaunay triangulation.
        // We create a fancy image of a 2D Delaunay triangulation. Points are
        // randomly generated.
        // first we load in the standard vtk packages into tcl
        // Generate some random points
        math = vtkMath.New();
        points = vtkPoints.New();
        for(int i = 0; i < 50; i++)
        {
            points.InsertPoint(i, vtkMath.Random(0, 1), vtkMath.Random(0, 1), 0.0);
        }

        // Create a polydata with the points we just created.
        profile = vtkPolyData.New();
        profile.SetPoints(points);

        // Perform a 2D Delaunay triangulation on them.
        del = vtkDelaunay2D.New();
        del.SetInput(profile);
        del.SetTolerance(0.001);

        mapMesh = vtkPolyDataMapper.New();
        mapMesh.SetInputConnection(del.GetOutputPort());

        meshActor = vtkActor.New();
        meshActor.SetMapper(mapMesh);
        meshActor.GetProperty().SetColor(.1, .2, .4);

        // We will now create a nice looking mesh by wrapping the edges in tubes,
        // and putting fat spheres at the points.
        extract = vtkExtractEdges.New();
        extract.SetInputConnection(del.GetOutputPort());

        tubes = vtkTubeFilter.New();
        tubes.SetInputConnection(extract.GetOutputPort());
        tubes.SetRadius(0.01);
        tubes.SetNumberOfSides(6);

        mapEdges = vtkPolyDataMapper.New();
        mapEdges.SetInputConnection(tubes.GetOutputPort());

        edgeActor = vtkActor.New();
        edgeActor.SetMapper(mapEdges);
        edgeActor.GetProperty().SetColor(0.2000, 0.6300, 0.7900);
        edgeActor.GetProperty().SetSpecularColor(1, 1, 1);
        edgeActor.GetProperty().SetSpecular(0.3);
        edgeActor.GetProperty().SetSpecularPower(20);
        edgeActor.GetProperty().SetAmbient(0.2);
        edgeActor.GetProperty().SetDiffuse(0.8);

        ball = vtkSphereSource.New();
        ball.SetRadius(0.025);
        ball.SetThetaResolution(12);
        ball.SetPhiResolution(12);

        balls = vtkGlyph3D.New();
        balls.SetInputConnection(del.GetOutputPort());
        balls.SetSourceConnection(ball.GetOutputPort());

        mapBalls = vtkPolyDataMapper.New();
        mapBalls.SetInputConnection(balls.GetOutputPort());

        ballActor = vtkActor.New();
        ballActor.SetMapper(mapBalls);
        ballActor.GetProperty().SetColor(1.0000, 0.4118, 0.7059);
        ballActor.GetProperty().SetSpecularColor(1, 1, 1);
        ballActor.GetProperty().SetSpecular(0.3);
        ballActor.GetProperty().SetSpecularPower(20);
        ballActor.GetProperty().SetAmbient(0.2);
        ballActor.GetProperty().SetDiffuse(0.8);

        // Create graphics objects
        // Create the rendering window, renderer, and interactive renderer
        ren1 = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer(ren1);
        iren = vtkRenderWindowInteractor.New();
        iren.SetRenderWindow(renWin);

        // Add the actors to the renderer, set the background and size
        ren1.AddActor(ballActor);
        ren1.AddActor(edgeActor);
        ren1.SetBackground(1, 1, 1);
        renWin.SetSize(150, 150);

        // render the image
        ren1.ResetCamera();
        ren1.GetActiveCamera().Zoom(1.5);
        iren.Initialize();
        iren.Start();

        // Clean Up
        deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestPDataSetReaderGrid(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);
        //[]
        // 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");
          // ====== Structured Grid ======[]
          // First save out a grid in parallel form.[]
          reader = new vtkMultiBlockPLOT3DReader();
          reader.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin");
          reader.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin");
          writer = new vtkPDataSetWriter();
          writer.SetFileName((string)"comb.pvtk");
          writer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          writer.SetNumberOfPieces((int)4);
          writer.Write();
          pReader = new vtkPDataSetReader();
          pReader.SetFileName((string)"comb.pvtk");
          surface = new vtkDataSetSurfaceFilter();
          surface.SetInputConnection((vtkAlgorithmOutput)pReader.GetOutputPort());
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)surface.GetOutputPort());
          mapper.SetNumberOfPieces((int)2);
          mapper.SetPiece((int)0);
          mapper.SetGhostLevel((int)1);
          mapper.Update();
          File.Delete("comb.pvtk");
          File.Delete("comb.0.vtk");
          File.Delete("comb.1.vtk");
          File.Delete("comb.2.vtk");
          File.Delete("comb.3.vtk");
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          actor.SetPosition((double)-5,(double)0,(double)-29);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)actor);
          // ====== ImageData ======[]
          // First save out a grid in parallel form.[]
          fractal = new vtkImageMandelbrotSource();
          fractal.SetWholeExtent((int)0,(int)9,(int)0,(int)9,(int)0,(int)9);
          fractal.SetSampleCX((double)0.1,(double)0.1,(double)0.1,(double)0.1);
          fractal.SetMaximumNumberOfIterations((ushort)10);
          writer2 = new vtkPDataSetWriter();
          writer.SetFileName((string)"fractal.pvtk");
          writer.SetInputConnection((vtkAlgorithmOutput)fractal.GetOutputPort());
          writer.SetNumberOfPieces((int)4);
          writer.Write();
          pReader2 = new vtkPDataSetReader();
          pReader2.SetFileName((string)"fractal.pvtk");
          iso = new vtkContourFilter();
          iso.SetInputConnection((vtkAlgorithmOutput)pReader2.GetOutputPort());
          iso.SetValue((int)0,(double)4);
          mapper2 = vtkPolyDataMapper.New();
          mapper2.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
          mapper2.SetNumberOfPieces((int)3);
          mapper2.SetPiece((int)0);
          mapper2.SetGhostLevel((int)0);
          mapper2.Update();
          File.Delete("fractal.pvtk");
          File.Delete("fractal.0.vtk");
          File.Delete("fractal.1.vtk");
          File.Delete("fractal.2.vtk");
          File.Delete("fractal.3.vtk");
          actor2 = new vtkActor();
          actor2.SetMapper((vtkMapper)mapper2);
          actor2.SetScale((double)5,(double)5,(double)5);
          actor2.SetPosition((double)6,(double)6,(double)6);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)actor2);
          // ====== PolyData ======[]
          // First save out a grid in parallel form.[]
          sphere = new vtkSphereSource();
          sphere.SetRadius((double)2);
          writer3 = new vtkPDataSetWriter();
          writer3.SetFileName((string)"sphere.pvtk");
          writer3.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          writer3.SetNumberOfPieces((int)4);
          writer3.Write();
          pReader3 = new vtkPDataSetReader();
          pReader3.SetFileName((string)"sphere.pvtk");
          mapper3 = vtkPolyDataMapper.New();
          mapper3.SetInputConnection((vtkAlgorithmOutput)pReader3.GetOutputPort());
          mapper3.SetNumberOfPieces((int)2);
          mapper3.SetPiece((int)0);
          mapper3.SetGhostLevel((int)1);
          mapper3.Update();
          File.Delete("sphere.pvtk");
          File.Delete("sphere.0.vtk");
          File.Delete("sphere.1.vtk");
          File.Delete("sphere.2.vtk");
          File.Delete("sphere.3.vtk");
          actor3 = new vtkActor();
          actor3.SetMapper((vtkMapper)mapper3);
          actor3.SetPosition((double)6,(double)6,(double)6);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)actor3);
          }

        ren1.SetBackground((double)0.1,(double)0.2,(double)0.4);
        renWin.SetSize((int)300,(int)300);
        // render the image[]
        //[]
        cam1 = ren1.GetActiveCamera();
        cam1.Azimuth((double)20);
        cam1.Elevation((double)40);
        ren1.ResetCamera();
        cam1.Zoom((double)1.2);
        iren.Initialize();
        // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Example #38
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();
    }
Example #39
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();
    }
        private void SetUpRenderWindow()
        {
            // create a VTK output control and make the forms host point to it
            rwc = new RenderWindowControl();
            rwc.CreateGraphics();
            windowsFormsHost.Child = rwc;

            // set up basic viewing
            vtkRenderer ren = rwc.RenderWindow.GetRenderers().GetFirstRenderer();

            // background color
            ren.SetBackground(0.0, 0.0, 0.0);

            // interactor style
            vtkInteractorStyleSwitch istyle = vtkInteractorStyleSwitch.New();

            rwc.RenderWindow.GetInteractor().SetInteractorStyle(istyle);
            rwc.RenderWindow.GetInteractor().SetPicker(vtkCellPicker.New());
            (istyle).SetCurrentStyleToTrackballCamera();

            // Demonstrate how to use the vtkBoxWidget 3D widget,
            vtkSphereSource sphere = vtkSphereSource.New();

            sphere.SetRadius(0.25);

            vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New();

            sphereMapper.SetInputConnection(sphere.GetOutputPort());

            vtkActor      sphereActor;
            vtkTransform  widgetTransform = vtkTransform.New();
            List <Region> region_list     = configurator.SimConfig.scenario.regions.ToList();

            for (int ii = 0; ii < region_list.Count; ++ii)
            {
                this.TransferMatrixToVTKTransform(region_list[ii].region_box_spec.transform_matrix, widgetTransform);
                sphereActor = vtkActor.New();
                sphereActor.SetMapper(sphereMapper);
                sphereActor.SetUserTransform(widgetTransform);
                sphereActor.GetProperty().SetOpacity(0.5);
                sphereActor.SetVisibility(region_list[ii].region_visibility ? 1 : 0);
                sphereActorList.Add(sphereActor);
                ren.AddActor(sphereActorList[ii]);
            }

            vtkCubeSource cube = vtkCubeSource.New();

            cube.SetXLength(5.0);
            cube.SetYLength(5.0);
            cube.SetZLength(5.0);

            vtkOutlineSource outline = vtkOutlineSource.New();

            outline.SetBounds(-2, 2, -2, 2, -2, 2);

            vtkPolyDataMapper cubeMapper = vtkPolyDataMapper.New();

            cubeMapper.SetInputConnection(outline.GetOutputPort());

            vtkLODActor cubeActor = vtkLODActor.New();

            cubeActor.SetMapper(cubeMapper);
            cubeActor.VisibilityOn();

            ren.AddActor(cubeActor);

            boxRep = vtkBoxRepresentation.New();
            boxRep.SetTransform(widgetTransform);

            boxWidget = vtkBoxWidget2.New();
            boxWidget.SetInteractor(rwc.RenderWindow.GetInteractor());
            boxWidget.SetRepresentation(boxRep);
            boxWidget.SetPriority(1);
            boxWidget.InteractionEvt += this.boxInteractionCallback;

            ren.ResetCamera();
        }
Example #41
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();
        }
Example #42
0
        public FormFor3DDataDisplay(bool IsFullScreen, cScreening CompleteScreening)
        {
            this.CompleteScreening = CompleteScreening;
            InitializeComponent();

            // toolTip1.SetToolTip(comboBoxDescriptorX,comboBoxDescriptorX.Text+"aaaaaa");
            //comboBoxDescriptorX.MouseHover += new System.EventHandler(this.comboBoxDescriptorX_MouseHover);

            //this.comboBoxDescriptorX.tool
            // Set up the ToolTip text for the Button and Checkbox.
            // toolTip1.SetToolTip(, "Unsupervised feature selection.\nThese approaches use all the active wells as data for the dimensionality reduction.");

            this.IsFullScreen = IsFullScreen;
            //  WindowFormFor3DVizuOptions.Parent = this;

            for (int i = 0; i < (int)CompleteScreening.ListDescriptors.Count; i++)
            {
                ListScales.Add(1);
            }

            ClassSelectionPanel = new PanelForClassSelection(true, Classes.Base_Classes.GUI.eClassType.WELL);
            ClassSelectionPanel.Height = panelForClasses.Height;
            ClassSelectionPanel.SelectAll();
            panelForClasses.Controls.Add(ClassSelectionPanel);

            foreach (var CurrentCheckBox in ClassSelectionPanel.ListCheckBoxes)
            {
                CurrentCheckBox.CheckedChanged += new EventHandler(CurrentCheckBox_CheckedChanged);
            }

            ToolTipForX.AutoPopDelay = ToolTipForY.AutoPopDelay = ToolTipForZ.AutoPopDelay = 5000;
            ToolTipForX.InitialDelay = ToolTipForY.InitialDelay = ToolTipForZ.InitialDelay = 500;
            ToolTipForX.ReshowDelay = ToolTipForY.ReshowDelay = ToolTipForZ.ReshowDelay = 500;
            ToolTipForX.ShowAlways = ToolTipForY.ShowAlways = ToolTipForZ.ShowAlways = true;
            ToolTipForX.SetToolTip(comboBoxDescriptorX, comboBoxDescriptorX.Text);

            this.WindowFormFor3DVizuOptions = new FormFor3DVizuOptions(this);

            this.LightIntensity = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightIntensity.Value;
            this.LightAmbient = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightAmbient.Value;
            this.LightDiffuse = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightIntensity.Value;
            this.LightSpecular = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightIntensity.Value;

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

        math = new vtkMath();
        vtkMath.RandomSeed((int)22);
        pf = new vtkParallelFactory();
        vtkParallelFactory.RegisterFactory((vtkObjectFactory)pf);
        sphere = new vtkSphereSource();
        sphere.SetPhiResolution((int)32);
        sphere.SetThetaResolution((int)32);
        extract = new vtkExtractPolyDataPiece();
        extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
        normals = new vtkPolyDataNormals();
        normals.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort());
        ps = new vtkPieceScalars();
        ps.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort());
        mapper = vtkPolyDataMapper.New();
        mapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort());
        mapper.SetNumberOfPieces((int)2);
        actor = new vtkActor();
        actor.SetMapper((vtkMapper)mapper);
        sphere2 = new vtkSphereSource();
        sphere2.SetPhiResolution((int)32);
        sphere2.SetThetaResolution((int)32);
        extract2 = new vtkExtractPolyDataPiece();
        extract2.SetInputConnection((vtkAlgorithmOutput)sphere2.GetOutputPort());
        mapper2 = vtkPolyDataMapper.New();
        mapper2.SetInputConnection((vtkAlgorithmOutput)extract2.GetOutputPort());
        mapper2.SetNumberOfPieces((int)2);
        mapper2.SetPiece((int)1);
        mapper2.SetScalarRange((double)0, (double)4);
        mapper2.SetScalarModeToUseCellFieldData();
        mapper2.SetColorModeToMapScalars();
        mapper2.ColorByArrayComponent((string)"vtkGhostLevels", (int)0);
        mapper2.SetGhostLevel((int)4);
        // check the pipeline size[]
        extract2.UpdateInformation();
        psize = new vtkPipelineSize();
        if ((psize.GetEstimatedSize((vtkAlgorithm)extract2, (int)0, (int)0)) > 100)
        {
            //puts skipedputs ['stderr', '"ERROR: Pipeline Size increased"']
        }


        if ((psize.GetNumberOfSubPieces((uint)10, (vtkPolyDataMapper)mapper2)) != 2)
        {
            //puts skipedputs ['stderr', '"ERROR: Number of sub pieces changed"']
        }


        actor2 = new vtkActor();
        actor2.SetMapper((vtkMapper)mapper2);
        actor2.SetPosition((double)1.5, (double)0, (double)0);
        sphere3 = new vtkSphereSource();
        sphere3.SetPhiResolution((int)32);
        sphere3.SetThetaResolution((int)32);
        extract3 = new vtkExtractPolyDataPiece();
        extract3.SetInputConnection((vtkAlgorithmOutput)sphere3.GetOutputPort());
        ps3 = new vtkPieceScalars();
        ps3.SetInputConnection((vtkAlgorithmOutput)extract3.GetOutputPort());
        mapper3 = vtkPolyDataMapper.New();
        mapper3.SetInputConnection((vtkAlgorithmOutput)ps3.GetOutputPort());
        mapper3.SetNumberOfSubPieces((int)8);
        mapper3.SetScalarRange((double)0, (double)8);
        actor3 = new vtkActor();
        actor3.SetMapper((vtkMapper)mapper3);
        actor3.SetPosition((double)0, (double)-1.5, (double)0);
        sphere4 = new vtkSphereSource();
        sphere4.SetPhiResolution((int)32);
        sphere4.SetThetaResolution((int)32);
        extract4 = new vtkExtractPolyDataPiece();
        extract4.SetInputConnection((vtkAlgorithmOutput)sphere4.GetOutputPort());
        ps4 = new vtkPieceScalars();
        ps4.RandomModeOn();
        ps4.SetScalarModeToCellData();
        ps4.SetInputConnection((vtkAlgorithmOutput)extract4.GetOutputPort());
        mapper4 = vtkPolyDataMapper.New();
        mapper4.SetInputConnection((vtkAlgorithmOutput)ps4.GetOutputPort());
        mapper4.SetNumberOfSubPieces((int)8);
        mapper4.SetScalarRange((double)0, (double)8);
        actor4 = new vtkActor();
        actor4.SetMapper((vtkMapper)mapper4);
        actor4.SetPosition((double)1.5, (double)-1.5, (double)0);
        ren = vtkRenderer.New();
        ren.AddActor((vtkProp)actor);
        ren.AddActor((vtkProp)actor2);
        ren.AddActor((vtkProp)actor3);
        ren.AddActor((vtkProp)actor4);
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        iren.Initialize();

//deleteAllVTKObjects();
    }
        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();
        }
Example #45
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVStreamPolyData(String [] argv)
    {
        //Prefix Content is: ""

        NUMBER_OF_PIECES = 5;
        // Generate implicit model of a sphere[]
        //[]
        // Create renderer stuff[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        // create pipeline that handles ghost cells[]
        sphere = new vtkSphereSource();
        sphere.SetRadius((double)3);
        sphere.SetPhiResolution((int)100);
        sphere.SetThetaResolution((int)150);
        // sphere AddObserver StartEvent {tk_messageBox -message "Executing with piece [[sphere GetOutput] GetUpdatePiece]"}[]
        // Just playing with an alternative that is not currently used.[]
        //method moved
        // Just playing with an alternative that is not currently used.[]
        deci = new vtkDecimatePro();
        deci.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
        // this did not remove seams as I thought it would[]
        deci.BoundaryVertexDeletionOff();
        //deci PreserveTopologyOn[]
        // Since quadric Clustering does not handle borders properly yet,[]
        // the pieces will have dramatic "eams"[]
        q = new vtkQuadricClustering();
        q.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
        q.SetNumberOfXDivisions((int)5);
        q.SetNumberOfYDivisions((int)5);
        q.SetNumberOfZDivisions((int)10);
        q.UseInputPointsOn();
        streamer = new vtkPolyDataStreamer();
        //streamer SetInputConnection [deci GetOutputPort][]
        streamer.SetInputConnection((vtkAlgorithmOutput)q.GetOutputPort());
        //streamer SetInputConnection [pdn GetOutputPort][]
        streamer.SetNumberOfStreamDivisions((int)NUMBER_OF_PIECES);
        mapper = vtkPolyDataMapper.New();
        mapper.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
        mapper.ScalarVisibilityOff();
        mapper.SetPiece((int)0);
        mapper.SetNumberOfPieces((int)2);
        mapper.ImmediateModeRenderingOn();
        actor = new vtkActor();
        actor.SetMapper((vtkMapper)mapper);
        actor.GetProperty().SetColor((double)0.8300, 0.2400, 0.1000);
        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.GetActiveCamera().SetPosition((double)5, (double)5, (double)10);
        ren1.GetActiveCamera().SetFocalPoint((double)0, (double)0, (double)0);
        ren1.AddActor((vtkProp)actor);
        ren1.SetBackground((double)1, (double)1, (double)1);
        renWin.SetSize((int)300, (int)300);
        iren.Initialize();
        // 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 AVclosedSplines(String [] argv)
    {
        //Prefix Content is: ""

          // get the interactor ui[]
          // Now create the RenderWindow, Renderer and Interactor[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          math = new vtkMath();
          numberOfInputPoints = 30;
          aKSplineX = new vtkKochanekSpline();
          aKSplineX.ClosedOn();
          aKSplineY = new vtkKochanekSpline();
          aKSplineY.ClosedOn();
          aKSplineZ = new vtkKochanekSpline();
          aKSplineZ.ClosedOn();
          aCSplineX = new vtkCardinalSpline();
          aCSplineX.ClosedOn();
          aCSplineY = new vtkCardinalSpline();
          aCSplineY.ClosedOn();
          aCSplineZ = new vtkCardinalSpline();
          aCSplineZ.ClosedOn();
          // add some points[]
          inputPoints = new vtkPoints();
          x = -1.0;
          y = -1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)0,(double)x);
          aKSplineY.AddPoint((double)0,(double)y);
          aKSplineZ.AddPoint((double)0,(double)z);
          aCSplineX.AddPoint((double)0,(double)x);
          aCSplineY.AddPoint((double)0,(double)y);
          aCSplineZ.AddPoint((double)0,(double)z);
          inputPoints.InsertPoint((int)0,(double)x,(double)y,(double)z);
          x = 1.0;
          y = -1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)1,(double)x);
          aKSplineY.AddPoint((double)1,(double)y);
          aKSplineZ.AddPoint((double)1,(double)z);
          aCSplineX.AddPoint((double)1,(double)x);
          aCSplineY.AddPoint((double)1,(double)y);
          aCSplineZ.AddPoint((double)1,(double)z);
          inputPoints.InsertPoint((int)1,(double)x,(double)y,(double)z);
          x = 1.0;
          y = 1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)2,(double)x);
          aKSplineY.AddPoint((double)2,(double)y);
          aKSplineZ.AddPoint((double)2,(double)z);
          aCSplineX.AddPoint((double)2,(double)x);
          aCSplineY.AddPoint((double)2,(double)y);
          aCSplineZ.AddPoint((double)2,(double)z);
          inputPoints.InsertPoint((int)2,(double)x,(double)y,(double)z);
          x = -1.0;
          y = 1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)3,(double)x);
          aKSplineY.AddPoint((double)3,(double)y);
          aKSplineZ.AddPoint((double)3,(double)z);
          aCSplineX.AddPoint((double)3,(double)x);
          aCSplineY.AddPoint((double)3,(double)y);
          aCSplineZ.AddPoint((double)3,(double)z);
          inputPoints.InsertPoint((int)3,(double)x,(double)y,(double)z);
          inputData = new vtkPolyData();
          inputData.SetPoints((vtkPoints)inputPoints);
          balls = new vtkSphereSource();
          balls.SetRadius((double).04);
          balls.SetPhiResolution((int)10);
          balls.SetThetaResolution((int)10);
          glyphPoints = new vtkGlyph3D();
          glyphPoints.SetInput((vtkDataObject)inputData);
          glyphPoints.SetSource((vtkPolyData)balls.GetOutput());
          glyphMapper = vtkPolyDataMapper.New();
          glyphMapper.SetInputConnection((vtkAlgorithmOutput)glyphPoints.GetOutputPort());
          glyph = new vtkActor();
          glyph.SetMapper((vtkMapper)glyphMapper);
          glyph.GetProperty().SetDiffuseColor((double) 1.0000, 0.3882, 0.2784 );
          glyph.GetProperty().SetSpecular((double).3);
          glyph.GetProperty().SetSpecularPower((double)30);
          ren1.AddActor((vtkProp)glyph);
          Kpoints = new vtkPoints();
          Cpoints = new vtkPoints();
          profileKData = new vtkPolyData();
          profileCData = new vtkPolyData();
          numberOfInputPoints = 5;
          numberOfOutputPoints = 100;
          offset = 1.0;
          //method moved
          fit();
          lines = new vtkCellArray();
          lines.InsertNextCell((int)numberOfOutputPoints);
          i = 0;
          while((i) < numberOfOutputPoints)
        {
          lines.InsertCellPoint((int)i);
          i = i + 1;
        }

          profileKData.SetPoints((vtkPoints)Kpoints);
          profileKData.SetLines((vtkCellArray)lines);
          profileCData.SetPoints((vtkPoints)Cpoints);
          profileCData.SetLines((vtkCellArray)lines);
          profileKTubes = new vtkTubeFilter();
          profileKTubes.SetNumberOfSides((int)8);
          profileKTubes.SetInput((vtkDataObject)profileKData);
          profileKTubes.SetRadius((double).01);
          profileKMapper = vtkPolyDataMapper.New();
          profileKMapper.SetInputConnection((vtkAlgorithmOutput)profileKTubes.GetOutputPort());
          profileK = new vtkActor();
          profileK.SetMapper((vtkMapper)profileKMapper);
          profileK.GetProperty().SetDiffuseColor((double) 0.8900, 0.8100, 0.3400 );
          profileK.GetProperty().SetSpecular((double).3);
          profileK.GetProperty().SetSpecularPower((double)30);
          ren1.AddActor((vtkProp)profileK);
          profileCTubes = new vtkTubeFilter();
          profileCTubes.SetNumberOfSides((int)8);
          profileCTubes.SetInput((vtkDataObject)profileCData);
          profileCTubes.SetRadius((double).01);
          profileCMapper = vtkPolyDataMapper.New();
          profileCMapper.SetInputConnection((vtkAlgorithmOutput)profileCTubes.GetOutputPort());
          profileC = new vtkActor();
          profileC.SetMapper((vtkMapper)profileCMapper);
          profileC.GetProperty().SetDiffuseColor((double) 0.2000, 0.6300, 0.7900 );
          profileC.GetProperty().SetSpecular((double).3);
          profileC.GetProperty().SetSpecularPower((double)30);
          ren1.AddActor((vtkProp)profileC);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Dolly((double)1.5);
          ren1.ResetCameraClippingRange();
          renWin.SetSize((int)300,(int)300);
          // render the image[]
          //[]
          iren.Initialize();
          // prevent the tk window from showing up then start the event loop[]
          //method moved
          //method moved
          //method moved
          //method moved
          //method moved
          //method moved

        //deleteAllVTKObjects();
    }
    /// <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();
    }
Example #48
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setsphere(vtkSphereSource toSet)
 {
     sphere = toSet;
 }
Example #49
0
    /// <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();
    }