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

        math = new vtkMath();
        vtkMath.RandomSeed((int)22);
        pf = new vtkParallelFactory();
        vtkParallelFactory.RegisterFactory((vtkObjectFactory)pf);
        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);
        dst = new vtkDataSetTriangleFilter();
        dst.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        extract = new vtkExtractUnstructuredGridPiece();
        extract.SetInputConnection((vtkAlgorithmOutput)dst.GetOutputPort());
        cf = new vtkContourFilter();
        cf.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort());
        cf.SetValue((int)0, (double)0.24);
        pdn = new vtkPolyDataNormals();
        pdn.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort());
        ps = new vtkPieceScalars();
        ps.SetInputConnection((vtkAlgorithmOutput)pdn.GetOutputPort());
        mapper = vtkPolyDataMapper.New();
        mapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort());
        mapper.SetNumberOfPieces((int)3);
        actor = new vtkActor();
        actor.SetMapper((vtkMapper)mapper);
        ren = vtkRenderer.New();
        ren.AddActor((vtkProp)actor);
        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();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestUnstructuredPieces(String [] argv)
    {
        //Prefix Content is: ""

          math = new vtkMath();
          vtkMath.RandomSeed((int)22);
          pf = new vtkParallelFactory();
          vtkParallelFactory.RegisterFactory((vtkObjectFactory)pf);
          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);
          dst = new vtkDataSetTriangleFilter();
          dst.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          extract = new vtkExtractUnstructuredGridPiece();
          extract.SetInputConnection((vtkAlgorithmOutput)dst.GetOutputPort());
          cf = new vtkContourFilter();
          cf.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort());
          cf.SetValue((int)0,(double)0.24);
          pdn = new vtkPolyDataNormals();
          pdn.SetInputConnection((vtkAlgorithmOutput)cf.GetOutputPort());
          ps = new vtkPieceScalars();
          ps.SetInputConnection((vtkAlgorithmOutput)pdn.GetOutputPort());
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)ps.GetOutputPort());
          mapper.SetNumberOfPieces((int)3);
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          ren = vtkRenderer.New();
          ren.AddActor((vtkProp)actor);
          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();
    }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setmath(vtkMath toSet)
 {
     math = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setmath(vtkMath toSet)
 {
     math = toSet;
 }
    /// <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();
    }
    /// <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 #7
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVPlot3DScalars(String[] argv)
    {
        //Prefix Content is: ""

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

            i = i + 1;

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

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

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

        //deleteAllVTKObjects();
    }
Example #11
0
    /// <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);
        balls.Update();
        glyphPoints = new vtkGlyph3D();
        glyphPoints.SetInputData((vtkDataObject)inputData);
        glyphPoints.SetSourceData((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.SetInputData((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.SetInputData((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();
    }