コード例 #1
0
ファイル: AVHyper.cs プロジェクト: Powerino/activizdotnet
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetwSP(vtkDataSetWriter toSet)
 {
     wSP = toSet;
 }
コード例 #2
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestPolygonWriters(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[]
          //[]
          input = new vtkPolyDataReader();
          input.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/brainImageSmooth.vtk");
          //[]
          // generate vectors[]
          clean = new vtkCleanPolyData();
          clean.SetInputConnection((vtkAlgorithmOutput)input.GetOutputPort());
          smooth = new vtkWindowedSincPolyDataFilter();
          smooth.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort());
          smooth.GenerateErrorVectorsOn();
          smooth.GenerateErrorScalarsOn();
          smooth.Update();
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          mapper.SetScalarRange((double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[0],
          (double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[1]);
          brain = new vtkActor();
          brain.SetMapper((vtkMapper)mapper);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)brain);
          renWin.SetSize((int)320,(int)240);
          ren1.GetActiveCamera().SetPosition((double)149.653,(double)-65.3464,(double)96.0401);
          ren1.GetActiveCamera().SetFocalPoint((double)146.003,(double)22.3839,(double)0.260541);
          ren1.GetActiveCamera().SetViewAngle((double)30);
          ren1.GetActiveCamera().SetViewUp((double)-0.255578,(double)-0.717754,(double)-0.647695);
          ren1.GetActiveCamera().SetClippingRange((double)79.2526,(double)194.052);
          iren.Initialize();
          renWin.Render();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]
          //[]
          // If the current directory is writable, then test the witers[]
          //[]
          try
          {
         channel = new StreamWriter("test.tmp");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          File.Delete("test.tmp");
          //[]
          //[]
          // test the writers[]
          dsw = new vtkDataSetWriter();
          dsw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          dsw.SetFileName((string)"brain.dsw");
          dsw.Write();
          File.Delete("brain.dsw");
          pdw = new vtkPolyDataWriter();
          pdw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          pdw.SetFileName((string)"brain.pdw");
          pdw.Write();
          File.Delete("brain.pdw");
          iv = new vtkIVWriter();
          iv.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          iv.SetFileName((string)"brain.iv");
          iv.Write();
          File.Delete("brain.iv");

          //[]
          // the next writers only handle triangles[]
          triangles = new vtkTriangleFilter();
          triangles.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
          iv2 = new vtkIVWriter();
          iv2.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          iv2.SetFileName((string)"brain2.iv");
          iv2.Write();
          File.Delete("brain2.iv");

          edges = new vtkExtractEdges();
          edges.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          iv3 = new vtkIVWriter();
          iv3.SetInputConnection((vtkAlgorithmOutput)edges.GetOutputPort());
          iv3.SetFileName((string)"brain3.iv");
          iv3.Write();
          File.Delete("brain3.iv");

          byu = new vtkBYUWriter();
          byu.SetGeometryFileName((string)"brain.g");
          byu.SetScalarFileName((string)"brain.s");
          byu.SetDisplacementFileName((string)"brain.d");
          byu.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          byu.Write();
          File.Delete("brain.g");
          File.Delete("brain.s");
          File.Delete("brain.d");
          mcubes = new vtkMCubesWriter();
          mcubes.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          mcubes.SetFileName((string)"brain.tri");
          mcubes.SetLimitsFileName((string)"brain.lim");
          mcubes.Write();
          File.Delete("brain.lim");
          File.Delete("brain.tri");
          stl = new vtkSTLWriter();
          stl.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          stl.SetFileName((string)"brain.stl");
          stl.Write();
          File.Delete("brain.stl");
          stlBinary = new vtkSTLWriter();
          stlBinary.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
          stlBinary.SetFileName((string)"brainBinary.stl");
          stlBinary.SetFileType((int)2);
          stlBinary.Write();
          File.Delete("brainBinary.stl");
        }

        //deleteAllVTKObjects();
    }
コード例 #3
0
ファイル: AVHyper.cs プロジェクト: Powerino/activizdotnet
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyper(String [] argv)
    {
        //Prefix Content is: ""

          // Create the RenderWindow, Renderer and interactive renderer[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
          //[]
          // generate tensors[]
          ptLoad = new vtkPointLoad();
          ptLoad.SetLoadValue((double)100.0);
          ptLoad.SetSampleDimensions((int)20,(int)20,(int)20);
          ptLoad.ComputeEffectiveStressOn();
          ptLoad.SetModelBounds((double)-10,(double)10,(double)-10,(double)10,(double)-10,(double)10);
          //[]
          // If the current directory is writable, then test the witers[]
          //[]
          try
          {
         channel = new StreamWriter("test.tmp");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          File.Delete("test.tmp");
          wSP = new vtkDataSetWriter();
          wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
          wSP.SetFileName((string)"wSP.vtk");
          wSP.SetTensorsName((string)"pointload");
          wSP.SetScalarsName((string)"effective_stress");
          wSP.Write();
          rSP = new vtkDataSetReader();
          rSP.SetFileName((string)"wSP.vtk");
          rSP.SetTensorsName((string)"pointload");
          rSP.SetScalarsName((string)"effective_stress");
          rSP.Update();
          input = rSP.GetOutput();
          File.Delete("wSP.vtk");
        }
          else
        {
          input = ptLoad.GetOutput();
        }

          // Generate hyperstreamlines[]
          s1 = new vtkHyperStreamline();
          s1.SetInputData((vtkDataObject)input);
          s1.SetStartPosition((double)9,(double)9,(double)-9);
          s1.IntegrateMinorEigenvector();
          s1.SetMaximumPropagationDistance((double)18.0);
          s1.SetIntegrationStepLength((double)0.1);
          s1.SetStepLength((double)0.01);
          s1.SetRadius((double)0.25);
          s1.SetNumberOfSides((int)18);
          s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s1.Update();
          // Map hyperstreamlines[]
          lut = new vtkLogLookupTable();
          lut.SetHueRange((double).6667,(double)0.0);
          s1Mapper = vtkPolyDataMapper.New();
          s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
          s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
          ptLoad.Update();
          //force update for scalar range[]
          s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
          s1Actor = new vtkActor();
          s1Actor.SetMapper((vtkMapper)s1Mapper);
          s2 = new vtkHyperStreamline();
          s2.SetInputData((vtkDataObject)input);
          s2.SetStartPosition((double)-9,(double)-9,(double)-9);
          s2.IntegrateMinorEigenvector();
          s2.SetMaximumPropagationDistance((double)18.0);
          s2.SetIntegrationStepLength((double)0.1);
          s2.SetStepLength((double)0.01);
          s2.SetRadius((double)0.25);
          s2.SetNumberOfSides((int)18);
          s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s2.Update();
          s2Mapper = vtkPolyDataMapper.New();
          s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
          s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s2Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]);
          s2Actor = new vtkActor();
          s2Actor.SetMapper((vtkMapper)s2Mapper);
          s3 = new vtkHyperStreamline();
          s3.SetInputData((vtkDataObject)input);
          s3.SetStartPosition((double)9,(double)-9,(double)-9);
          s3.IntegrateMinorEigenvector();
          s3.SetMaximumPropagationDistance((double)18.0);
          s3.SetIntegrationStepLength((double)0.1);
          s3.SetStepLength((double)0.01);
          s3.SetRadius((double)0.25);
          s3.SetNumberOfSides((int)18);
          s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s3.Update();
          s3Mapper = vtkPolyDataMapper.New();
          s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
          s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s3Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],
          (double)((vtkDataSet)input).GetScalarRange()[1]);
          s3Actor = new vtkActor();
          s3Actor.SetMapper((vtkMapper)s3Mapper);
          s4 = new vtkHyperStreamline();
          s4.SetInputData((vtkDataObject)input);
          s4.SetStartPosition((double)-9,(double)9,(double)-9);
          s4.IntegrateMinorEigenvector();
          s4.SetMaximumPropagationDistance((double)18.0);
          s4.SetIntegrationStepLength((double)0.1);
          s4.SetStepLength((double)0.01);
          s4.SetRadius((double)0.25);
          s4.SetNumberOfSides((int)18);
          s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
          s4.Update();
          s4Mapper = vtkPolyDataMapper.New();
          s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
          s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
          s4Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],(double)((vtkDataSet)input).GetScalarRange()[1]);
          s4Actor = new vtkActor();
          s4Actor.SetMapper((vtkMapper)s4Mapper);
          // plane for context[]
          //[]
          g = new vtkImageDataGeometryFilter();
          g.SetInputData((vtkDataObject)input);
          g.SetExtent((int)0,(int)100,(int)0,(int)100,(int)0,(int)0);
          g.Update();
          //for scalar range[]
          gm = vtkPolyDataMapper.New();
          gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
          gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0],(double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
          ga = new vtkActor();
          ga.SetMapper((vtkMapper)gm);
          // Create outline around data[]
          //[]
          outline = new vtkOutlineFilter();
          outline.SetInputData((vtkDataObject)input);
          outlineMapper = vtkPolyDataMapper.New();
          outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outlineMapper);
          outlineActor.GetProperty().SetColor((double)0,(double)0,(double)0);
          // Create cone indicating application of load[]
          //[]
          coneSrc = new vtkConeSource();
          coneSrc.SetRadius((double).5);
          coneSrc.SetHeight((double)2);
          coneMap = vtkPolyDataMapper.New();
          coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
          coneActor = new vtkActor();
          coneActor.SetMapper((vtkMapper)coneMap);
          coneActor.SetPosition((double)0,(double)0,(double)11);
          coneActor.RotateY((double)90);
          coneActor.GetProperty().SetColor((double)1,(double)0,(double)0);
          camera = new vtkCamera();
          camera.SetFocalPoint((double)0.113766,(double)-1.13665,(double)-1.01919);
          camera.SetPosition((double)-29.4886,(double)-63.1488,(double)26.5807);
          camera.SetViewAngle((double)24.4617);
          camera.SetViewUp((double)0.17138,(double)0.331163,(double)0.927879);
          camera.SetClippingRange((double)1,(double)100);
          ren1.AddActor((vtkProp)s1Actor);
          ren1.AddActor((vtkProp)s2Actor);
          ren1.AddActor((vtkProp)s3Actor);
          ren1.AddActor((vtkProp)s4Actor);
          ren1.AddActor((vtkProp)outlineActor);
          ren1.AddActor((vtkProp)coneActor);
          ren1.AddActor((vtkProp)ga);
          ren1.SetBackground((double)1.0,(double)1.0,(double)1.0);
          ren1.SetActiveCamera((vtkCamera)camera);
          renWin.SetSize((int)300,(int)300);
          renWin.Render();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
コード例 #4
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setdsw(vtkDataSetWriter toSet)
 {
     dsw = toSet;
 }
コード例 #5
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetwSP(vtkDataSetWriter toSet)
 {
     wSP = toSet;
 }
コード例 #6
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVHyper(String [] argv)
    {
        //Prefix Content is: ""

        // Create the RenderWindow, Renderer and interactive renderer[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        VTK_INTEGRATE_BOTH_DIRECTIONS = 2;
        //[]
        // generate tensors[]
        ptLoad = new vtkPointLoad();
        ptLoad.SetLoadValue((double)100.0);
        ptLoad.SetSampleDimensions((int)20, (int)20, (int)20);
        ptLoad.ComputeEffectiveStressOn();
        ptLoad.SetModelBounds((double)-10, (double)10, (double)-10, (double)10, (double)-10, (double)10);
        //[]
        // If the current directory is writable, then test the witers[]
        //[]
        try
        {
            channel       = new StreamWriter("test.tmp");
            tryCatchError = "NOERROR";
        }
        catch (Exception)
        { tryCatchError = "ERROR"; }

        if (tryCatchError.Equals("NOERROR"))
        {
            channel.Close();
            File.Delete("test.tmp");
            wSP = new vtkDataSetWriter();
            wSP.SetInputConnection((vtkAlgorithmOutput)ptLoad.GetOutputPort());
            wSP.SetFileName((string)"wSP.vtk");
            wSP.SetTensorsName((string)"pointload");
            wSP.SetScalarsName((string)"effective_stress");
            wSP.Write();
            rSP = new vtkDataSetReader();
            rSP.SetFileName((string)"wSP.vtk");
            rSP.SetTensorsName((string)"pointload");
            rSP.SetScalarsName((string)"effective_stress");
            rSP.Update();
            input = rSP.GetOutput();
            File.Delete("wSP.vtk");
        }
        else
        {
            input = ptLoad.GetOutput();
        }

        // Generate hyperstreamlines[]
        s1 = new vtkHyperStreamline();
        s1.SetInputData((vtkDataObject)input);
        s1.SetStartPosition((double)9, (double)9, (double)-9);
        s1.IntegrateMinorEigenvector();
        s1.SetMaximumPropagationDistance((double)18.0);
        s1.SetIntegrationStepLength((double)0.1);
        s1.SetStepLength((double)0.01);
        s1.SetRadius((double)0.25);
        s1.SetNumberOfSides((int)18);
        s1.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s1.Update();
        // Map hyperstreamlines[]
        lut = new vtkLogLookupTable();
        lut.SetHueRange((double).6667, (double)0.0);
        s1Mapper = vtkPolyDataMapper.New();
        s1Mapper.SetInputConnection((vtkAlgorithmOutput)s1.GetOutputPort());
        s1Mapper.SetLookupTable((vtkScalarsToColors)lut);
        ptLoad.Update();
        //force update for scalar range[]
        s1Mapper.SetScalarRange((double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)ptLoad.GetOutput()).GetScalarRange()[1]);
        s1Actor = new vtkActor();
        s1Actor.SetMapper((vtkMapper)s1Mapper);
        s2 = new vtkHyperStreamline();
        s2.SetInputData((vtkDataObject)input);
        s2.SetStartPosition((double)-9, (double)-9, (double)-9);
        s2.IntegrateMinorEigenvector();
        s2.SetMaximumPropagationDistance((double)18.0);
        s2.SetIntegrationStepLength((double)0.1);
        s2.SetStepLength((double)0.01);
        s2.SetRadius((double)0.25);
        s2.SetNumberOfSides((int)18);
        s2.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s2.Update();
        s2Mapper = vtkPolyDataMapper.New();
        s2Mapper.SetInputConnection((vtkAlgorithmOutput)s2.GetOutputPort());
        s2Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s2Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]);
        s2Actor = new vtkActor();
        s2Actor.SetMapper((vtkMapper)s2Mapper);
        s3 = new vtkHyperStreamline();
        s3.SetInputData((vtkDataObject)input);
        s3.SetStartPosition((double)9, (double)-9, (double)-9);
        s3.IntegrateMinorEigenvector();
        s3.SetMaximumPropagationDistance((double)18.0);
        s3.SetIntegrationStepLength((double)0.1);
        s3.SetStepLength((double)0.01);
        s3.SetRadius((double)0.25);
        s3.SetNumberOfSides((int)18);
        s3.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s3.Update();
        s3Mapper = vtkPolyDataMapper.New();
        s3Mapper.SetInputConnection((vtkAlgorithmOutput)s3.GetOutputPort());
        s3Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s3Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0],
                                (double)((vtkDataSet)input).GetScalarRange()[1]);
        s3Actor = new vtkActor();
        s3Actor.SetMapper((vtkMapper)s3Mapper);
        s4 = new vtkHyperStreamline();
        s4.SetInputData((vtkDataObject)input);
        s4.SetStartPosition((double)-9, (double)9, (double)-9);
        s4.IntegrateMinorEigenvector();
        s4.SetMaximumPropagationDistance((double)18.0);
        s4.SetIntegrationStepLength((double)0.1);
        s4.SetStepLength((double)0.01);
        s4.SetRadius((double)0.25);
        s4.SetNumberOfSides((int)18);
        s4.SetIntegrationDirection((int)VTK_INTEGRATE_BOTH_DIRECTIONS);
        s4.Update();
        s4Mapper = vtkPolyDataMapper.New();
        s4Mapper.SetInputConnection((vtkAlgorithmOutput)s4.GetOutputPort());
        s4Mapper.SetLookupTable((vtkScalarsToColors)lut);
        s4Mapper.SetScalarRange((double)((vtkDataSet)input).GetScalarRange()[0], (double)((vtkDataSet)input).GetScalarRange()[1]);
        s4Actor = new vtkActor();
        s4Actor.SetMapper((vtkMapper)s4Mapper);
        // plane for context[]
        //[]
        g = new vtkImageDataGeometryFilter();
        g.SetInputData((vtkDataObject)input);
        g.SetExtent((int)0, (int)100, (int)0, (int)100, (int)0, (int)0);
        g.Update();
        //for scalar range[]
        gm = vtkPolyDataMapper.New();
        gm.SetInputConnection((vtkAlgorithmOutput)g.GetOutputPort());
        gm.SetScalarRange((double)((vtkDataSet)g.GetOutput()).GetScalarRange()[0], (double)((vtkDataSet)g.GetOutput()).GetScalarRange()[1]);
        ga = new vtkActor();
        ga.SetMapper((vtkMapper)gm);
        // Create outline around data[]
        //[]
        outline = new vtkOutlineFilter();
        outline.SetInputData((vtkDataObject)input);
        outlineMapper = vtkPolyDataMapper.New();
        outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outlineMapper);
        outlineActor.GetProperty().SetColor((double)0, (double)0, (double)0);
        // Create cone indicating application of load[]
        //[]
        coneSrc = new vtkConeSource();
        coneSrc.SetRadius((double).5);
        coneSrc.SetHeight((double)2);
        coneMap = vtkPolyDataMapper.New();
        coneMap.SetInputConnection((vtkAlgorithmOutput)coneSrc.GetOutputPort());
        coneActor = new vtkActor();
        coneActor.SetMapper((vtkMapper)coneMap);
        coneActor.SetPosition((double)0, (double)0, (double)11);
        coneActor.RotateY((double)90);
        coneActor.GetProperty().SetColor((double)1, (double)0, (double)0);
        camera = new vtkCamera();
        camera.SetFocalPoint((double)0.113766, (double)-1.13665, (double)-1.01919);
        camera.SetPosition((double)-29.4886, (double)-63.1488, (double)26.5807);
        camera.SetViewAngle((double)24.4617);
        camera.SetViewUp((double)0.17138, (double)0.331163, (double)0.927879);
        camera.SetClippingRange((double)1, (double)100);
        ren1.AddActor((vtkProp)s1Actor);
        ren1.AddActor((vtkProp)s2Actor);
        ren1.AddActor((vtkProp)s3Actor);
        ren1.AddActor((vtkProp)s4Actor);
        ren1.AddActor((vtkProp)outlineActor);
        ren1.AddActor((vtkProp)coneActor);
        ren1.AddActor((vtkProp)ga);
        ren1.SetBackground((double)1.0, (double)1.0, (double)1.0);
        ren1.SetActiveCamera((vtkCamera)camera);
        renWin.SetSize((int)300, (int)300);
        renWin.Render();
        // prevent the tk window from showing up then start the event loop[]

//deleteAllVTKObjects();
    }
コード例 #7
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setdsw(vtkDataSetWriter toSet)
 {
     dsw = toSet;
 }
コード例 #8
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestPolygonWriters(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[]
        //[]
        input = new vtkPolyDataReader();
        input.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/brainImageSmooth.vtk");
        //[]
        // generate vectors[]
        clean = new vtkCleanPolyData();
        clean.SetInputConnection((vtkAlgorithmOutput)input.GetOutputPort());
        smooth = new vtkWindowedSincPolyDataFilter();
        smooth.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort());
        smooth.GenerateErrorVectorsOn();
        smooth.GenerateErrorScalarsOn();
        smooth.Update();
        mapper = vtkPolyDataMapper.New();
        mapper.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
        mapper.SetScalarRange((double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[0],
                              (double)((vtkDataSet)smooth.GetOutput()).GetScalarRange()[1]);
        brain = new vtkActor();
        brain.SetMapper((vtkMapper)mapper);
        // Add the actors to the renderer, set the background and size[]
        //[]
        ren1.AddActor((vtkProp)brain);
        renWin.SetSize((int)320, (int)240);
        ren1.GetActiveCamera().SetPosition((double)149.653, (double)-65.3464, (double)96.0401);
        ren1.GetActiveCamera().SetFocalPoint((double)146.003, (double)22.3839, (double)0.260541);
        ren1.GetActiveCamera().SetViewAngle((double)30);
        ren1.GetActiveCamera().SetViewUp((double)-0.255578, (double)-0.717754, (double)-0.647695);
        ren1.GetActiveCamera().SetClippingRange((double)79.2526, (double)194.052);
        iren.Initialize();
        renWin.Render();
        // render the image[]
        //[]
        // prevent the tk window from showing up then start the event loop[]
        //[]
        // If the current directory is writable, then test the witers[]
        //[]
        try
        {
            channel       = new StreamWriter("test.tmp");
            tryCatchError = "NOERROR";
        }
        catch (Exception)
        { tryCatchError = "ERROR"; }

        if (tryCatchError.Equals("NOERROR"))
        {
            channel.Close();
            File.Delete("test.tmp");
            //[]
            //[]
            // test the writers[]
            dsw = new vtkDataSetWriter();
            dsw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
            dsw.SetFileName((string)"brain.dsw");
            dsw.Write();
            File.Delete("brain.dsw");
            pdw = new vtkPolyDataWriter();
            pdw.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
            pdw.SetFileName((string)"brain.pdw");
            pdw.Write();
            File.Delete("brain.pdw");
            iv = new vtkIVWriter();
            iv.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
            iv.SetFileName((string)"brain.iv");
            iv.Write();
            File.Delete("brain.iv");


            //[]
            // the next writers only handle triangles[]
            triangles = new vtkTriangleFilter();
            triangles.SetInputConnection((vtkAlgorithmOutput)smooth.GetOutputPort());
            iv2 = new vtkIVWriter();
            iv2.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
            iv2.SetFileName((string)"brain2.iv");
            iv2.Write();
            File.Delete("brain2.iv");


            edges = new vtkExtractEdges();
            edges.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
            iv3 = new vtkIVWriter();
            iv3.SetInputConnection((vtkAlgorithmOutput)edges.GetOutputPort());
            iv3.SetFileName((string)"brain3.iv");
            iv3.Write();
            File.Delete("brain3.iv");


            byu = new vtkBYUWriter();
            byu.SetGeometryFileName((string)"brain.g");
            byu.SetScalarFileName((string)"brain.s");
            byu.SetDisplacementFileName((string)"brain.d");
            byu.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
            byu.Write();
            File.Delete("brain.g");
            File.Delete("brain.s");
            File.Delete("brain.d");
            mcubes = new vtkMCubesWriter();
            mcubes.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
            mcubes.SetFileName((string)"brain.tri");
            mcubes.SetLimitsFileName((string)"brain.lim");
            mcubes.Write();
            File.Delete("brain.lim");
            File.Delete("brain.tri");
            stl = new vtkSTLWriter();
            stl.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
            stl.SetFileName((string)"brain.stl");
            stl.Write();
            File.Delete("brain.stl");
            stlBinary = new vtkSTLWriter();
            stlBinary.SetInputConnection((vtkAlgorithmOutput)triangles.GetOutputPort());
            stlBinary.SetFileName((string)"brainBinary.stl");
            stlBinary.SetFileType((int)2);
            stlBinary.Write();
            File.Delete("brainBinary.stl");
        }



//deleteAllVTKObjects();
    }