コード例 #1
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();
    }
コード例 #2
0
        //切片模式_绘制
        private void DrawMode_Slice()
        {
            int[]    xyz = m_ImageData.GetDimensions();
            double[] sp  = m_ImageData.GetSpacing();

            double[] pos = new double[] { m_XPos, m_YPos, m_ZPos };

            #region -------------------XOY切片(垂直Z轴)-------------------

            m_ImageResliceXOY = vtkImageReslice.New();
            m_ImageResliceXOY.SetInput(m_ImageData);
            m_ImageResliceXOY.SetResliceAxesDirectionCosines(
                1, 0, 0,
                0, 1, 0,
                0, 0, 1
                );
            m_ImageResliceXOY.InterpolateOn();
            m_ImageResliceXOY.SetInterpolationModeToNearestNeighbor();
            m_ImageResliceXOY.SetResliceAxesOrigin(pos[0], pos[1], pos[2]);
            m_ImageResliceXOY.SetOutputDimensionality(2);
            m_ImageResliceXOY.Update();

            m_TextureXOY = vtkTexture.New();
            m_TextureXOY.InterpolateOff();
            m_TextureXOY.SetInput(m_ImageResliceXOY.GetOutput());
            m_TextureXOY.SetLookupTable(m_LookupTable);
            m_TextureXOY.MapColorScalarsThroughLookupTableOn();

            //---------------------set plane position----------
            m_PlaneSourceXOY = vtkPlaneSource.New();
            m_PlaneSourceXOY.SetXResolution(xyz[0]);
            m_PlaneSourceXOY.SetYResolution(xyz[1]);
            m_PlaneSourceXOY.SetOrigin(0, 0, 0);
            m_PlaneSourceXOY.SetPoint1((xyz[0] - 1) * sp[0], 0, 0);
            m_PlaneSourceXOY.SetPoint2(0, (xyz[1] - 1) * sp[1], 0);
            m_PlaneSourceXOY.Push(pos[2]);

            //---------------------pipeline--------------------
            m_PlaneMapperXOY = vtkPolyDataMapper.New();
            m_PlaneMapperXOY.SetInput(m_PlaneSourceXOY.GetOutput());

            m_ActorXOY = vtkActor.New();
            m_ActorXOY.SetMapper(m_PlaneMapperXOY);
            m_ActorXOY.SetTexture(m_TextureXOY);

            #endregion

            #region -------------------XOZ切片(垂直Y轴)-------------------

            m_ImageResliceXOZ = vtkImageReslice.New();
            m_ImageResliceXOZ.SetInput(m_ImageData);
            m_ImageResliceXOZ.SetResliceAxesDirectionCosines(
                1, 0, 0,
                0, 0, -1,
                0, 1, 0
                );
            m_ImageResliceXOZ.InterpolateOn();
            m_ImageResliceXOZ.SetInterpolationModeToNearestNeighbor();
            m_ImageResliceXOZ.SetResliceAxesOrigin(pos[0], pos[1], pos[2]);
            m_ImageResliceXOZ.SetOutputDimensionality(2);
            m_ImageResliceXOZ.Update();

            m_TextureXOZ = vtkTexture.New();
            m_TextureXOZ.SetInput(m_ImageResliceXOZ.GetOutput());
            m_TextureXOZ.SetLookupTable(m_LookupTable);
            m_TextureXOZ.MapColorScalarsThroughLookupTableOn();

            //---------------------set plane position--------------------
            m_PlaneSourceXOZ = vtkPlaneSource.New();
            m_PlaneSourceXOZ.SetXResolution(xyz[0]);
            m_PlaneSourceXOZ.SetYResolution(xyz[2]);
            m_PlaneSourceXOZ.SetOrigin(0, 0, (xyz[2] - 1) * sp[2]);
            m_PlaneSourceXOZ.SetPoint1((xyz[0] - 1) * sp[0], 0, (xyz[2] - 1) * sp[2]);
            m_PlaneSourceXOZ.SetPoint2(0, 0, 0);
            m_PlaneSourceXOZ.Push(pos[1]);

            //---------------------pipeline------------------------------
            m_PlaneMapperXOZ = vtkPolyDataMapper.New();
            m_PlaneMapperXOZ.SetInput(m_PlaneSourceXOZ.GetOutput());

            m_ActorXOZ = vtkActor.New();
            m_ActorXOZ.SetMapper(m_PlaneMapperXOZ);
            m_ActorXOZ.SetTexture(m_TextureXOZ);

            #endregion

            #region -------------------YOZ切片(垂直X轴)-------------------

            m_ImageResliceYOZ = vtkImageReslice.New();
            m_ImageResliceYOZ.SetInput(m_ImageData);
            m_ImageResliceYOZ.SetResliceAxesDirectionCosines(
                0, 0, -1,
                0, 1, 0,
                1, 0, 0
                );
            m_ImageResliceYOZ.InterpolateOn();
            m_ImageResliceYOZ.SetInterpolationModeToNearestNeighbor();
            m_ImageResliceYOZ.SetResliceAxesOrigin(pos[0], pos[1], pos[2]);
            m_ImageResliceYOZ.SetOutputDimensionality(2);
            m_ImageResliceYOZ.Update();

            m_TextureYOZ = vtkTexture.New();
            m_TextureYOZ.SetInput(m_ImageResliceYOZ.GetOutput());
            m_TextureYOZ.SetLookupTable(m_LookupTable);
            m_TextureYOZ.MapColorScalarsThroughLookupTableOn();

            //---------------------set plane position--------------------
            m_PlaneSourceYOZ = vtkPlaneSource.New();
            m_PlaneSourceYOZ.SetXResolution(xyz[2]);
            m_PlaneSourceYOZ.SetYResolution(xyz[1]);
            m_PlaneSourceYOZ.SetOrigin(0, 0, (xyz[2] - 1) * sp[2]);
            m_PlaneSourceYOZ.SetPoint1(0, 0, 0);
            m_PlaneSourceYOZ.SetPoint2(0, (xyz[1] - 1) * sp[1], (xyz[2] - 1) * sp[2]);
            m_PlaneSourceYOZ.Push(pos[0]);

            //---------------------pipeline------------------------------
            m_PlaneMapperYOZ = vtkPolyDataMapper.New();
            m_PlaneMapperYOZ.SetInput(m_PlaneSourceYOZ.GetOutput());

            m_ActorYOZ = vtkActor.New();
            m_ActorYOZ.SetMapper(m_PlaneMapperYOZ);
            m_ActorYOZ.SetTexture(m_TextureYOZ);

            #endregion

            m_Renderer.AddActor(m_ActorXOY);
            m_Renderer.AddActor(m_ActorXOZ);
            m_Renderer.AddActor(m_ActorYOZ);
        }
コード例 #3
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();
    }