Esempio n. 1
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();
    }
    /// <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();
    }