コード例 #1
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestCutMaterial(String [] argv)
    {
        //Prefix Content is: ""

          // Lets create a data set.[]
          data = new vtkImageData();
          data.SetExtent((int)0,(int)31,(int)0,(int)31,(int)0,(int)31);
          data.SetScalarTypeToFloat();
          // First the data array:[]
          gauss = new vtkImageGaussianSource();
          gauss.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          gauss.SetCenter((double)18,(double)12,(double)20);
          gauss.SetMaximum((double)1.0);
          gauss.SetStandardDeviation((double)10.0);
          gauss.Update();
          a = gauss.GetOutput().GetPointData().GetScalars();
          a.SetName((string)"Gauss");
          data.GetCellData().SetScalars((vtkDataArray)a);
          //skipping Delete gauss
          // Now the material array:[]
          ellipse = new vtkImageEllipsoidSource();
          ellipse.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          ellipse.SetCenter((double)11,(double)12,(double)13);
          ellipse.SetRadius((double)5,(double)9,(double)13);
          ellipse.SetInValue((double)1);
          ellipse.SetOutValue((double)0);
          ellipse.SetOutputScalarTypeToInt();
          ellipse.Update();
          m = ellipse.GetOutput().GetPointData().GetScalars();
          m.SetName((string)"Material");
          data.GetCellData().AddArray((vtkAbstractArray)m);
          //skipping Delete ellipse
          cut = new vtkCutMaterial();
          cut.SetInput((vtkDataObject)data);
          cut.SetMaterialArrayName((string)"Material");
          cut.SetMaterial((int)1);
          cut.SetArrayName((string)"Gauss");
          cut.SetUpVector((double)1,(double)0,(double)0);
          cut.Update();
          mapper2 = vtkPolyDataMapper.New();
          mapper2.SetInputConnection((vtkAlgorithmOutput)cut.GetOutputPort());
          mapper2.SetScalarRange((double)0,(double)1);
          //apper2 SetScalarModeToUseCellFieldData[]
          //apper2 SetColorModeToMapScalars []
          //apper2 ColorByArrayComponent "vtkGhostLevels" 0[]
          actor2 = new vtkActor();
          actor2.SetMapper((vtkMapper)mapper2);
          actor2.SetPosition((double)1.5,(double)0,(double)0);
          ren = vtkRenderer.New();
          ren.AddActor((vtkProp)actor2);
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren);
          p = cut.GetCenterPoint();
          n = cut.GetNormal();
          cam = ren.GetActiveCamera();
          cam.SetFocalPoint(p[0],p[1],p[2]);
          cam.SetViewUp(cut.GetUpVector()[0], cut.GetUpVector()[1], cut.GetUpVector()[2]);
          cam.SetPosition(
          (double)(lindex(n,0))+(double)(lindex(p,0)),
          (double)(lindex(n,1))+(double)(lindex(p,1)),
          (double)(lindex(n,2))+(double)(lindex(p,2)));
          ren.ResetCamera();
          iren = vtkRenderWindowInteractor.New();
          iren.SetRenderWindow(renWin);
          iren.Initialize();

        //deleteAllVTKObjects();
    }
コード例 #2
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestCutMaterial(String [] argv)
    {
        //Prefix Content is: ""

        // Lets create a data set.[]
        data = new vtkImageData();
        data.SetExtent((int)0, (int)31, (int)0, (int)31, (int)0, (int)31);
        data.SetScalarTypeToFloat();
        // First the data array:[]
        gauss = new vtkImageGaussianSource();
        gauss.SetWholeExtent((int)0, (int)30, (int)0, (int)30, (int)0, (int)30);
        gauss.SetCenter((double)18, (double)12, (double)20);
        gauss.SetMaximum((double)1.0);
        gauss.SetStandardDeviation((double)10.0);
        gauss.Update();
        a = gauss.GetOutput().GetPointData().GetScalars();
        a.SetName((string)"Gauss");
        data.GetCellData().SetScalars((vtkDataArray)a);
        //skipping Delete gauss
        // Now the material array:[]
        ellipse = new vtkImageEllipsoidSource();
        ellipse.SetWholeExtent((int)0, (int)30, (int)0, (int)30, (int)0, (int)30);
        ellipse.SetCenter((double)11, (double)12, (double)13);
        ellipse.SetRadius((double)5, (double)9, (double)13);
        ellipse.SetInValue((double)1);
        ellipse.SetOutValue((double)0);
        ellipse.SetOutputScalarTypeToInt();
        ellipse.Update();
        m = ellipse.GetOutput().GetPointData().GetScalars();
        m.SetName((string)"Material");
        data.GetCellData().AddArray((vtkAbstractArray)m);
        //skipping Delete ellipse
        cut = new vtkCutMaterial();
        cut.SetInput((vtkDataObject)data);
        cut.SetMaterialArrayName((string)"Material");
        cut.SetMaterial((int)1);
        cut.SetArrayName((string)"Gauss");
        cut.SetUpVector((double)1, (double)0, (double)0);
        cut.Update();
        mapper2 = vtkPolyDataMapper.New();
        mapper2.SetInputConnection((vtkAlgorithmOutput)cut.GetOutputPort());
        mapper2.SetScalarRange((double)0, (double)1);
        //apper2 SetScalarModeToUseCellFieldData[]
        //apper2 SetColorModeToMapScalars []
        //apper2 ColorByArrayComponent "vtkGhostLevels" 0[]
        actor2 = new vtkActor();
        actor2.SetMapper((vtkMapper)mapper2);
        actor2.SetPosition((double)1.5, (double)0, (double)0);
        ren = vtkRenderer.New();
        ren.AddActor((vtkProp)actor2);
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren);
        p   = cut.GetCenterPoint();
        n   = cut.GetNormal();
        cam = ren.GetActiveCamera();
        cam.SetFocalPoint(p[0], p[1], p[2]);
        cam.SetViewUp(cut.GetUpVector()[0], cut.GetUpVector()[1], cut.GetUpVector()[2]);
        cam.SetPosition(
            (double)(lindex(n, 0)) + (double)(lindex(p, 0)),
            (double)(lindex(n, 1)) + (double)(lindex(p, 1)),
            (double)(lindex(n, 2)) + (double)(lindex(p, 2)));
        ren.ResetCamera();
        iren = vtkRenderWindowInteractor.New();
        iren.SetRenderWindow(renWin);
        iren.Initialize();

//deleteAllVTKObjects();
    }