Forcing vtlResliceCursorWidget to change on slider move

Dear VTK team,

could you please help me with vtlResliceCursorWidget, I would like to render reslice changes not only when I do mouse scrolling but also when I move a slider manually created by me for the purpose of slice changing. How can I pass slice number to the widget and cause it to update views? I’m using this example in my project vtk.js

Olga.

I’d start with looking at the code that calls updateReslice. It should give you an idea of how to programmatically invoke the reslice from your slider.

Hello, I tried to control the position of the slice through the slider by reading the source code (vtk-js/behavior.js at ee863d1d08dc846c904526385e3d24335db16cb9 · Kitware/vtk-js · GitHub), and found that I need to get the origin, but I don’t know how to calculate the origin through the current position of the slider, can you help me? For example, I slide to the 50th layer, how can I get the origin of the 50th layer?

If you have access to the underlying vtkImageSlice actor, you can call imageSliceActor.getBoundsForSlice(), and then get the center of that bounding box. If you would rather get the origin without going through the actor, you will need to transform the slice point to world point via the image position. For example, if you are slicing along the K axis, you would do imageData.indexToWorld([0, 0, kSliceValue]).