Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions examples/jsm/loaders/NRRDLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class NRRDLoader extends Loader {

const volume = new Volume();
volume.header = headerObject;
volume.segmentation = this.segmentation;
//
// parse the (unzipped) data to a datastream of the correct type
//
Expand Down Expand Up @@ -445,7 +446,7 @@ class NRRDLoader extends Loader {
}


if ( ! headerObject.vectors || this.segmentation ) {
if ( ! headerObject.vectors ) {

volume.matrix.set(
1, 0, 0, 0,
Expand All @@ -472,7 +473,12 @@ class NRRDLoader extends Loader {

volume.inverseMatrix = new Matrix4();
volume.inverseMatrix.copy( volume.matrix ).invert();
volume.RASDimensions = new Vector3( volume.xLength, volume.yLength, volume.zLength ).applyMatrix4( volume.matrix ).round().toArray().map( Math.abs );

volume.RASDimensions = [
Math.floor( volume.xLength * spacingX ),
Math.floor( volume.yLength * spacingY ),
Math.floor( volume.zLength * spacingZ )
];

// .. and set the default threshold
// only if the threshold was not already set
Expand Down
25 changes: 20 additions & 5 deletions examples/jsm/misc/Volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,18 @@ class Volume {
this.sliceList = [];


/**
* @member {boolean} segmentation in segmentation mode, it can load 16-bits nrrds correctly
*/
this.segmentation = false;


/**
* @member {Array} RASDimensions This array holds the dimensions of the volume in the RAS space
*/



}

/**
Expand Down Expand Up @@ -332,13 +340,20 @@ class Volume {

}

firstDirection.applyMatrix4( volume.inverseMatrix ).normalize();

let iLength, jLength;

if( ! this.segmentation ) {

firstDirection.applyMatrix4( volume.inverseMatrix ).normalize();
secondDirection.applyMatrix4( volume.inverseMatrix ).normalize();
axisInIJK.applyMatrix4( volume.inverseMatrix ).normalize();

}
firstDirection.arglet = 'i';
secondDirection.applyMatrix4( volume.inverseMatrix ).normalize();
secondDirection.arglet = 'j';
axisInIJK.applyMatrix4( volume.inverseMatrix ).normalize();
const iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
const jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
const planeWidth = Math.abs( iLength * firstSpacing );
const planeHeight = Math.abs( jLength * secondSpacing );

Expand Down