Ejemplo n.º 1
0
Archivo: Part.cs Proyecto: ovevans/STAN
        public void ExtractFeatures()
        {
            Filter = vtkDataSetSurfaceFilter.New();
            Filter.SetInput(Grid);
            Filter.Update();
            Faces = Filter.GetOutput();

            vtkFeatureEdges FeatureEdges = vtkFeatureEdges.New();

            FeatureEdges.SetInput(Filter.GetOutput());
            FeatureEdges.Update();

            FeatureEdges.BoundaryEdgesOn();
            FeatureEdges.FeatureEdgesOn();
            FeatureEdges.ManifoldEdgesOn();
            FeatureEdges.NonManifoldEdgesOn();

            // Change Edge color
            FeatureEdges.SetColoring(0);

            // Update
            FeatureEdges.Update();

            vtkPolyDataMapper EdgeMapper = vtkPolyDataMapper.New();

            EdgeMapper.SetInput(FeatureEdges.GetOutput());
            EdgeMapper.ScalarVisibilityOff();

            Edges.SetMapper(EdgeMapper);
            Edges.GetProperty().SetEdgeColor(0, 0, 0);
            Edges.GetProperty().SetColor(0.0, 0.0, 0.0);
            Edges.GetProperty().SetLineWidth((float)1.0);   // Set default edge thickness
            Edges.SetVisibility(0);
        }
Ejemplo n.º 2
0
        private void MatrixMathFilter()
        {
            // 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\tensors.vtk");
            vtkUnstructuredGridReader reader = vtkUnstructuredGridReader.New();

            reader.SetFileName(filePath);
            reader.Update();

            vtkDataSetSurfaceFilter surfaceFilter = vtkDataSetSurfaceFilter.New();

            surfaceFilter.SetInputConnection(reader.GetOutputPort());
            surfaceFilter.Update();

            vtkMatrixMathFilter matrixMathFilter = vtkMatrixMathFilter.New();

            //matrixMathFilter.SetOperationToDeterminant();
            matrixMathFilter.SetOperationToEigenvalue();
            matrixMathFilter.SetInputConnection(surfaceFilter.GetOutputPort());
            matrixMathFilter.Update();
            matrixMathFilter.GetOutput().GetPointData().SetActiveScalars("Eigenvalue");

            vtkXMLPolyDataWriter writer = vtkXMLPolyDataWriter.New();

            writer.SetInputConnection(matrixMathFilter.GetOutputPort());
            writer.SetFileName(System.IO.Path.Combine(root, @"Data\output.vtp"));
            writer.Write();

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(matrixMathFilter.GetOutputPort());

            // actor
            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.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
Ejemplo n.º 3
0
    /// <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();
    }
Ejemplo n.º 4
0
    /// <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();
    }
Ejemplo n.º 5
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());
        }
Ejemplo n.º 6
0
Archivo: Part.cs Proyecto: ovevans/STAN
        /// <summary>
        /// Create new VTK structure of Part:
        /// <br> Points -> Grid -> Mapper -> Actor </br>
        /// </summary>
        public void CreatePart(Dictionary <int, Node> NodeLib, Dictionary <int, Element> ElemLib)
        {
            // Catch nodes - only used by Part
            Nodes = DetectPartNodes(ElemLib);

            // Initialize Elements - to connect vtkCells with Element IDs (and therefore scalar/result value)
            Elements = new List <int>();

            // Initialize VTK data
            Points = vtkPoints.New();
            Grid   = vtkUnstructuredGrid.New();
            Mapper = vtkDataSetMapper.New();
            Actor  = vtkActor.New();
            Edges  = vtkActor.New();
            Faces  = vtkPolyData.New();
            Filter = vtkDataSetSurfaceFilter.New();

            // Insert Points
            foreach (int n in Nodes.Keys)
            {
                Points.InsertNextPoint(NodeLib[n].X, NodeLib[n].Y, NodeLib[n].Z);
            }

            Grid.SetPoints(Points);      // Add points to Grid
            CreateMesh(ElemLib);         // Create Mesh grid

            // Add Grid to Mapper
            Mapper.SetInput(Grid);
            Mapper.SetScalarModeToUseCellData();
            Mapper.ScalarVisibilityOff();
            Mapper.InterpolateScalarsBeforeMappingOn();
            Mapper.Update();

            Actor.SetMapper(Mapper);                        // Add Mapper to Actor
            Actor.GetProperty().SetEdgeVisibility(1);       // Enable wireframe display mode
            Actor.GetProperty().SetLineWidth((float)0.5);   // Set wireframe line thickness
            // Set Actor default color
            ColorID = ID % 13;
            SetColor(ColorID);

            // Outer features
            ExtractFeatures();
        }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setgf8(vtkDataSetSurfaceFilter toSet)
 {
     gf8 = toSet;
 }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVdataSetSurfaceFilter(String [] argv)
    {
        //Prefix Content is: ""

        // create pipeline - structured grid[]
        //[]
        pl3d = new vtkMultiBlockPLOT3DReader();
        pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin");
        pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin");
        pl3d.SetScalarFunctionNumber((int)100);
        pl3d.SetVectorFunctionNumber((int)202);
        pl3d.Update();
        gf = new vtkDataSetSurfaceFilter();
        gf.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        gMapper = vtkPolyDataMapper.New();
        gMapper.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort());
        gMapper.SetScalarRange(
            (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
            (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        gActor = new vtkActor();
        gActor.SetMapper((vtkMapper)gMapper);
        gf2 = new vtkDataSetSurfaceFilter();
        gf2.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        gf2.UseStripsOn();
        g2Mapper = vtkPolyDataMapper.New();
        g2Mapper.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort());
        g2Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        g2Actor = new vtkActor();
        g2Actor.SetMapper((vtkMapper)g2Mapper);
        g2Actor.AddPosition((double)0, (double)15, (double)0);
        // create pipeline - poly data[]
        //[]
        gf3 = new vtkDataSetSurfaceFilter();
        gf3.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort());
        g3Mapper = vtkPolyDataMapper.New();
        g3Mapper.SetInputConnection((vtkAlgorithmOutput)gf3.GetOutputPort());
        g3Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        g3Actor = new vtkActor();
        g3Actor.SetMapper((vtkMapper)g3Mapper);
        g3Actor.AddPosition((double)0, (double)0, (double)15);
        gf4 = new vtkDataSetSurfaceFilter();
        gf4.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort());
        gf4.UseStripsOn();
        g4Mapper = vtkPolyDataMapper.New();
        g4Mapper.SetInputConnection((vtkAlgorithmOutput)gf4.GetOutputPort());
        g4Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        g4Actor = new vtkActor();
        g4Actor.SetMapper((vtkMapper)g4Mapper);
        g4Actor.AddPosition((double)0, (double)15, (double)15);
        // create pipeline - unstructured grid[]
        //[]
        s = new vtkSphere();
        s.SetCenter(((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[0],
                    ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[1],
                    ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[2]);
        s.SetRadius((double)100.0);
        //everything[]
        eg = new vtkExtractGeometry();
        eg.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        eg.SetImplicitFunction((vtkImplicitFunction)s);
        gf5 = new vtkDataSetSurfaceFilter();
        gf5.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort());
        g5Mapper = vtkPolyDataMapper.New();
        g5Mapper.SetInputConnection((vtkAlgorithmOutput)gf5.GetOutputPort());
        g5Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        g5Actor = new vtkActor();
        g5Actor.SetMapper((vtkMapper)g5Mapper);
        g5Actor.AddPosition((double)0, (double)0, (double)30);
        gf6 = new vtkDataSetSurfaceFilter();
        gf6.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort());
        gf6.UseStripsOn();
        g6Mapper = vtkPolyDataMapper.New();
        g6Mapper.SetInputConnection((vtkAlgorithmOutput)gf6.GetOutputPort());
        g6Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        g6Actor = new vtkActor();
        g6Actor.SetMapper((vtkMapper)g6Mapper);
        g6Actor.AddPosition((double)0, (double)15, (double)30);
        // create pipeline - rectilinear grid[]
        //[]
        rgridReader = new vtkRectilinearGridReader();
        rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk");
        rgridReader.Update();
        gf7 = new vtkDataSetSurfaceFilter();
        gf7.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
        g7Mapper = vtkPolyDataMapper.New();
        g7Mapper.SetInputConnection((vtkAlgorithmOutput)gf7.GetOutputPort());
        g7Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],
                                (double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]);
        g7Actor = new vtkActor();
        g7Actor.SetMapper((vtkMapper)g7Mapper);
        g7Actor.SetScale((double)3, (double)3, (double)3);
        gf8 = new vtkDataSetSurfaceFilter();
        gf8.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
        gf8.UseStripsOn();
        g8Mapper = vtkPolyDataMapper.New();
        g8Mapper.SetInputConnection((vtkAlgorithmOutput)gf8.GetOutputPort());
        g8Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],
                                (double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]);
        g8Actor = new vtkActor();
        g8Actor.SetMapper((vtkMapper)g8Mapper);
        g8Actor.SetScale((double)3, (double)3, (double)3);
        g8Actor.AddPosition((double)0, (double)15, (double)0);
        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        ren1.AddActor((vtkProp)gActor);
        ren1.AddActor((vtkProp)g2Actor);
        ren1.AddActor((vtkProp)g3Actor);
        ren1.AddActor((vtkProp)g4Actor);
        ren1.AddActor((vtkProp)g5Actor);
        ren1.AddActor((vtkProp)g6Actor);
        ren1.AddActor((vtkProp)g7Actor);
        ren1.AddActor((vtkProp)g8Actor);
        renWin.SetSize((int)340, (int)550);
        cam1 = ren1.GetActiveCamera();
        cam1.SetClippingRange((double)84, (double)174);
        cam1.SetFocalPoint((double)5.22824, (double)6.09412, (double)35.9813);
        cam1.SetPosition((double)100.052, (double)62.875, (double)102.818);
        cam1.SetViewUp((double)-0.307455, (double)-0.464269, (double)0.830617);
        iren.Initialize();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setsurf3(vtkDataSetSurfaceFilter toSet)
 {
     surf3 = toSet;
 }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestBranchExtentTranslator(String [] argv)
    {
        //Prefix Content is: ""

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

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

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

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

          // create pipeline - rectilinear grid[]
          //[]
          rgridReader = new vtkRectilinearGridReader();
          rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk");
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          rgridReader.Update();
          extract1 = new vtkExtractRectilinearGrid();
          extract1.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
          //extract1 SetVOI 0 46 0 32 0 10[]
          extract1.SetVOI((int)23,(int)40,(int)16,(int)30,(int)9,(int)9);
          extract1.SetSampleRate((int)2,(int)2,(int)1);
          extract1.IncludeBoundaryOn();
          extract1.Update();
          surf1 = new vtkDataSetSurfaceFilter();
          surf1.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort());
          tris = new vtkTriangleFilter();
          tris.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort());
          mapper1 = vtkPolyDataMapper.New();
          mapper1.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort());
          mapper1.SetScalarRange((double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[1]);
          actor1 = new vtkActor();
          actor1.SetMapper((vtkMapper)mapper1);
          // write out a rect grid[]
          // write to the temp directory if possible, otherwise use .[]
          dir = ".";
          dir = TclToCsScriptTestDriver.GetTempDirectory();

          // make sure the directory is writeable first[]
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          rectWriter = new vtkRectilinearGridWriter();
          rectWriter.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort());
          rectWriter.SetFileName((string)"" + (dir.ToString()) + "/rect.tmp");
          rectWriter.Write();
          // delete the file[]
          File.Delete("" + (dir.ToString()) + "/rect.tmp");
        }

          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          //ren1 AddActor actor[]
          ren1.AddActor((vtkProp)actor1);
          renWin.SetSize((int)340,(int)400);
          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 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();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVdataSetSurfaceFilter(String [] argv)
    {
        //Prefix Content is: ""

          // create pipeline - structured grid[]
          //[]
          pl3d = new vtkMultiBlockPLOT3DReader();
          pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin");
          pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin");
          pl3d.SetScalarFunctionNumber((int)100);
          pl3d.SetVectorFunctionNumber((int)202);
          pl3d.Update();
          gf = new vtkDataSetSurfaceFilter();
          gf.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          gMapper = vtkPolyDataMapper.New();
          gMapper.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort());
          gMapper.SetScalarRange(
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          gActor = new vtkActor();
          gActor.SetMapper((vtkMapper)gMapper);
          gf2 = new vtkDataSetSurfaceFilter();
          gf2.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          gf2.UseStripsOn();
          g2Mapper = vtkPolyDataMapper.New();
          g2Mapper.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort());
          g2Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          g2Actor = new vtkActor();
          g2Actor.SetMapper((vtkMapper)g2Mapper);
          g2Actor.AddPosition((double)0,(double)15,(double)0);
          // create pipeline - poly data[]
          //[]
          gf3 = new vtkDataSetSurfaceFilter();
          gf3.SetInputConnection((vtkAlgorithmOutput)gf.GetOutputPort());
          g3Mapper = vtkPolyDataMapper.New();
          g3Mapper.SetInputConnection((vtkAlgorithmOutput)gf3.GetOutputPort());
          g3Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          g3Actor = new vtkActor();
          g3Actor.SetMapper((vtkMapper)g3Mapper);
          g3Actor.AddPosition((double)0,(double)0,(double)15);
          gf4 = new vtkDataSetSurfaceFilter();
          gf4.SetInputConnection((vtkAlgorithmOutput)gf2.GetOutputPort());
          gf4.UseStripsOn();
          g4Mapper = vtkPolyDataMapper.New();
          g4Mapper.SetInputConnection((vtkAlgorithmOutput)gf4.GetOutputPort());
          g4Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          g4Actor = new vtkActor();
          g4Actor.SetMapper((vtkMapper)g4Mapper);
          g4Actor.AddPosition((double)0,(double)15,(double)15);
          // create pipeline - unstructured grid[]
          //[]
          s = new vtkSphere();
          s.SetCenter(((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[0],
              ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[1],
              ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetCenter()[2]);
          s.SetRadius((double)100.0);
          //everything[]
          eg = new vtkExtractGeometry();
          eg.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          eg.SetImplicitFunction((vtkImplicitFunction)s);
          gf5 = new vtkDataSetSurfaceFilter();
          gf5.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort());
          g5Mapper = vtkPolyDataMapper.New();
          g5Mapper.SetInputConnection((vtkAlgorithmOutput)gf5.GetOutputPort());
          g5Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          g5Actor = new vtkActor();
          g5Actor.SetMapper((vtkMapper)g5Mapper);
          g5Actor.AddPosition((double)0,(double)0,(double)30);
          gf6 = new vtkDataSetSurfaceFilter();
          gf6.SetInputConnection((vtkAlgorithmOutput)eg.GetOutputPort());
          gf6.UseStripsOn();
          g6Mapper = vtkPolyDataMapper.New();
          g6Mapper.SetInputConnection((vtkAlgorithmOutput)gf6.GetOutputPort());
          g6Mapper.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          g6Actor = new vtkActor();
          g6Actor.SetMapper((vtkMapper)g6Mapper);
          g6Actor.AddPosition((double)0,(double)15,(double)30);
          // create pipeline - rectilinear grid[]
          //[]
          rgridReader = new vtkRectilinearGridReader();
          rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk");
          rgridReader.Update();
          gf7 = new vtkDataSetSurfaceFilter();
          gf7.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
          g7Mapper = vtkPolyDataMapper.New();
          g7Mapper.SetInputConnection((vtkAlgorithmOutput)gf7.GetOutputPort());
          g7Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],
          (double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]);
          g7Actor = new vtkActor();
          g7Actor.SetMapper((vtkMapper)g7Mapper);
          g7Actor.SetScale((double)3,(double)3,(double)3);
          gf8 = new vtkDataSetSurfaceFilter();
          gf8.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
          gf8.UseStripsOn();
          g8Mapper = vtkPolyDataMapper.New();
          g8Mapper.SetInputConnection((vtkAlgorithmOutput)gf8.GetOutputPort());
          g8Mapper.SetScalarRange((double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[0],
          (double)((vtkDataSet)rgridReader.GetOutput()).GetScalarRange()[1]);
          g8Actor = new vtkActor();
          g8Actor.SetMapper((vtkMapper)g8Mapper);
          g8Actor.SetScale((double)3,(double)3,(double)3);
          g8Actor.AddPosition((double)0,(double)15,(double)0);
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          ren1.AddActor((vtkProp)gActor);
          ren1.AddActor((vtkProp)g2Actor);
          ren1.AddActor((vtkProp)g3Actor);
          ren1.AddActor((vtkProp)g4Actor);
          ren1.AddActor((vtkProp)g5Actor);
          ren1.AddActor((vtkProp)g6Actor);
          ren1.AddActor((vtkProp)g7Actor);
          ren1.AddActor((vtkProp)g8Actor);
          renWin.SetSize((int)340,(int)550);
          cam1 = ren1.GetActiveCamera();
          cam1.SetClippingRange((double)84,(double)174);
          cam1.SetFocalPoint((double)5.22824,(double)6.09412,(double)35.9813);
          cam1.SetPosition((double)100.052,(double)62.875,(double)102.818);
          cam1.SetViewUp((double)-0.307455,(double)-0.464269,(double)0.830617);
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setgf8(vtkDataSetSurfaceFilter toSet)
 {
     gf8 = toSet;
 }
Ejemplo n.º 16
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setsurf(vtkDataSetSurfaceFilter toSet)
 {
     surf = toSet;
 }
    /// <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();
    }
Ejemplo n.º 18
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVextractRectGrid(String [] argv)
    {
        //Prefix Content is: ""

        // create pipeline - rectilinear grid[]
        //[]
        rgridReader = new vtkRectilinearGridReader();
        rgridReader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk");
        outline = new vtkOutlineFilter();
        outline.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
        mapper = vtkPolyDataMapper.New();
        mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        actor = new vtkActor();
        actor.SetMapper((vtkMapper)mapper);
        rgridReader.Update();
        extract1 = new vtkExtractRectilinearGrid();
        extract1.SetInputConnection((vtkAlgorithmOutput)rgridReader.GetOutputPort());
        //extract1 SetVOI 0 46 0 32 0 10[]
        extract1.SetVOI((int)23, (int)40, (int)16, (int)30, (int)9, (int)9);
        extract1.SetSampleRate((int)2, (int)2, (int)1);
        extract1.IncludeBoundaryOn();
        extract1.Update();
        surf1 = new vtkDataSetSurfaceFilter();
        surf1.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort());
        tris = new vtkTriangleFilter();
        tris.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort());
        mapper1 = vtkPolyDataMapper.New();
        mapper1.SetInputConnection((vtkAlgorithmOutput)tris.GetOutputPort());
        mapper1.SetScalarRange((double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)extract1.GetOutput()).GetScalarRange()[1]);
        actor1 = new vtkActor();
        actor1.SetMapper((vtkMapper)mapper1);
        // write out a rect grid[]
        // write to the temp directory if possible, otherwise use .[]
        dir = ".";
        dir = TclToCsScriptTestDriver.GetTempDirectory();


        // make sure the directory is writeable first[]
        try
        {
            channel       = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
            tryCatchError = "NOERROR";
        }
        catch (Exception)
        { tryCatchError = "ERROR"; }

        if (tryCatchError.Equals("NOERROR"))
        {
            channel.Close();
            File.Delete("" + (dir.ToString()) + "/test.tmp");
            rectWriter = new vtkRectilinearGridWriter();
            rectWriter.SetInputConnection((vtkAlgorithmOutput)extract1.GetOutputPort());
            rectWriter.SetFileName((string)"" + (dir.ToString()) + "/rect.tmp");
            rectWriter.Write();
            // delete the file[]
            File.Delete("" + (dir.ToString()) + "/rect.tmp");
        }


        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        //ren1 AddActor actor[]
        ren1.AddActor((vtkProp)actor1);
        renWin.SetSize((int)340, (int)400);
        iren.Initialize();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }