예제 #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();
    }
        //读取Camera参数,传递给主窗体
        public void GetCameraParameters(ref double[] CameraFocalPoint, ref double[] CameraPosition, ref double[] CameraViewUp)
        {
            vtkCamera Camera = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer().GetActiveCamera();

            CameraFocalPoint = Camera.GetFocalPoint();
            CameraPosition   = Camera.GetPosition();
            CameraViewUp     = Camera.GetViewUp();
        }
예제 #3
0
        internal void UpdateCamera(vtkCamera mainViewCamera)
        {
            //return;

            vtkCamera OrientationEnumViewCamera = _topRenderer.GetActiveCamera();

            double[] mainViewCameraPosition = mainViewCamera.GetPosition();
            double[] mainViewFocalPosition  = mainViewCamera.GetFocalPoint();
            double[] mainViewViewUp         = mainViewCamera.GetViewUp();

            OrientationEnumViewCamera.SetPosition(mainViewCameraPosition[0], mainViewCameraPosition[1], mainViewCameraPosition[2]);
            OrientationEnumViewCamera.SetFocalPoint(mainViewFocalPosition[0], mainViewFocalPosition[1], mainViewFocalPosition[2]);
            OrientationEnumViewCamera.SetViewUp(mainViewViewUp[0], mainViewViewUp[1], mainViewViewUp[2]);

            _topRenderer.ResetCameraClippingRange();
            //_topRenderer.ResetCamera();
        }
        internal void UpdateCamera(vtkCamera mainViewCamera)
        {
            //return;

            vtkCamera OrientationEnumViewCamera = _topRenderer.GetActiveCamera();

            double[] mainViewCameraPosition = mainViewCamera.GetPosition();
            double[] mainViewFocalPosition  = mainViewCamera.GetFocalPoint();
            double[] mainViewViewUp         = mainViewCamera.GetViewUp();

            OrientationEnumViewCamera.SetPosition(mainViewCameraPosition[0], mainViewCameraPosition[1], mainViewCameraPosition[2]);
            OrientationEnumViewCamera.SetFocalPoint(mainViewFocalPosition[0], mainViewFocalPosition[1], mainViewFocalPosition[2]);
            OrientationEnumViewCamera.SetViewUp(mainViewViewUp[0], mainViewViewUp[1], mainViewViewUp[2]);
            OrientationEnumViewCamera.ComputeViewPlaneNormal();
            OrientationEnumViewCamera.ComputeProjAndViewParams();
            OrientationEnumViewCamera.OrthogonalizeViewUp();

            _topRenderer.ResetCameraClippingRange();
            _topRenderer.ResetCamera();
        }
예제 #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();
    }
    /// <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();
    }
예제 #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();
    }
예제 #8
0
        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            // Create components of the rendering subsystem
            //
            vtkRenderer     ren1   = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
            vtkRenderWindow renWin = renderWindowControl1.RenderWindow;

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

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

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

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

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


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

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

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

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

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


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

            //camera.Zoom(1.5);
        }