Пример #1
1
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVPlot3DVectors(String [] argv)
    {
        //Prefix Content is: ""

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

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


            i = i + 1;
        }
        //[]
        // now layout renderers[]
        column = 1;
        row    = 1;
        deltaX = 1.0 / 2.0;
        deltaY = 1.0 / 2.0;
        foreach (string vectorFunction in vectorFunctions.Split(new char[] { ' ' }))
        {
            ren[getArrayIndex(vectorFunction)].SetViewport((double)(column - 1) * deltaX + (deltaX * .05), (double)(row - 1) * deltaY + (deltaY * .05), (double)column * deltaX - (deltaX * .05), (double)row * deltaY - (deltaY * .05));
            column = column + 1;
            if ((column) > 2)
            {
                column = 1;
                row    = row + 1;
            }
        }
        camera.SetViewUp((double)1, (double)0, (double)0);
        camera.SetFocalPoint((double)0, (double)0, (double)0);
        camera.SetPosition((double).4, (double)-.5, (double)-.75);
        ren[200].ResetCamera();
        camera.Dolly((double)1.25);
        ren[200].ResetCameraClippingRange();
        ren[201].ResetCameraClippingRange();
        ren[202].ResetCameraClippingRange();
        ren[210].ResetCameraClippingRange();
        light.SetPosition(camera.GetPosition()[0], camera.GetPosition()[1], camera.GetPosition()[2]);
        light.SetFocalPoint(camera.GetFocalPoint()[0], camera.GetFocalPoint()[1], camera.GetFocalPoint()[2]);
        renWin.SetSize(350, 350);
        renWin.Render();
        iren.Initialize();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
Пример #2
0
     private void ReadPLOT3D() {
         // 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 filePathXYZ = System.IO.Path.Combine(root, @"Data\bluntfinxyz.bin");
         string filePathQ = System.IO.Path.Combine(root, @"Data\bluntfinq.bin");
         //string filePathXYZ = System.IO.Path.Combine(root, @"Data\combxyz.bin");
         //string filePathQ = System.IO.Path.Combine(root, @"Data\combq.bin");

         vtkMultiBlockPLOT3DReader reader = vtkMultiBlockPLOT3DReader.New();
         reader.SetXYZFileName(filePathXYZ);
         reader.SetQFileName(filePathQ);

         // Specify the scalar function to extract. If ==(-1), then no scalar function is extracted. 
         int scalarFctNo = reader.GetScalarFunctionNumber();
         int vectorFctNo = reader.GetVectorFunctionNumber();
         if(scalarFctNo != -1)
            reader.SetScalarFunctionNumber(scalarFctNo);
         // Specify the vector function to extract. If ==(-1), then no vector function is extracted. 
         if(vectorFctNo != -1)
            reader.SetVectorFunctionNumber(vectorFctNo);
         reader.Update();

         //// geometry filter
         //// This filter is multi-block aware and will request blocks from the
         //// input. These blocks will be processed by simple processes as if they
         //// are the whole dataset
         //vtkCompositeDataGeometryFilter geom1 = vtkCompositeDataGeometryFilter.New();
         //geom1.SetInputConnection(0, reader.GetOutputPort(0));

         vtkStructuredGridGeometryFilter geometryFilter = vtkStructuredGridGeometryFilter.New();
         geometryFilter.SetInput(reader.GetOutput().GetBlock(0));
         //geometryFilter.SetInputConnection(geom1.GetOutputPort(0));
         geometryFilter.Update();

         // Visualize
         vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
         mapper.SetInputConnection(geometryFilter.GetOutputPort());
         //mapper.SetInputConnection(geom1.GetOutputPort());
         mapper.ScalarVisibilityOn();
         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);
      }
Пример #3
0
        private void ReadStructuredGrid()
        {
            // 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\multicomb_0.vts");

            // reader
            vtkXMLStructuredGridReader reader = vtkXMLStructuredGridReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            reader.SetFileName(filePath);
            reader.Update(); // here we read the file actually

            vtkStructuredGridGeometryFilter geometryFilter = vtkStructuredGridGeometryFilter.New();

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

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

            mapper.SetInputConnection(geometryFilter.GetOutputPort());

            //// mapper
            //vtkDataSetMapper mapper = vtkDataSetMapper.New();
            //mapper.SetInputConnection(reader.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);
        }
Пример #4
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVtextureThreshold(String [] argv)
    {
        //Prefix Content is: ""

          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // read data[]
          //[]
          pl3d = new vtkMultiBlockPLOT3DReader();
          pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinxyz.bin");
          pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinq.bin");
          pl3d.SetScalarFunctionNumber((int)100);
          pl3d.SetVectorFunctionNumber((int)202);
          pl3d.Update();
          // wall[]
          //[]
          wall = new vtkStructuredGridGeometryFilter();
          wall.SetInputData(pl3d.GetOutput().GetBlock(0));
          wall.SetExtent((int)0,(int)100,(int)0,(int)0,(int)0,(int)100);
          wallMap = vtkPolyDataMapper.New();
          wallMap.SetInputConnection((vtkAlgorithmOutput)wall.GetOutputPort());
          wallMap.ScalarVisibilityOff();
          wallActor = new vtkActor();
          wallActor.SetMapper((vtkMapper)wallMap);
          wallActor.GetProperty().SetColor((double)0.8,(double)0.8,(double)0.8);
          // fin[]
          // []
          fin = new vtkStructuredGridGeometryFilter();
          fin.SetInputData(pl3d.GetOutput().GetBlock(0));
          fin.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          finMap = vtkPolyDataMapper.New();
          finMap.SetInputConnection((vtkAlgorithmOutput)fin.GetOutputPort());
          finMap.ScalarVisibilityOff();
          finActor = new vtkActor();
          finActor.SetMapper((vtkMapper)finMap);
          finActor.GetProperty().SetColor((double)0.8,(double)0.8,(double)0.8);
          // planes to threshold[]
          tmap = new vtkStructuredPointsReader();
          tmap.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/texThres2.vtk");
          texture = new vtkTexture();
          texture.SetInputConnection((vtkAlgorithmOutput)tmap.GetOutputPort());
          texture.InterpolateOff();
          texture.RepeatOff();
          plane1 = new vtkStructuredGridGeometryFilter();
          plane1.SetInputData(pl3d.GetOutput().GetBlock(0));
          plane1.SetExtent((int)10,(int)10,(int)0,(int)100,(int)0,(int)100);
          thresh1 = new vtkThresholdTextureCoords();
          thresh1.SetInputConnection((vtkAlgorithmOutput)plane1.GetOutputPort());
          thresh1.ThresholdByUpper((double)1.5);
          plane1Map = new vtkDataSetMapper();
          plane1Map.SetInputConnection((vtkAlgorithmOutput)thresh1.GetOutputPort());
          plane1Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          plane1Actor = new vtkActor();
          plane1Actor.SetMapper((vtkMapper)plane1Map);
          plane1Actor.SetTexture((vtkTexture)texture);
          plane1Actor.GetProperty().SetOpacity((double)0.999);
          plane2 = new vtkStructuredGridGeometryFilter();
          plane2.SetInputData(pl3d.GetOutput().GetBlock(0));
          plane2.SetExtent((int)30,(int)30,(int)0,(int)100,(int)0,(int)100);
          thresh2 = new vtkThresholdTextureCoords();
          thresh2.SetInputConnection((vtkAlgorithmOutput)plane2.GetOutputPort());
          thresh2.ThresholdByLower((double)1.5);
          plane2Map = new vtkDataSetMapper();
          plane2Map.SetInputConnection((vtkAlgorithmOutput)thresh2.GetOutputPort());
          plane2Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          plane2Actor = new vtkActor();
          plane2Actor.SetMapper((vtkMapper)plane2Map);
          plane2Actor.SetTexture((vtkTexture)texture);
          plane2Actor.GetProperty().SetOpacity((double)0.999);
          plane3 = new vtkStructuredGridGeometryFilter();
          plane3.SetInputData(pl3d.GetOutput().GetBlock(0));
          plane3.SetExtent((int)35,(int)35,(int)0,(int)100,(int)0,(int)100);
          thresh3 = new vtkThresholdTextureCoords();
          thresh3.SetInputConnection((vtkAlgorithmOutput)plane3.GetOutputPort());
          thresh3.ThresholdBetween((double)1.5,(double)1.8);
          plane3Map = new vtkDataSetMapper();
          plane3Map.SetInputConnection((vtkAlgorithmOutput)thresh3.GetOutputPort());
          plane3Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          plane3Actor = new vtkActor();
          plane3Actor.SetMapper((vtkMapper)plane3Map);
          plane3Actor.SetTexture((vtkTexture)texture);
          plane3Actor.GetProperty().SetOpacity((double)0.999);
          // outline[]
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputData(pl3d.GetOutput().GetBlock(0));
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineProp = outlineActor.GetProperty();
          outlineProp.SetColor((double)0,(double)0,(double)0);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)wallActor);
          ren1.AddActor((vtkProp)finActor);
          ren1.AddActor((vtkProp)plane1Actor);
          ren1.AddActor((vtkProp)plane2Actor);
          ren1.AddActor((vtkProp)plane3Actor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)256,(int)256);
          cam1 = new vtkCamera();
          cam1.SetClippingRange((double)1.51176,(double)75.5879);
          cam1.SetFocalPoint((double)2.33749,(double)2.96739,(double)3.61023);
          cam1.SetPosition((double)10.8787,(double)5.27346,(double)15.8687);
          cam1.SetViewAngle((double)30);
          cam1.SetViewUp((double)-0.0610856,(double)0.987798,(double)-0.143262);
          ren1.SetActiveCamera((vtkCamera)cam1);
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Пример #5
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();
    }
Пример #6
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setplane1(vtkStructuredGridGeometryFilter toSet)
 {
     plane1 = toSet;
 }
Пример #7
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVtextureThreshold(String [] argv)
    {
        //Prefix Content is: ""

        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        // read data[]
        //[]
        pl3d = new vtkMultiBlockPLOT3DReader();
        pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinxyz.bin");
        pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/bluntfinq.bin");
        pl3d.SetScalarFunctionNumber((int)100);
        pl3d.SetVectorFunctionNumber((int)202);
        pl3d.Update();
        // wall[]
        //[]
        wall = new vtkStructuredGridGeometryFilter();
        wall.SetInputData(pl3d.GetOutput().GetBlock(0));
        wall.SetExtent((int)0, (int)100, (int)0, (int)0, (int)0, (int)100);
        wallMap = vtkPolyDataMapper.New();
        wallMap.SetInputConnection((vtkAlgorithmOutput)wall.GetOutputPort());
        wallMap.ScalarVisibilityOff();
        wallActor = new vtkActor();
        wallActor.SetMapper((vtkMapper)wallMap);
        wallActor.GetProperty().SetColor((double)0.8, (double)0.8, (double)0.8);
        // fin[]
        // []
        fin = new vtkStructuredGridGeometryFilter();
        fin.SetInputData(pl3d.GetOutput().GetBlock(0));
        fin.SetExtent((int)0, (int)100, (int)0, (int)100, (int)0, (int)0);
        finMap = vtkPolyDataMapper.New();
        finMap.SetInputConnection((vtkAlgorithmOutput)fin.GetOutputPort());
        finMap.ScalarVisibilityOff();
        finActor = new vtkActor();
        finActor.SetMapper((vtkMapper)finMap);
        finActor.GetProperty().SetColor((double)0.8, (double)0.8, (double)0.8);
        // planes to threshold[]
        tmap = new vtkStructuredPointsReader();
        tmap.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/texThres2.vtk");
        texture = new vtkTexture();
        texture.SetInputConnection((vtkAlgorithmOutput)tmap.GetOutputPort());
        texture.InterpolateOff();
        texture.RepeatOff();
        plane1 = new vtkStructuredGridGeometryFilter();
        plane1.SetInputData(pl3d.GetOutput().GetBlock(0));
        plane1.SetExtent((int)10, (int)10, (int)0, (int)100, (int)0, (int)100);
        thresh1 = new vtkThresholdTextureCoords();
        thresh1.SetInputConnection((vtkAlgorithmOutput)plane1.GetOutputPort());
        thresh1.ThresholdByUpper((double)1.5);
        plane1Map = new vtkDataSetMapper();
        plane1Map.SetInputConnection((vtkAlgorithmOutput)thresh1.GetOutputPort());
        plane1Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                 (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        plane1Actor = new vtkActor();
        plane1Actor.SetMapper((vtkMapper)plane1Map);
        plane1Actor.SetTexture((vtkTexture)texture);
        plane1Actor.GetProperty().SetOpacity((double)0.999);
        plane2 = new vtkStructuredGridGeometryFilter();
        plane2.SetInputData(pl3d.GetOutput().GetBlock(0));
        plane2.SetExtent((int)30, (int)30, (int)0, (int)100, (int)0, (int)100);
        thresh2 = new vtkThresholdTextureCoords();
        thresh2.SetInputConnection((vtkAlgorithmOutput)plane2.GetOutputPort());
        thresh2.ThresholdByLower((double)1.5);
        plane2Map = new vtkDataSetMapper();
        plane2Map.SetInputConnection((vtkAlgorithmOutput)thresh2.GetOutputPort());
        plane2Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                 (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        plane2Actor = new vtkActor();
        plane2Actor.SetMapper((vtkMapper)plane2Map);
        plane2Actor.SetTexture((vtkTexture)texture);
        plane2Actor.GetProperty().SetOpacity((double)0.999);
        plane3 = new vtkStructuredGridGeometryFilter();
        plane3.SetInputData(pl3d.GetOutput().GetBlock(0));
        plane3.SetExtent((int)35, (int)35, (int)0, (int)100, (int)0, (int)100);
        thresh3 = new vtkThresholdTextureCoords();
        thresh3.SetInputConnection((vtkAlgorithmOutput)plane3.GetOutputPort());
        thresh3.ThresholdBetween((double)1.5, (double)1.8);
        plane3Map = new vtkDataSetMapper();
        plane3Map.SetInputConnection((vtkAlgorithmOutput)thresh3.GetOutputPort());
        plane3Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                 (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        plane3Actor = new vtkActor();
        plane3Actor.SetMapper((vtkMapper)plane3Map);
        plane3Actor.SetTexture((vtkTexture)texture);
        plane3Actor.GetProperty().SetOpacity((double)0.999);
        // outline[]
        outline = new vtkStructuredGridOutlineFilter();
        outline.SetInputData(pl3d.GetOutput().GetBlock(0));
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineProp = outlineActor.GetProperty();
        outlineProp.SetColor((double)0, (double)0, (double)0);
        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)wallActor);
        ren1.AddActor((vtkProp)finActor);
        ren1.AddActor((vtkProp)plane1Actor);
        ren1.AddActor((vtkProp)plane2Actor);
        ren1.AddActor((vtkProp)plane3Actor);
        ren1.SetBackground((double)1, (double)1, (double)1);
        renWin.SetSize((int)256, (int)256);
        cam1 = new vtkCamera();
        cam1.SetClippingRange((double)1.51176, (double)75.5879);
        cam1.SetFocalPoint((double)2.33749, (double)2.96739, (double)3.61023);
        cam1.SetPosition((double)10.8787, (double)5.27346, (double)15.8687);
        cam1.SetViewAngle((double)30);
        cam1.SetViewUp((double)-0.0610856, (double)0.987798, (double)-0.143262);
        ren1.SetActiveCamera((vtkCamera)cam1);
        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 Setwindow(vtkStructuredGridGeometryFilter toSet)
 {
     window = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setbookshelf2Bottom(vtkStructuredGridGeometryFilter toSet)
 {
     bookshelf2Bottom = toSet;
 }
Пример #10
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVofficeStreamPoints(String [] argv)
    {
        //Prefix Content is: ""

          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // read data[]
          //[]
          reader = new vtkStructuredGridReader();
          reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/office.binary.vtk");
          reader.Update();
          //force a read to occur[]
          // to add coverage for vtkOnePieceExtentTranslator[]
          translator = new vtkOnePieceExtentTranslator();
          vtkStreamingDemandDrivenPipeline.SetExtentTranslator(reader.GetOutputInformation(0), (vtkExtentTranslator)translator);
          length = reader.GetOutput().GetLength();
          maxVelocity = reader.GetOutput().GetPointData().GetVectors().GetMaxNorm();
          maxTime = 35.0*length/maxVelocity;
          table1 = new vtkStructuredGridGeometryFilter();
          table1.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          table1.SetExtent((int)11,(int)15,(int)7,(int)9,(int)8,(int)8);
          mapTable1 = vtkPolyDataMapper.New();
          mapTable1.SetInputConnection((vtkAlgorithmOutput)table1.GetOutputPort());
          mapTable1.ScalarVisibilityOff();
          table1Actor = new vtkActor();
          table1Actor.SetMapper((vtkMapper)mapTable1);
          table1Actor.GetProperty().SetColor((double).59,(double).427,(double).392);
          table2 = new vtkStructuredGridGeometryFilter();
          table2.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          table2.SetExtent((int)11,(int)15,(int)10,(int)12,(int)8,(int)8);
          mapTable2 = vtkPolyDataMapper.New();
          mapTable2.SetInputConnection((vtkAlgorithmOutput)table2.GetOutputPort());
          mapTable2.ScalarVisibilityOff();
          table2Actor = new vtkActor();
          table2Actor.SetMapper((vtkMapper)mapTable2);
          table2Actor.GetProperty().SetColor((double).59,(double).427,(double).392);
          FilingCabinet1 = new vtkStructuredGridGeometryFilter();
          FilingCabinet1.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          FilingCabinet1.SetExtent((int)15,(int)15,(int)7,(int)9,(int)0,(int)8);
          mapFilingCabinet1 = vtkPolyDataMapper.New();
          mapFilingCabinet1.SetInputConnection((vtkAlgorithmOutput)FilingCabinet1.GetOutputPort());
          mapFilingCabinet1.ScalarVisibilityOff();
          FilingCabinet1Actor = new vtkActor();
          FilingCabinet1Actor.SetMapper((vtkMapper)mapFilingCabinet1);
          FilingCabinet1Actor.GetProperty().SetColor((double).8,(double).8,(double).6);
          FilingCabinet2 = new vtkStructuredGridGeometryFilter();
          FilingCabinet2.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          FilingCabinet2.SetExtent((int)15,(int)15,(int)10,(int)12,(int)0,(int)8);
          mapFilingCabinet2 = vtkPolyDataMapper.New();
          mapFilingCabinet2.SetInputConnection((vtkAlgorithmOutput)FilingCabinet2.GetOutputPort());
          mapFilingCabinet2.ScalarVisibilityOff();
          FilingCabinet2Actor = new vtkActor();
          FilingCabinet2Actor.SetMapper((vtkMapper)mapFilingCabinet2);
          FilingCabinet2Actor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Top = new vtkStructuredGridGeometryFilter();
          bookshelf1Top.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Top.SetExtent((int)13,(int)13,(int)0,(int)4,(int)0,(int)11);
          mapBookshelf1Top = vtkPolyDataMapper.New();
          mapBookshelf1Top.SetInputConnection((vtkAlgorithmOutput)bookshelf1Top.GetOutputPort());
          mapBookshelf1Top.ScalarVisibilityOff();
          bookshelf1TopActor = new vtkActor();
          bookshelf1TopActor.SetMapper((vtkMapper)mapBookshelf1Top);
          bookshelf1TopActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Bottom = new vtkStructuredGridGeometryFilter();
          bookshelf1Bottom.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Bottom.SetExtent((int)20,(int)20,(int)0,(int)4,(int)0,(int)11);
          mapBookshelf1Bottom = vtkPolyDataMapper.New();
          mapBookshelf1Bottom.SetInputConnection((vtkAlgorithmOutput)bookshelf1Bottom.GetOutputPort());
          mapBookshelf1Bottom.ScalarVisibilityOff();
          bookshelf1BottomActor = new vtkActor();
          bookshelf1BottomActor.SetMapper((vtkMapper)mapBookshelf1Bottom);
          bookshelf1BottomActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Front = new vtkStructuredGridGeometryFilter();
          bookshelf1Front.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Front.SetExtent((int)13,(int)20,(int)0,(int)0,(int)0,(int)11);
          mapBookshelf1Front = vtkPolyDataMapper.New();
          mapBookshelf1Front.SetInputConnection((vtkAlgorithmOutput)bookshelf1Front.GetOutputPort());
          mapBookshelf1Front.ScalarVisibilityOff();
          bookshelf1FrontActor = new vtkActor();
          bookshelf1FrontActor.SetMapper((vtkMapper)mapBookshelf1Front);
          bookshelf1FrontActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1Back = new vtkStructuredGridGeometryFilter();
          bookshelf1Back.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1Back.SetExtent((int)13,(int)20,(int)4,(int)4,(int)0,(int)11);
          mapBookshelf1Back = vtkPolyDataMapper.New();
          mapBookshelf1Back.SetInputConnection((vtkAlgorithmOutput)bookshelf1Back.GetOutputPort());
          mapBookshelf1Back.ScalarVisibilityOff();
          bookshelf1BackActor = new vtkActor();
          bookshelf1BackActor.SetMapper((vtkMapper)mapBookshelf1Back);
          bookshelf1BackActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1LHS = new vtkStructuredGridGeometryFilter();
          bookshelf1LHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1LHS.SetExtent((int)13,(int)20,(int)0,(int)4,(int)0,(int)0);
          mapBookshelf1LHS = vtkPolyDataMapper.New();
          mapBookshelf1LHS.SetInputConnection((vtkAlgorithmOutput)bookshelf1LHS.GetOutputPort());
          mapBookshelf1LHS.ScalarVisibilityOff();
          bookshelf1LHSActor = new vtkActor();
          bookshelf1LHSActor.SetMapper((vtkMapper)mapBookshelf1LHS);
          bookshelf1LHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf1RHS = new vtkStructuredGridGeometryFilter();
          bookshelf1RHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf1RHS.SetExtent((int)13,(int)20,(int)0,(int)4,(int)11,(int)11);
          mapBookshelf1RHS = vtkPolyDataMapper.New();
          mapBookshelf1RHS.SetInputConnection((vtkAlgorithmOutput)bookshelf1RHS.GetOutputPort());
          mapBookshelf1RHS.ScalarVisibilityOff();
          bookshelf1RHSActor = new vtkActor();
          bookshelf1RHSActor.SetMapper((vtkMapper)mapBookshelf1RHS);
          bookshelf1RHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Top = new vtkStructuredGridGeometryFilter();
          bookshelf2Top.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Top.SetExtent((int)13,(int)13,(int)15,(int)19,(int)0,(int)11);
          mapBookshelf2Top = vtkPolyDataMapper.New();
          mapBookshelf2Top.SetInputConnection((vtkAlgorithmOutput)bookshelf2Top.GetOutputPort());
          mapBookshelf2Top.ScalarVisibilityOff();
          bookshelf2TopActor = new vtkActor();
          bookshelf2TopActor.SetMapper((vtkMapper)mapBookshelf2Top);
          bookshelf2TopActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Bottom = new vtkStructuredGridGeometryFilter();
          bookshelf2Bottom.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Bottom.SetExtent((int)20,(int)20,(int)15,(int)19,(int)0,(int)11);
          mapBookshelf2Bottom = vtkPolyDataMapper.New();
          mapBookshelf2Bottom.SetInputConnection((vtkAlgorithmOutput)bookshelf2Bottom.GetOutputPort());
          mapBookshelf2Bottom.ScalarVisibilityOff();
          bookshelf2BottomActor = new vtkActor();
          bookshelf2BottomActor.SetMapper((vtkMapper)mapBookshelf2Bottom);
          bookshelf2BottomActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Front = new vtkStructuredGridGeometryFilter();
          bookshelf2Front.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Front.SetExtent((int)13,(int)20,(int)15,(int)15,(int)0,(int)11);
          mapBookshelf2Front = vtkPolyDataMapper.New();
          mapBookshelf2Front.SetInputConnection((vtkAlgorithmOutput)bookshelf2Front.GetOutputPort());
          mapBookshelf2Front.ScalarVisibilityOff();
          bookshelf2FrontActor = new vtkActor();
          bookshelf2FrontActor.SetMapper((vtkMapper)mapBookshelf2Front);
          bookshelf2FrontActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2Back = new vtkStructuredGridGeometryFilter();
          bookshelf2Back.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2Back.SetExtent((int)13,(int)20,(int)19,(int)19,(int)0,(int)11);
          mapBookshelf2Back = vtkPolyDataMapper.New();
          mapBookshelf2Back.SetInputConnection((vtkAlgorithmOutput)bookshelf2Back.GetOutputPort());
          mapBookshelf2Back.ScalarVisibilityOff();
          bookshelf2BackActor = new vtkActor();
          bookshelf2BackActor.SetMapper((vtkMapper)mapBookshelf2Back);
          bookshelf2BackActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2LHS = new vtkStructuredGridGeometryFilter();
          bookshelf2LHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2LHS.SetExtent((int)13,(int)20,(int)15,(int)19,(int)0,(int)0);
          mapBookshelf2LHS = vtkPolyDataMapper.New();
          mapBookshelf2LHS.SetInputConnection((vtkAlgorithmOutput)bookshelf2LHS.GetOutputPort());
          mapBookshelf2LHS.ScalarVisibilityOff();
          bookshelf2LHSActor = new vtkActor();
          bookshelf2LHSActor.SetMapper((vtkMapper)mapBookshelf2LHS);
          bookshelf2LHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          bookshelf2RHS = new vtkStructuredGridGeometryFilter();
          bookshelf2RHS.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          bookshelf2RHS.SetExtent((int)13,(int)20,(int)15,(int)19,(int)11,(int)11);
          mapBookshelf2RHS = vtkPolyDataMapper.New();
          mapBookshelf2RHS.SetInputConnection((vtkAlgorithmOutput)bookshelf2RHS.GetOutputPort());
          mapBookshelf2RHS.ScalarVisibilityOff();
          bookshelf2RHSActor = new vtkActor();
          bookshelf2RHSActor.SetMapper((vtkMapper)mapBookshelf2RHS);
          bookshelf2RHSActor.GetProperty().SetColor((double).8,(double).8,(double).6);
          window = new vtkStructuredGridGeometryFilter();
          window.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          window.SetExtent((int)20,(int)20,(int)6,(int)13,(int)10,(int)13);
          mapWindow = vtkPolyDataMapper.New();
          mapWindow.SetInputConnection((vtkAlgorithmOutput)window.GetOutputPort());
          mapWindow.ScalarVisibilityOff();
          windowActor = new vtkActor();
          windowActor.SetMapper((vtkMapper)mapWindow);
          windowActor.GetProperty().SetColor((double).3,(double).3,(double).5);
          outlet = new vtkStructuredGridGeometryFilter();
          outlet.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          outlet.SetExtent((int)0,(int)0,(int)9,(int)10,(int)14,(int)16);
          mapOutlet = vtkPolyDataMapper.New();
          mapOutlet.SetInputConnection((vtkAlgorithmOutput)outlet.GetOutputPort());
          mapOutlet.ScalarVisibilityOff();
          outletActor = new vtkActor();
          outletActor.SetMapper((vtkMapper)mapOutlet);
          outletActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          inlet = new vtkStructuredGridGeometryFilter();
          inlet.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          inlet.SetExtent((int)0,(int)0,(int)9,(int)10,(int)0,(int)6);
          mapInlet = vtkPolyDataMapper.New();
          mapInlet.SetInputConnection((vtkAlgorithmOutput)inlet.GetOutputPort());
          mapInlet.ScalarVisibilityOff();
          inletActor = new vtkActor();
          inletActor.SetMapper((vtkMapper)mapInlet);
          inletActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          mapOutline = vtkPolyDataMapper.New();
          mapOutline.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)mapOutline);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create source for streamtubes[]
          streamer = new vtkStreamPoints();
          streamer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          streamer.SetStartPosition((double)0.1,(double)2.1,(double)0.5);
          streamer.SetMaximumPropagationTime((double)500);
          streamer.SetTimeIncrement((double)0.5);
          streamer.SetIntegrationDirectionToForward();
          cone = new vtkConeSource();
          cone.SetResolution((int)8);
          cones = new vtkGlyph3D();
          cones.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          cones.SetSourceConnection(cone.GetOutputPort());
          cones.SetScaleFactor((double)0.5);
          cones.SetScaleModeToScaleByVector();
          mapCones = vtkPolyDataMapper.New();
          mapCones.SetInputConnection((vtkAlgorithmOutput)cones.GetOutputPort());
          mapCones.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)reader.GetOutput()).GetScalarRange()[1]);
          conesActor = new vtkActor();
          conesActor.SetMapper((vtkMapper)mapCones);
          ren1.AddActor((vtkProp)table1Actor);
          ren1.AddActor((vtkProp)table2Actor);
          ren1.AddActor((vtkProp)FilingCabinet1Actor);
          ren1.AddActor((vtkProp)FilingCabinet2Actor);
          ren1.AddActor((vtkProp)bookshelf1TopActor);
          ren1.AddActor((vtkProp)bookshelf1BottomActor);
          ren1.AddActor((vtkProp)bookshelf1FrontActor);
          ren1.AddActor((vtkProp)bookshelf1BackActor);
          ren1.AddActor((vtkProp)bookshelf1LHSActor);
          ren1.AddActor((vtkProp)bookshelf1RHSActor);
          ren1.AddActor((vtkProp)bookshelf2TopActor);
          ren1.AddActor((vtkProp)bookshelf2BottomActor);
          ren1.AddActor((vtkProp)bookshelf2FrontActor);
          ren1.AddActor((vtkProp)bookshelf2BackActor);
          ren1.AddActor((vtkProp)bookshelf2LHSActor);
          ren1.AddActor((vtkProp)bookshelf2RHSActor);
          ren1.AddActor((vtkProp)windowActor);
          ren1.AddActor((vtkProp)outletActor);
          ren1.AddActor((vtkProp)inletActor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)conesActor);
          ren1.SetBackground((double)0.4,(double)0.4,(double)0.5);
          aCamera = new vtkCamera();
          aCamera.SetClippingRange((double)0.7724,(double)39);
          aCamera.SetFocalPoint((double)1.14798,(double)3.08416,(double)2.47187);
          aCamera.SetPosition((double)-2.64683,(double)-3.55525,(double)3.55848);
          aCamera.SetViewUp((double)0.0511273,(double)0.132773,(double)0.989827);
          aCamera.SetViewAngle((double)15.5033);
          ren1.SetActiveCamera((vtkCamera)aCamera);
          renWin.SetSize((int)500,(int)300);
          iren.Initialize();
          // interact with data[]

        //deleteAllVTKObjects();
    }
Пример #11
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setoutlet(vtkStructuredGridGeometryFilter toSet)
 {
     outlet = toSet;
 }
Пример #12
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setplane1(vtkStructuredGridGeometryFilter toSet)
 {
     plane1 = toSet;
 }
        private void XMLStructuredGridWriter()
        {
            // 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\structuredgrid_test.vts");
            // Create a grid
            vtkStructuredGrid structuredGrid = vtkStructuredGrid.New();
            vtkPoints         points         = vtkPoints.New();

            points.InsertNextPoint(0, 0, 0);
            points.InsertNextPoint(1, 0, 0);
            points.InsertNextPoint(0, 1, 0);
            points.InsertNextPoint(1, 1, 0);
            points.InsertNextPoint(0, 2, 0);
            points.InsertNextPoint(1, 2, 1);

            // Specify the dimensions of the grid
            structuredGrid.SetDimensions(2, 3, 1);
            structuredGrid.SetPoints(points);

            // Write file
            vtkXMLStructuredGridWriter writer = vtkXMLStructuredGridWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(structuredGrid);
            writer.Write();

            // Read and display file for verification that it was written correctly
            vtkXMLStructuredGridReader reader = vtkXMLStructuredGridReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            reader.SetFileName(filePath);
            reader.Update(); // here we read the file actually

            vtkStructuredGridGeometryFilter geometryFilter = vtkStructuredGridGeometryFilter.New();

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

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

            mapper.SetInputConnection(geometryFilter.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);
        }
Пример #14
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVpolyConn(String [] argv)
    {
        //Prefix Content is: ""

        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        // read data[]
        //[]
        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();
        // planes to connect[]
        plane1 = new vtkStructuredGridGeometryFilter();
        plane1.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        plane1.SetExtent((int)20, (int)20, (int)0, (int)100, (int)0, (int)100);
        conn = new vtkPolyDataConnectivityFilter();
        conn.SetInputConnection((vtkAlgorithmOutput)plane1.GetOutputPort());
        conn.ScalarConnectivityOn();
        conn.SetScalarRange((double)0.19, (double)0.25);
        plane1Map = vtkPolyDataMapper.New();
        plane1Map.SetInputConnection((vtkAlgorithmOutput)conn.GetOutputPort());
        plane1Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
                                 (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
        plane1Actor = new vtkActor();
        plane1Actor.SetMapper((vtkMapper)plane1Map);
        plane1Actor.GetProperty().SetOpacity((double)0.999);
        // outline[]
        outline = new vtkStructuredGridOutlineFilter();
        outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineProp = outlineActor.GetProperty();
        outlineProp.SetColor((double)0, (double)0, (double)0);
        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)plane1Actor);
        ren1.SetBackground((double)1, (double)1, (double)1);
        renWin.SetSize((int)300, (int)300);
        cam1 = new vtkCamera();
        cam1.SetClippingRange((double)14.29, (double)63.53);
        cam1.SetFocalPoint((double)8.58522, (double)1.58266, (double)30.6486);
        cam1.SetPosition((double)37.6808, (double)-20.1298, (double)35.4016);
        cam1.SetViewAngle((double)30);
        cam1.SetViewUp((double)-0.0566235, (double)0.140504, (double)0.98846);
        ren1.SetActiveCamera((vtkCamera)cam1);
        iren.Initialize();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
Пример #15
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVprobe(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);
          // cut data[]
          pl3d = new vtkPLOT3DReader();
          pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin");
          pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin");
          pl3d.SetScalarFunctionNumber((int)100);
          pl3d.SetVectorFunctionNumber((int)202);
          pl3d.Update();
          plane = new vtkPlane();
          plane.SetOrigin(pl3d.GetOutput().GetCenter()[0],pl3d.GetOutput().GetCenter()[1],pl3d.GetOutput().GetCenter()[2]);
          plane.SetNormal((double)-0.287,(double)0,(double)0.9579);
          planeCut = new vtkCutter();
          planeCut.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort());
          planeCut.SetCutFunction((vtkImplicitFunction)plane);
          probe = new vtkProbeFilter();
          probe.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort());
          probe.SetSourceConnection((vtkAlgorithmOutput)pl3d.GetOutputPort());
          cutMapper = new vtkDataSetMapper();
          cutMapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort());
          cutMapper.SetScalarRange((double)((vtkStructuredGrid)pl3d.GetOutput()).GetPointData().GetScalars().GetRange()[0],
          (double)((vtkStructuredGrid)pl3d.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
          cutActor = new vtkActor();
          cutActor.SetMapper((vtkMapper)cutMapper);
          //extract plane[]
          compPlane = new vtkStructuredGridGeometryFilter();
          compPlane.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort());
          compPlane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)9,(int)9);
          planeMapper = vtkPolyDataMapper.New();
          planeMapper.SetInputConnection((vtkAlgorithmOutput)compPlane.GetOutputPort());
          planeMapper.ScalarVisibilityOff();
          planeActor = new vtkActor();
          planeActor.SetMapper((vtkMapper)planeMapper);
          planeActor.GetProperty().SetRepresentationToWireframe();
          planeActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          //outline[]
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort());
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineProp = outlineActor.GetProperty();
          outlineProp.SetColor((double)0,(double)0,(double)0);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)planeActor);
          ren1.AddActor((vtkProp)cutActor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)400,(int)300);
          cam1 = ren1.GetActiveCamera();
          cam1.SetClippingRange((double)11.1034,(double)59.5328);
          cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999);
          cam1.SetPosition((double)-2.95748,(double)-26.7271,(double)44.5309);
          cam1.SetViewUp((double)0.0184785,(double)0.479657,(double)0.877262);
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Пример #16
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetcompPlane(vtkStructuredGridGeometryFilter toSet)
 {
     compPlane = toSet;
 }
Пример #17
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setfin(vtkStructuredGridGeometryFilter toSet)
 {
     fin = toSet;
 }
Пример #18
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setwall(vtkStructuredGridGeometryFilter toSet)
 {
     wall = toSet;
 }
Пример #19
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetFilingCabinet2(vtkStructuredGridGeometryFilter toSet)
 {
     FilingCabinet2 = toSet;
 }
Пример #20
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();
    }
Пример #21
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Settable2(vtkStructuredGridGeometryFilter toSet)
 {
     table2 = toSet;
 }
Пример #22
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVPlot3DVectors(String [] argv)
    {
        //Prefix Content is: ""

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

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

          i = i + 1;

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

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

        //deleteAllVTKObjects();
    }
Пример #23
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setbookshelf1Top(vtkStructuredGridGeometryFilter toSet)
 {
     bookshelf1Top = toSet;
 }
Пример #24
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setfin(vtkStructuredGridGeometryFilter toSet)
 {
     fin = toSet;
 }
Пример #25
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setbookshelf2Front(vtkStructuredGridGeometryFilter toSet)
 {
     bookshelf2Front = toSet;
 }
Пример #26
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setwall(vtkStructuredGridGeometryFilter toSet)
 {
     wall = toSet;
 }
Пример #27
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVpolyConn(String [] argv)
    {
        //Prefix Content is: ""

          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // read data[]
          //[]
          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();
          // planes to connect[]
          plane1 = new vtkStructuredGridGeometryFilter();
          plane1.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          plane1.SetExtent((int)20,(int)20,(int)0,(int)100,(int)0,(int)100);
          conn = new vtkPolyDataConnectivityFilter();
          conn.SetInputConnection((vtkAlgorithmOutput)plane1.GetOutputPort());
          conn.ScalarConnectivityOn();
          conn.SetScalarRange((double)0.19,(double)0.25);
          plane1Map = vtkPolyDataMapper.New();
          plane1Map.SetInputConnection((vtkAlgorithmOutput)conn.GetOutputPort());
          plane1Map.SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetScalarRange()[1]);
          plane1Actor = new vtkActor();
          plane1Actor.SetMapper((vtkMapper)plane1Map);
          plane1Actor.GetProperty().SetOpacity((double)0.999);
          // outline[]
          outline = new vtkStructuredGridOutlineFilter();
          outline.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineProp = outlineActor.GetProperty();
          outlineProp.SetColor((double)0,(double)0,(double)0);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)plane1Actor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)300,(int)300);
          cam1 = new vtkCamera();
          cam1.SetClippingRange((double)14.29,(double)63.53);
          cam1.SetFocalPoint((double)8.58522,(double)1.58266,(double)30.6486);
          cam1.SetPosition((double)37.6808,(double)-20.1298,(double)35.4016);
          cam1.SetViewAngle((double)30);
          cam1.SetViewUp((double)-0.0566235,(double)0.140504,(double)0.98846);
          ren1.SetActiveCamera((vtkCamera)cam1);
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Пример #28
0
        private void DrawRainBow()
        {
            //# First create pipeline a simple pipeline that reads a structure grid
            //# and then extracts a plane from the grid. The plane will be colored
            //# differently by using different lookup tables.
            //#
            //# Note: the Update method is manually invoked because it causes the
            //# reader to read; later on we use the output of the reader to set
            //# a range for the scalar values.
            vtkMultiBlockPLOT3DReader pl3d = vtkMultiBlockPLOT3DReader.New();

            pl3d.SetXYZFileName(@"..\..\Data\combxyz.bin");
            pl3d.SetQFileName(@"..\..\Data\combq.bin");
            pl3d.SetScalarFunctionNumber(100);
            pl3d.SetVectorFunctionNumber(202);
            pl3d.Update();
            vtkDataObject pl3d_output = pl3d.GetOutput().GetBlock(0);

            vtkStructuredGridGeometryFilter planeFilter = vtkStructuredGridGeometryFilter.New();

            planeFilter.SetInputData(pl3d_output);
            planeFilter.SetExtent(1, 100, 1, 100, 7, 7);
            vtkLookupTable    lut         = vtkLookupTable.New();
            vtkPolyDataMapper planeMapper = vtkPolyDataMapper.New();

            planeMapper.SetLookupTable(lut);
            planeMapper.SetInputConnection(planeFilter.GetOutputPort());
            //planeMapper.SetScalarRange(pl3d_output.)
            vtkActor planeActor = vtkActor.New();

            planeActor.SetMapper(planeMapper);

            //this creates an outline around the data
            vtkStructuredGridOutlineFilter outlineFilter = vtkStructuredGridOutlineFilter.New();

            outlineFilter.SetInputData(pl3d_output);
            vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New();

            outlineMapper.SetInputConnection(outlineFilter.GetOutputPort());
            vtkActor outlineActor = vtkActor.New();

            outlineActor.SetMapper(outlineMapper);

            //Much of the following is commented out. To try different lookup tables.
            //This create a black to white lut
            //lut.SetHueRange(0, 0);
            //lut.SetSaturationRange(0, 0);
            //lut.SetValueRange(0.2, 1.0);

            //This creates a red to blue lut
            //lut.SetHueRange(0.0, 0.677);

            //This creates a blue to red lue
            lut.SetHueRange(0.667, 0.0);

            //This creates a weird effect. the Build() method cause lookup
            //table to allocate memory and create a table based on the correct
            //hue, saturatioin, value, and alpha range. Here we then
            //manully overwrite the value generated by the Build() method.
            lut.SetNumberOfColors(256);
            lut.Build();
            for (int i = 0; i < 16; i++)
            {
                lut.SetTableValue(i * 16, (float)Color.Red.R / 256, (float)Color.Red.G / 256, (float)Color.Red.B / 256, 1);
                lut.SetTableValue(i * 16 + 1, (float)Color.Green.R / 256, (float)Color.Green.G / 256, (float)Color.Green.B / 256, 1);
                lut.SetTableValue(i * 16 + 2, (float)Color.Blue.R / 256, (float)Color.Blue.G / 256, (float)Color.Blue.B / 256, 1);
                lut.SetTableValue(i * 16 + 3, (float)Color.Black.R / 256, (float)Color.Black.G / 256, (float)Color.Black.B / 256, 1);
            }


            //Create the renderwindow, the render and both actors
            vtkRenderer     ren    = vtkRenderer.New();
            vtkRenderWindow renWin = myRenderWindowControl.RenderWindow;

            renWin.AddRenderer(ren);

            //Add the actors to the renderer, set the backgroud
            ren.AddActor(outlineActor);
            ren.AddActor(planeActor);

            ren.SetBackground(0.1, 0.2, 0.4);
            ren.TwoSidedLightingOff();
        }