[vtkusers] Image is not updated when I call vtkImageViewer2.SetSlice()

Yii.Guxing yii.guxing at gmail.com
Wed Apr 11 21:30:58 EDT 2018


Hello!!

I'm using the JAVA API to display DICOM images, but image is not updated
when
I call vtkImageViewer2.SetSlice():

fun main(args: Array<String>) {
    loadAllNativeLibraries()

    val reader = vtkDICOMImageReader().apply {
        SetDirectoryName("D:\\Home\\Data\\dcm\\ct0")
        Update()
    }

    val p = VtkImageViewer(reader.GetOutput())
    JFrame("DICOM").apply {
        defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        contentPane.layout = BorderLayout()
        contentPane.add(p.component, BorderLayout.CENTER)
        setSize(600, 600)
        setLocationRelativeTo(null)
        isVisible = true
    }
    p.resetCamera()
}

internal class VtkImageViewer(imageData: vtkImageData) :
vtkJoglPanelComponent() {
    val imageViewer: vtkImageViewer2 = vtkImageViewer2().apply {

this at VtkImageViewer.windowInteractor.SetInteractorStyle(vtkInteractorStyleImage())
        SetRenderWindow(renderWindow)
        SetRenderer(renderer)
        SetupInteractor(this at VtkImageViewer.windowInteractor)
        SetInputData(imageData)
        camera.ParallelProjectionOn()
    }

    init {
        val min = imageViewer.GetSliceMin()
        val max = imageViewer.GetSliceMax()
        setInteractorStyle(vtkInteractorStyleImage())
        interactorForwarder.eventInterceptor = object :
vtkAbstractEventInterceptor() {
            override fun mouseWheelMoved(e: MouseWheelEvent): Boolean {
                val curSlice = imageViewer.GetSlice()
                val slice = when {
                    e.wheelRotation > 0 -> maxOf(curSlice - 1, min)
                    e.wheelRotation < 0 -> minOf(curSlice + 1, max)
                    else -> curSlice
                }

                if (curSlice != slice) {
                    imageViewer.SetSlice(slice)
                }

                return true
            }
        }
    }
}
<http://vtk.1045678.n5.nabble.com/file/t342389/1.gif> 



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list