Exemplo n.º 1
0
        static public vtkProp3D genQuadricSurfaceActor(CompontData data, vtkProperty pro)
        {
            if (data.restriction != null)
            {
                return(genActorByRestriction(data, pro));
            }
            QuadricSurfaceData s = (QuadricSurfaceData)data;

            vtkQuadric quadric = vtkQuadric.New();

            quadric.SetCoefficients(s.param[0], s.param[1], s.param[2], s.param[3], s.param[4], s.param[5], s.param[6],
                                    s.param[7], s.param[8], s.param[9] + 1);

            //二次函数采样分辨率
            vtkSampleFunction sample = vtkSampleFunction.New();

            sample.SetSampleDimensions(60, 60, 30);
            sample.SetImplicitFunction(quadric);
            sample.SetModelBounds(s.param[10], s.param[11], s.param[12], s.param[13], s.param[14], s.param[15]);
            vtkContourFilter contourFilter = vtkContourFilter.New();

            contourFilter.SetInputConnection(sample.GetOutputPort());
            contourFilter.GenerateValues(1, 1, 1);
            contourFilter.Update();

            return(genUserActor(data, contourFilter.GetOutputPort(), pro));
        }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVmultipleIso(String [] argv)
    {
        //Prefix Content is: ""

        // get the interactor ui[]
        //# Graphics stuff[]
        // Create the RenderWindow, Renderer and both Actors[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        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();
        range = ((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange();
        min   = (double)(lindex(range, 0));
        max   = (double)(lindex(range, 1));
        value = (min + max) / 2.0;

        cf = new vtkContourFilter();
        cf.SetInputData((vtkDataSet)pl3d.GetOutput().GetBlock(0));
        cf.SetValue((int)0, (double)value);
        cf.UseScalarTreeOn();
        numberOfContours = 5;
        epsilon          = (double)(max - min) / (double)(numberOfContours * 10);
        min = min + epsilon;
        max = max - epsilon;
        i   = 1;
        while ((i) <= numberOfContours)
        {
            cf.SetValue((int)0, (double)min + ((i - 1) / (double)(numberOfContours - 1)) * (max - min));
            cf.Update();
            pd[i] = new vtkPolyData();
            pd[i].CopyStructure((vtkDataSet)cf.GetOutput());
            pd[i].GetPointData().DeepCopy((vtkFieldData)cf.GetOutput().GetPointData());
            mapper[i] = vtkPolyDataMapper.New();
            mapper[i].SetInputData((vtkPolyData)pd[i]);
            mapper[i].SetScalarRange((double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[0],
                                     (double)((vtkDataSet)pl3d.GetOutput().GetBlock(0)).GetPointData().GetScalars().GetRange()[1]);
            actor[i] = new vtkActor();
            actor[i].AddPosition((double)0, (double)i * 12, (double)0);
            actor[i].SetMapper((vtkMapper)mapper[i]);
            ren1.AddActor((vtkProp)actor[i]);
            i = i + 1;
        }

        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.SetBackground((double).3, (double).3, (double).3);
        renWin.SetSize((int)450, (int)150);
        cam1 = ren1.GetActiveCamera();
        ren1.GetActiveCamera().SetPosition((double)-36.3762, (double)32.3855, (double)51.3652);
        ren1.GetActiveCamera().SetFocalPoint((double)8.255, (double)33.3861, (double)29.7687);
        ren1.GetActiveCamera().SetViewAngle((double)30);
        ren1.GetActiveCamera().SetViewUp((double)0, (double)0, (double)1);
        ren1.ResetCameraClippingRange();
        iren.Initialize();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
Exemplo n.º 4
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVmultipleIso(String [] argv)
    {
        //Prefix Content is: ""

          // get the interactor ui[]
          //# Graphics stuff[]
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          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();
          range = pl3d.GetOutput().GetPointData().GetScalars().GetRange();
          min = (double)(lindex(range,0));
          max = (double)(lindex(range,1));
          value = (min+max)/2.0;
          cf = new vtkContourFilter();
          cf.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort());
          cf.SetValue((int)0,(double)value);
          cf.UseScalarTreeOn();
          numberOfContours = 5;
          epsilon = (double)(max-min)/(double)(numberOfContours*10);
          min = min+epsilon;
          max = max-epsilon;
          i = 1;
          while((i) <= numberOfContours)
        {
          cf.SetValue((int)0,(double)min+((i-1)/(double)(numberOfContours-1))*(max-min));
          cf.Update();
          pd[i] = new vtkPolyData();
          pd[i].CopyStructure((vtkDataSet)cf.GetOutput());
          pd[i].GetPointData().DeepCopy((vtkFieldData)cf.GetOutput().GetPointData());
          mapper[i] = vtkPolyDataMapper.New();
          mapper[i].SetInput((vtkPolyData)pd[i]);
          mapper[i].SetScalarRange((double)((vtkDataSet)pl3d.GetOutput()).GetPointData().GetScalars().GetRange()[0],
          (double)((vtkDataSet)pl3d.GetOutput()).GetPointData().GetScalars().GetRange()[1]);
          actor[i] = new vtkActor();
          actor[i].AddPosition((double)0,(double)i*12,(double)0);
          actor[i].SetMapper((vtkMapper)mapper[i]);
          ren1.AddActor((vtkProp)actor[i]);
          i = i + 1;
        }

          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.SetBackground((double).3,(double).3,(double).3);
          renWin.SetSize((int)450,(int)150);
          cam1 = ren1.GetActiveCamera();
          ren1.GetActiveCamera().SetPosition((double)-36.3762,(double)32.3855,(double)51.3652);
          ren1.GetActiveCamera().SetFocalPoint((double)8.255,(double)33.3861,(double)29.7687);
          ren1.GetActiveCamera().SetViewAngle((double)30);
          ren1.GetActiveCamera().SetViewUp((double)0,(double)0,(double)1);
          ren1.ResetCameraClippingRange();
          iren.Initialize();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Exemplo n.º 5
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();
    }