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

          // demonstrate labeling of contour with scalar value[]
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.SetMultiSamples(0);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // Read a slice and contour it[]
          v16 = new vtkVolume16Reader();
          v16.SetDataDimensions((int)64,(int)64);
          v16.GetOutput().SetOrigin((double)0.0,(double)0.0,(double)0.0);
          v16.SetDataByteOrderToLittleEndian();
          v16.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter");
          v16.SetImageRange((int)45,(int)45);
          v16.SetDataSpacing((double)3.2,(double)3.2,(double)1.5);
          iso = new vtkContourFilter();
          iso.SetInputConnection((vtkAlgorithmOutput)v16.GetOutputPort());
          iso.GenerateValues((int)6,(double)500,(double)1150);
          iso.Update();
          numPts = iso.GetOutput().GetNumberOfPoints();
          isoMapper = vtkPolyDataMapper.New();
          isoMapper.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
          isoMapper.ScalarVisibilityOn();
          isoMapper.SetScalarRange((double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[1]);
          isoActor = new vtkActor();
          isoActor.SetMapper((vtkMapper)isoMapper);
          // Subsample the points and label them[]
          mask = new vtkMaskPoints();
          mask.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
          mask.SetOnRatio((int)(numPts/50));
          mask.SetMaximumNumberOfPoints((int)50);
          mask.RandomModeOn();
          // Create labels for points - only show visible points[]
          visPts = new vtkSelectVisiblePoints();
          visPts.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort());
          visPts.SetRenderer((vtkRenderer)ren1);
          ldm = new vtkLabeledDataMapper();
          ldm.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort());
          //    ldm SetLabelFormat "%g"[]
          ldm.SetLabelModeToLabelScalars();
          tprop = ldm.GetLabelTextProperty();
          tprop.SetFontFamilyToArial();
          tprop.SetFontSize((int)10);
          tprop.SetColor((double)1,(double)0,(double)0);
          contourLabels = new vtkActor2D();
          contourLabels.SetMapper((vtkMapper2D)ldm);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor2D((vtkProp)isoActor);
          ren1.AddActor2D((vtkProp)contourLabels);
          ren1.SetBackground((double)1,(double)1,(double)1);
          renWin.SetSize((int)500,(int)500);
          renWin.Render();
          ren1.GetActiveCamera().Zoom((double)1.5);
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
示例#2
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setmask(vtkMaskPoints toSet)
 {
     mask = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setmask(vtkMaskPoints toSet)
 {
     mask = toSet;
 }
示例#4
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVlabeledContours(String [] argv)
    {
        //Prefix Content is: ""

        // demonstrate labeling of contour with scalar value[]
        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.SetMultiSamples(0);
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        // Read a slice and contour it[]
        v16 = new vtkVolume16Reader();
        v16.SetDataDimensions((int)64, (int)64);
        v16.GetOutput().SetOrigin((double)0.0, (double)0.0, (double)0.0);
        v16.SetDataByteOrderToLittleEndian();
        v16.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter");
        v16.SetImageRange((int)45, (int)45);
        v16.SetDataSpacing((double)3.2, (double)3.2, (double)1.5);
        iso = new vtkContourFilter();
        iso.SetInputConnection((vtkAlgorithmOutput)v16.GetOutputPort());
        iso.GenerateValues((int)6, (double)500, (double)1150);
        iso.Update();
        numPts    = iso.GetOutput().GetNumberOfPoints();
        isoMapper = vtkPolyDataMapper.New();
        isoMapper.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
        isoMapper.ScalarVisibilityOn();
        isoMapper.SetScalarRange((double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)iso.GetOutput()).GetScalarRange()[1]);
        isoActor = new vtkActor();
        isoActor.SetMapper((vtkMapper)isoMapper);
        // Subsample the points and label them[]
        mask = new vtkMaskPoints();
        mask.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort());
        mask.SetOnRatio((int)(numPts / 50));
        mask.SetMaximumNumberOfPoints((int)50);
        mask.RandomModeOn();
        // Create labels for points - only show visible points[]
        visPts = new vtkSelectVisiblePoints();
        visPts.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort());
        visPts.SetRenderer((vtkRenderer)ren1);
        ldm = new vtkLabeledDataMapper();
        ldm.SetInputConnection((vtkAlgorithmOutput)mask.GetOutputPort());
        //    ldm SetLabelFormat "%g"[]
        ldm.SetLabelModeToLabelScalars();
        tprop = ldm.GetLabelTextProperty();
        tprop.SetFontFamilyToArial();
        tprop.SetFontSize((int)10);
        tprop.SetColor((double)1, (double)0, (double)0);
        contourLabels = new vtkActor2D();
        contourLabels.SetMapper((vtkMapper2D)ldm);
        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.AddActor2D((vtkProp)isoActor);
        ren1.AddActor2D((vtkProp)contourLabels);
        ren1.SetBackground((double)1, (double)1, (double)1);
        renWin.SetSize((int)500, (int)500);
        renWin.Render();
        ren1.GetActiveCamera().Zoom((double)1.5);
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }