Skip to content

Commit 7a0adb4

Browse files
bruyeretfinetjul
authored andcommitted
fix(ImageCPRMapper): Fix projection slab thickness unit
1 parent f95f353 commit 7a0adb4

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Sources/Rendering/Core/ImageCPRMapper/example/controller.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<tr>
4545
<td>Number of samples</td>
4646
<td>
47-
<input id='projectionSamples' type='range' min='1' max='101' value='1' step="2"/>
47+
<input id='projectionSamples' type='range' min='1' max='501' value='1' step="2"/>
4848
</td>
4949
</tr>
5050
</table>

Sources/Rendering/Core/ImageCPRMapper/example/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,15 @@ projectionModeEl.addEventListener('input', (ev) => {
421421
});
422422

423423
projectionThicknessEl.addEventListener('input', (ev) => {
424-
const thickness = Number.parseFloat(projectionThicknessEl.value, 10);
425-
mapper.setProjectionSlabThickness(thickness);
424+
const thicknessRatio = Number.parseFloat(projectionThicknessEl.value, 10);
425+
const image = mapper.getInputData();
426+
if (image) {
427+
const spacing = image.getSpacing();
428+
const dimensions = image.getDimensions();
429+
const diagonal = vec3.len(vec3.mul([], spacing, dimensions));
430+
const thickness = diagonal * thicknessRatio;
431+
mapper.setProjectionSlabThickness(thickness);
432+
}
426433
renderWindow.render();
427434
});
428435
mapper.setProjectionSlabThickness(0.1);

Sources/Rendering/OpenGL/ImageCPRMapper/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
664664
];
665665
if (useProjection) {
666666
tcoordFSDec.push(
667-
'uniform vec3 spacing;',
667+
'uniform vec3 volumeSizeMC;',
668668
'uniform int projectionSlabNumberOfSamples;',
669669
'uniform float projectionConstantOffset;',
670670
'uniform float projectionStepLength;'
@@ -821,7 +821,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
821821

822822
// Loop on all the samples of the projection
823823
tcoordFSImpl.push(
824-
'vec3 projectionScaledDirection = projectionDirection / spacing;',
824+
'vec3 projectionScaledDirection = projectionDirection / volumeSizeMC;',
825825
'vec3 projectionStep = projectionStepLength * projectionScaledDirection;',
826826
'vec3 projectionStartPosition = volumePosTC + projectionConstantOffset * projectionScaledDirection;',
827827
'vec4 tvalue = initialProjectionTextureValue;',
@@ -1092,12 +1092,14 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
10921092
if (model.renderable.isProjectionEnabled()) {
10931093
const image = model.currentImageDataInput;
10941094
const spacing = image.getSpacing();
1095+
const dimensions = image.getDimensions();
10951096
const projectionSlabThickness =
10961097
model.renderable.getProjectionSlabThickness();
10971098
const projectionSlabNumberOfSamples =
10981099
model.renderable.getProjectionSlabNumberOfSamples();
10991100

1100-
program.setUniform3fArray('spacing', spacing);
1101+
const volumeSize = vec3.mul([], spacing, dimensions);
1102+
program.setUniform3fArray('volumeSizeMC', volumeSize);
11011103
program.setUniformi(
11021104
'projectionSlabNumberOfSamples',
11031105
projectionSlabNumberOfSamples

0 commit comments

Comments
 (0)