Skip to content

Commit

Permalink
fix(ImageCPRMapper): Fix projection slab thickness unit
Browse files Browse the repository at this point in the history
  • Loading branch information
bruyeret authored and finetjul committed Mar 22, 2024
1 parent f95f353 commit 7a0adb4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<tr>
<td>Number of samples</td>
<td>
<input id='projectionSamples' type='range' min='1' max='101' value='1' step="2"/>
<input id='projectionSamples' type='range' min='1' max='501' value='1' step="2"/>
</td>
</tr>
</table>
11 changes: 9 additions & 2 deletions Sources/Rendering/Core/ImageCPRMapper/example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,15 @@ projectionModeEl.addEventListener('input', (ev) => {
});

projectionThicknessEl.addEventListener('input', (ev) => {
const thickness = Number.parseFloat(projectionThicknessEl.value, 10);
mapper.setProjectionSlabThickness(thickness);
const thicknessRatio = Number.parseFloat(projectionThicknessEl.value, 10);
const image = mapper.getInputData();
if (image) {
const spacing = image.getSpacing();
const dimensions = image.getDimensions();
const diagonal = vec3.len(vec3.mul([], spacing, dimensions));
const thickness = diagonal * thicknessRatio;
mapper.setProjectionSlabThickness(thickness);
}
renderWindow.render();
});
mapper.setProjectionSlabThickness(0.1);
Expand Down
8 changes: 5 additions & 3 deletions Sources/Rendering/OpenGL/ImageCPRMapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
];
if (useProjection) {
tcoordFSDec.push(
'uniform vec3 spacing;',
'uniform vec3 volumeSizeMC;',
'uniform int projectionSlabNumberOfSamples;',
'uniform float projectionConstantOffset;',
'uniform float projectionStepLength;'
Expand Down Expand Up @@ -821,7 +821,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {

// Loop on all the samples of the projection
tcoordFSImpl.push(
'vec3 projectionScaledDirection = projectionDirection / spacing;',
'vec3 projectionScaledDirection = projectionDirection / volumeSizeMC;',
'vec3 projectionStep = projectionStepLength * projectionScaledDirection;',
'vec3 projectionStartPosition = volumePosTC + projectionConstantOffset * projectionScaledDirection;',
'vec4 tvalue = initialProjectionTextureValue;',
Expand Down Expand Up @@ -1092,12 +1092,14 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
if (model.renderable.isProjectionEnabled()) {
const image = model.currentImageDataInput;
const spacing = image.getSpacing();
const dimensions = image.getDimensions();
const projectionSlabThickness =
model.renderable.getProjectionSlabThickness();
const projectionSlabNumberOfSamples =
model.renderable.getProjectionSlabNumberOfSamples();

program.setUniform3fArray('spacing', spacing);
const volumeSize = vec3.mul([], spacing, dimensions);
program.setUniform3fArray('volumeSizeMC', volumeSize);
program.setUniformi(
'projectionSlabNumberOfSamples',
projectionSlabNumberOfSamples
Expand Down

0 comments on commit 7a0adb4

Please sign in to comment.