[vtkusers] Access to Cells in VTK.js
Andrzej Marciniak
marciniak.andrzej.zg at gmail.com
Fri Jan 18 13:42:46 EST 2019
Hi Sebastien,
Thank you for the tip - it works for me. Now, I have only a problem with
precision in finding IJK.
Should I better use vtkPicker or vtkMappers to get IJK position of selected
voxel? I have made a simple experiment with both ways to calculate IJK and I
got different results.
renderWindow.getInteractor().onRightButtonPress((callData) => {
if (renderer !== callData.pokedRenderer) {
return;
}
const pos = callData.position;
const point = [pos.x, pos.y, 0.0];
picker.pick(point, renderer);
const worldPos = picker.getPickedPositions()[0];
//I have only one Actor in renderer but 3 mappers set on different planes
let slices = null;
try {
slices = mappers.map((el) => {
return el.getSliceAtPosition(worldPos) // this is how I
get I,J,K with ImageMapper API
});
}
catch (err) { alert("You cannot pick a point outside MRI
volume");
return;
}
const pointIndex = slices[0] + slices[1] * dims[0] + slices[2] *
dims[0] * dims[1];
const pointIndex2 = picker.getCellIJK()[0]
+ picker.getCellIJK()[1] * dims[0]
+ picker.getCellIJK()[2] * dims[0] * dims[1];
if (pointIndex===pointIndex2)
inputData.getPointData().getScalars().getData()[pointIndex]=1983;
else {
inputData.getPointData().getScalars().getData()[pointIndex]=1700;
inputData.getPointData().getScalars().getData()[pointIndex2]
= 1500;
}
});
<http://vtk.1045678.n5.nabble.com/file/t342677/pickerProblem.png>
As a result I have different voxels marked (please see image). White voxel
is when they agree, light- and dark-grey when they don't. The results are
different when the selected point on canvas is close to the border of voxel
(points 1 and 3).
Which way is better? Can be direction of the vtkDataImage problem here (its
not aligned with xyz coordinates)?
Thank you again
Andrzej
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list