void RenderSlicer() { //Create all the objects for the pipeline vtkXMLImageDataReader reader = vtkXMLImageDataReader.New(); vtkImageActor iactor = vtkImageActor.New(); vtkImageClip clip = vtkImageClip.New(); vtkContourFilter contour = vtkContourFilter.New(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); vtkActor actor = vtkActor.New(); vtkInteractorStyleImage style = vtkInteractorStyleImage.New(); vtkRenderer renderer = renderWindowControl2.RenderWindow.GetRenderers().GetFirstRenderer(); //Read the Image reader.SetFileName(m_FileName); //Go through the visulization pipeline iactor.SetInput(reader.GetOutput()); renderer.AddActor(iactor); reader.Update(); int[] extent = reader.GetOutput().GetWholeExtent(); iactor.SetDisplayExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); clip.SetInputConnection(reader.GetOutputPort()); clip.SetOutputWholeExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); contour.SetInputConnection(clip.GetOutputPort()); contour.SetValue(0, 100); mapper.SetInputConnection(contour.GetOutputPort()); mapper.SetScalarVisibility(1); //Go through the graphics pipeline actor.SetMapper(mapper); actor.GetProperty().SetColor(0, 1, 0); renderer.AddActor(actor); //Give a new style to the interactor //vtkRenderWindowInteractor iren = renderWindowControl2.RenderWindow.GetInteractor(); //iren.SetInteractorStyle(style); //Update global variables this.trackBar1.Maximum = extent[5]; this.trackBar1.Minimum = extent[4]; //this.Interactor = iren; this.m_SliceRenderWindow = renderWindowControl2.RenderWindow; this.m_SliceRenderer = renderer; this.m_SliceClip = clip; this.m_SliceImageActor = iactor; renderer.ResetCamera(); this.m_SliceRenderer.ResetCameraClippingRange(); this.m_SliceRenderWindow.Render(); }
void RenderSlicer() { //Create all the objects for the pipeline vtkXMLImageDataReader reader = vtkXMLImageDataReader.New(); vtkImageActor iactor = vtkImageActor.New(); vtkImageClip clip = vtkImageClip.New(); vtkContourFilter contour = vtkContourFilter.New(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); vtkActor actor = vtkActor.New(); vtkInteractorStyleImage style = vtkInteractorStyleImage.New(); vtkRenderer renderer = renderWindowControl2.RenderWindow.GetRenderers().GetFirstRenderer(); //Read the Image reader.SetFileName(m_FileName); //Go through the visulization pipeline iactor.SetInput(reader.GetOutput()); renderer.AddActor(iactor); reader.Update(); int[] extent = reader.GetOutput().GetWholeExtent(); iactor.SetDisplayExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); clip.SetInputConnection(reader.GetOutputPort()); clip.SetOutputWholeExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); contour.SetInputConnection(clip.GetOutputPort()); contour.SetValue(0, 100); mapper.SetInputConnection(contour.GetOutputPort()); mapper.SetScalarVisibility(1); //Go through the graphics pipeline actor.SetMapper(mapper); actor.GetProperty().SetColor(0, 1, 0); renderer.AddActor(actor); //Give a new style to the interactor //vtkRenderWindowInteractor iren = renderWindowControl2.RenderWindow.GetInteractor(); //iren.SetInteractorStyle(style); //Update global variables this.trackBar1.Maximum = extent[5]; this.trackBar1.Minimum = extent[4]; //this.Interactor = iren; this.m_SliceRenderWindow = renderWindowControl2.RenderWindow; this.m_SliceRenderer = renderer; this.m_SliceClip = clip; this.m_SliceImageActor = iactor; renderer.ResetCamera(); }
///<summary> A Set Method for Static Variables </summary> public static void Setclip3(vtkImageClip toSet) { clip3 = toSet; }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestBranchExtentTranslator(String [] argv) { //Prefix Content is: "" gauss = new vtkImageGaussianSource(); gauss.SetWholeExtent((int)0, (int)30, (int)0, (int)30, (int)0, (int)2); gauss.SetCenter((double)18, (double)12, (double)0); gauss.SetMaximum((double)1.0); gauss.SetStandardDeviation((double)6.0); gauss.Update(); translator = new vtkBranchExtentTranslator(); translator.SetOriginalSource((vtkImageData)gauss.GetOutput()); gauss.GetOutput().SetExtentTranslator((vtkExtentTranslator)translator); clip1 = new vtkImageClip(); clip1.SetOutputWholeExtent((int)7, (int)28, (int)0, (int)15, (int)1, (int)1); clip1.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf1 = new vtkDataSetSurfaceFilter(); surf1.SetInputConnection((vtkAlgorithmOutput)clip1.GetOutputPort()); tf1 = new vtkTriangleFilter(); tf1.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort()); mapper1 = vtkPolyDataMapper.New(); mapper1.SetInputConnection((vtkAlgorithmOutput)tf1.GetOutputPort()); mapper1.SetScalarRange((double)0, (double)1); mapper1.SetNumberOfPieces((int)4); mapper1.SetPiece((int)1); actor1 = new vtkActor(); actor1.SetMapper((vtkMapper)mapper1); actor1.SetPosition((double)0, (double)0, (double)0); // For coverage, a case where all four sides get clipped by the whole extent.[] clip2 = new vtkImageClip(); clip2.SetOutputWholeExtent((int)16, (int)18, (int)3, (int)10, (int)0, (int)0); clip2.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf2 = new vtkDataSetSurfaceFilter(); surf2.SetInputConnection((vtkAlgorithmOutput)clip2.GetOutputPort()); tf2 = new vtkTriangleFilter(); tf2.SetInputConnection((vtkAlgorithmOutput)surf2.GetOutputPort()); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)tf2.GetOutputPort()); mapper2.SetScalarRange((double)0, (double)1); mapper2.SetNumberOfPieces((int)4); mapper2.SetPiece((int)1); actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetPosition((double)15, (double)0, (double)0); // nothing in intersection (empty case)[] clip3 = new vtkImageClip(); clip3.SetOutputWholeExtent((int)1, (int)10, (int)0, (int)15, (int)0, (int)2); clip3.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf3 = new vtkDataSetSurfaceFilter(); surf3.SetInputConnection((vtkAlgorithmOutput)clip3.GetOutputPort()); tf3 = new vtkTriangleFilter(); tf3.SetInputConnection((vtkAlgorithmOutput)surf3.GetOutputPort()); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)tf3.GetOutputPort()); mapper3.SetScalarRange((double)0, (double)1); mapper3.SetNumberOfPieces((int)4); mapper3.SetPiece((int)1); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)30, (double)0, (double)0); ren = vtkRenderer.New(); ren.AddActor((vtkProp)actor1); ren.AddActor((vtkProp)actor2); ren.AddActor((vtkProp)actor3); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren); //set cam [ren GetActiveCamera][] //ren ResetCamera[] iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); iren.Initialize(); renWin.Render(); // break loop to avoid a memory leak.[] translator.SetOriginalSource(null); //deleteAllVTKObjects(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVTestBranchExtentTranslator(String [] argv) { //Prefix Content is: "" gauss = new vtkImageGaussianSource(); gauss.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)2); gauss.SetCenter((double)18,(double)12,(double)0); gauss.SetMaximum((double)1.0); gauss.SetStandardDeviation((double)6.0); gauss.Update(); translator = new vtkBranchExtentTranslator(); translator.SetOriginalSource((vtkImageData)gauss.GetOutput()); gauss.GetOutput().SetExtentTranslator((vtkExtentTranslator)translator); clip1 = new vtkImageClip(); clip1.SetOutputWholeExtent((int)7,(int)28,(int)0,(int)15,(int)1,(int)1); clip1.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf1 = new vtkDataSetSurfaceFilter(); surf1.SetInputConnection((vtkAlgorithmOutput)clip1.GetOutputPort()); tf1 = new vtkTriangleFilter(); tf1.SetInputConnection((vtkAlgorithmOutput)surf1.GetOutputPort()); mapper1 = vtkPolyDataMapper.New(); mapper1.SetInputConnection((vtkAlgorithmOutput)tf1.GetOutputPort()); mapper1.SetScalarRange((double)0,(double)1); mapper1.SetNumberOfPieces((int)4); mapper1.SetPiece((int)1); actor1 = new vtkActor(); actor1.SetMapper((vtkMapper)mapper1); actor1.SetPosition((double)0,(double)0,(double)0); // For coverage, a case where all four sides get clipped by the whole extent.[] clip2 = new vtkImageClip(); clip2.SetOutputWholeExtent((int)16,(int)18,(int)3,(int)10,(int)0,(int)0); clip2.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf2 = new vtkDataSetSurfaceFilter(); surf2.SetInputConnection((vtkAlgorithmOutput)clip2.GetOutputPort()); tf2 = new vtkTriangleFilter(); tf2.SetInputConnection((vtkAlgorithmOutput)surf2.GetOutputPort()); mapper2 = vtkPolyDataMapper.New(); mapper2.SetInputConnection((vtkAlgorithmOutput)tf2.GetOutputPort()); mapper2.SetScalarRange((double)0,(double)1); mapper2.SetNumberOfPieces((int)4); mapper2.SetPiece((int)1); actor2 = new vtkActor(); actor2.SetMapper((vtkMapper)mapper2); actor2.SetPosition((double)15,(double)0,(double)0); // nothing in intersection (empty case)[] clip3 = new vtkImageClip(); clip3.SetOutputWholeExtent((int)1,(int)10,(int)0,(int)15,(int)0,(int)2); clip3.SetInputConnection((vtkAlgorithmOutput)gauss.GetOutputPort()); surf3 = new vtkDataSetSurfaceFilter(); surf3.SetInputConnection((vtkAlgorithmOutput)clip3.GetOutputPort()); tf3 = new vtkTriangleFilter(); tf3.SetInputConnection((vtkAlgorithmOutput)surf3.GetOutputPort()); mapper3 = vtkPolyDataMapper.New(); mapper3.SetInputConnection((vtkAlgorithmOutput)tf3.GetOutputPort()); mapper3.SetScalarRange((double)0,(double)1); mapper3.SetNumberOfPieces((int)4); mapper3.SetPiece((int)1); actor3 = new vtkActor(); actor3.SetMapper((vtkMapper)mapper3); actor3.SetPosition((double)30,(double)0,(double)0); ren = vtkRenderer.New(); ren.AddActor((vtkProp)actor1); ren.AddActor((vtkProp)actor2); ren.AddActor((vtkProp)actor3); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren); //set cam [ren GetActiveCamera][] //ren ResetCamera[] iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); iren.Initialize(); renWin.Render(); // break loop to avoid a memory leak.[] translator.SetOriginalSource(null); //deleteAllVTKObjects(); }
/// <summary> /// Display the render window with the slice in it /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void renderWindowControl1_Load(object sender, EventArgs e) { //Get the name of the Unsigned Char volume that you want to load fileName = "../../../head.vti"; //Create all the objects for the pipeline vtkXMLImageDataReader reader = vtkXMLImageDataReader.New(); vtkImageActor iactor = vtkImageActor.New(); vtkImageClip clip = vtkImageClip.New(); vtkContourFilter contour = vtkContourFilter.New(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); vtkActor actor = vtkActor.New(); vtkInteractorStyleImage style = vtkInteractorStyleImage.New(); vtkRenderer renderer = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer(); //Read the Image reader.SetFileName(fileName); //Go through the visulization pipeline iactor.SetInputData(reader.GetOutput()); renderer.AddActor(iactor); reader.Update(); int[] extent = reader.GetOutput().GetExtent(); iactor.SetDisplayExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); clip.SetInputConnection(reader.GetOutputPort()); clip.SetOutputWholeExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); contour.SetInputConnection(clip.GetOutputPort()); contour.SetValue(0, 100); mapper.SetInputConnection(contour.GetOutputPort()); mapper.SetScalarVisibility(1); //Go through the graphics pipeline actor.SetMapper(mapper); actor.GetProperty().SetColor(0, 1, 0); renderer.AddActor(actor); //Give a new style to the interactor vtkRenderWindowInteractor iren = renderWindowControl1.RenderWindow.GetInteractor(); iren.SetInteractorStyle(style); //Add new events to the interactor style style.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(iren_LeftButtonPressEvt); style.LeftButtonReleaseEvt += new vtkObject.vtkObjectEventHandler(iren_LeftButtonReleaseEvt); style.MouseMoveEvt += new vtkObject.vtkObjectEventHandler(iren_MouseMoveEvt); //Update global variables this.trackBar1.Maximum = extent[5]; this.trackBar1.Minimum = extent[4]; this.Interactor = iren; this.RenderWindow = renderWindowControl1.RenderWindow; this.Renderer = renderer; this.Clip = clip; this.ImageActor = iactor; }
/// <summary> /// Display the render window with the slice in it /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void renderWindowControl1_Load(object sender, EventArgs e) { //Get the name of the Unsigned Char volume that you want to load fileName = "../../../head.vti"; //Create all the objects for the pipeline vtkXMLImageDataReader reader = vtkXMLImageDataReader.New(); vtkImageActor iactor = vtkImageActor.New(); vtkImageClip clip = vtkImageClip.New(); vtkContourFilter contour = vtkContourFilter.New(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); vtkActor actor = vtkActor.New(); vtkInteractorStyleImage style = vtkInteractorStyleImage.New(); vtkRenderer renderer = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer(); //Read the Image reader.SetFileName(fileName); //Go through the visulization pipeline iactor.SetInput(reader.GetOutput()); renderer.AddActor(iactor); reader.Update(); int[] extent = reader.GetOutput().GetWholeExtent(); iactor.SetDisplayExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); clip.SetInputConnection(reader.GetOutputPort()); clip.SetOutputWholeExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); contour.SetInputConnection(clip.GetOutputPort()); contour.SetValue(0, 100); mapper.SetInputConnection(contour.GetOutputPort()); mapper.SetScalarVisibility(1); //Go through the graphics pipeline actor.SetMapper(mapper); actor.GetProperty().SetColor(0, 1, 0); renderer.AddActor(actor); //Give a new style to the interactor vtkRenderWindowInteractor iren = renderWindowControl1.RenderWindow.GetInteractor(); iren.SetInteractorStyle(style); //Add new events to the interactor style style.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(iren_LeftButtonPressEvt); style.LeftButtonReleaseEvt += new vtkObject.vtkObjectEventHandler(iren_LeftButtonReleaseEvt); style.MouseMoveEvt += new vtkObject.vtkObjectEventHandler(iren_MouseMoveEvt); //Update global variables this.trackBar1.Maximum = extent[5]; this.trackBar1.Minimum = extent[4]; this.Interactor = iren; this.RenderWindow = renderWindowControl1.RenderWindow; this.Renderer = renderer; this.Clip = clip; this.ImageActor = iactor; }