public void rendersiteplanes(vtk.vtkImageData VoxelData) { //vtk.vtkWin32RenderWindowInteractor renwX.AddRenderer(renX); renwY.AddRenderer(renY); renwZ.AddRenderer(renZ); irenX.SetRenderWindow(renwX); irenY.SetRenderWindow(renwY); irenZ.SetRenderWindow(renwZ); vtk.vtkOutlineFilter outline = new vtk.vtkOutlineFilter(); outline.SetInput(VoxelData); vtk.vtkPolyDataMapper outlineMapper = new vtk.vtkPolyDataMapper(); outlineMapper.SetInputConnection(outline.GetOutputPort()); vtk.vtkActor outlineActor = new vtk.vtkActor(); outlineActor.SetMapper(outlineMapper); vtk.vtkCellPicker picker = new vtk.vtkCellPicker(); picker.SetTolerance(0.005); planeWidgetX.SetInteractor(irenX); planeWidgetX.DisplayTextOff(); planeWidgetX.SetInput(VoxelData); planeWidgetX.SetPlaneOrientationToXAxes(); planeWidgetX.SetSliceIndex(slizex); planeWidgetX.SetPicker(picker); planeWidgetX.On(); planeWidgetX.InteractionOff(); if (firstTime) { double[] wl = new double[2]; vtk.vtkLookupTable lktb = new vtk.vtkLookupTable(); lktb = planeWidgetX.GetLookupTable(); wl = lktb.GetTableRange(); rangeXMin = wl[0]; rangeXMax = wl[1]; planeWidgetX.GetWindowLevel(wl); windowX = wl[0]; levelX = wl[1]; } planeWidgetY.SetInteractor(irenY); planeWidgetY.DisplayTextOff(); planeWidgetY.SetInput(VoxelData); planeWidgetY.SetPlaneOrientationToYAxes(); planeWidgetY.SetSliceIndex(slizey); planeWidgetY.SetPicker(picker); planeWidgetY.On(); planeWidgetY.InteractionOff(); if (firstTime) { double[] wl = new double[2]; vtk.vtkLookupTable lktb = new vtk.vtkLookupTable(); lktb = planeWidgetY.GetLookupTable(); wl = lktb.GetTableRange(); rangeYMin = wl[0]; rangeYMax = wl[1]; planeWidgetY.GetWindowLevel(wl); windowY = wl[0]; levelY = wl[1]; } planeWidgetZ.SetInteractor(irenZ); planeWidgetZ.DisplayTextOff(); planeWidgetZ.SetInput(VoxelData); planeWidgetZ.SetPlaneOrientationToZAxes(); planeWidgetZ.SetSliceIndex(slizez); planeWidgetZ.SetPicker(picker); planeWidgetZ.On(); planeWidgetZ.InteractionOff(); if (firstTime) { double[] wl = new double[2]; vtk.vtkLookupTable lktb = new vtk.vtkLookupTable(); lktb = planeWidgetZ.GetLookupTable(); wl = lktb.GetTableRange(); rangeZMin = wl[0]; rangeZMax = wl[1]; planeWidgetZ.GetWindowLevel(wl); windowZ = wl[0]; levelZ = wl[1]; } firstTime = false; enabled = true; if (firstime == 1) { renX.GetActiveCamera().Roll(90); renX.GetActiveCamera().Azimuth(90); renY.GetActiveCamera().Elevation(-90); renX.GetActiveCamera().ParallelProjectionOff(); renY.GetActiveCamera().ParallelProjectionOff(); renZ.GetActiveCamera().ParallelProjectionOff(); } renX.ResetCamera(); renY.ResetCamera(); renZ.ResetCamera(); renX.GetActiveCamera().ParallelProjectionOn(); renY.GetActiveCamera().ParallelProjectionOn(); renZ.GetActiveCamera().ParallelProjectionOn(); renX.GetActiveCamera().Azimuth(-90); renX.GetActiveCamera().Roll(-90); renY.GetActiveCamera().Elevation(90); firstime = 1; int[] dimensions = VoxelData.GetDimensions(); double[] spacing = VoxelData.GetSpacing(); double xmax = (double)dimensions[0] * spacing[0] * 0.5; double ymax = (double)dimensions[1] * spacing[1] * 0.5; double zmax = (double)dimensions[2] * spacing[2] * 0.5; double smax = xmax; if (ymax > smax) { smax = ymax; } if (zmax > smax) { smax = zmax; } renX.GetActiveCamera().SetParallelScale(smax); renY.GetActiveCamera().SetParallelScale(smax); renZ.GetActiveCamera().SetParallelScale(smax); renX.GetActiveCamera().SetClippingRange(0.1, 1000); renY.GetActiveCamera().SetClippingRange(0.1, 1000); renZ.GetActiveCamera().SetClippingRange(0.1, 1000); irenX.Initialize(); irenY.Initialize(); irenZ.Initialize(); irenX.Disable(); irenY.Disable(); irenZ.Disable(); renwX.Render(); renwY.Render(); renwZ.Render(); }
public void render3Dplanes(vtk.vtkImageData VoxelData) { renWin.AddRenderer(ren2); iren.SetRenderWindow(renWin); vtk.vtkOutlineFilter outline = new vtk.vtkOutlineFilter(); outline.SetInput(VoxelData); vtk.vtkPolyDataMapper outlineMapper = new vtk.vtkPolyDataMapper(); outlineMapper.SetInputConnection(outline.GetOutputPort()); vtk.vtkActor outlineActor = new vtk.vtkActor(); outlineActor.SetMapper(outlineMapper); vtk.vtkCellPicker picker = new vtk.vtkCellPicker(); picker.SetTolerance(0.005); vtk.vtkColorTransferFunction colorTransferFunction = new vtk.vtkColorTransferFunction(); double[] inputRange = VoxelData.GetScalarRange(); colorTransferFunction.AddRGBPoint(inputRange[0], 0.0, 0.0, 0.0); colorTransferFunction.AddRGBPoint(inputRange[1], 1.0, 1.0, 1.0); sColorsX.SetLookupTable(colorTransferFunction); sColorsY.SetLookupTable(colorTransferFunction); sColorsZ.SetLookupTable(colorTransferFunction); planeWidgetX.SetColorMap(sColorsX); planeWidgetX.SetInteractor(iren); planeWidgetX.DisplayTextOff(); planeWidgetX.SetInput(VoxelData); planeWidgetX.SetPlaneOrientationToXAxes(); planeWidgetX.SetSliceIndex(slizex); planeWidgetX.SetPicker(picker); planeWidgetX.On(); planeWidgetX.InteractionOff(); planeWidgetY.SetColorMap(sColorsY); planeWidgetY.SetInteractor(iren); planeWidgetY.DisplayTextOff(); planeWidgetY.SetInput(VoxelData); planeWidgetY.SetPlaneOrientationToYAxes(); planeWidgetY.SetSliceIndex(slizey); planeWidgetY.SetPicker(picker); planeWidgetY.On(); planeWidgetY.InteractionOff(); planeWidgetZ.SetColorMap(sColorsZ); planeWidgetZ.SetInteractor(iren); planeWidgetZ.DisplayTextOff(); planeWidgetZ.SetInput(VoxelData); planeWidgetZ.SetPlaneOrientationToZAxes(); planeWidgetZ.SetSliceIndex(slizez); planeWidgetZ.SetPicker(picker); planeWidgetZ.On(); planeWidgetZ.InteractionOff(); ren2.ResetCamera(); renWin.Render(); iren.Initialize(); iren.Enable(); }