Skip to content

Commit

Permalink
Use origin index in quantif, fixes #1842
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Jan 15, 2025
1 parent 00be1d1 commit 5c42c57
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/image/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,37 @@ export class Annotation {
}

/**
* Get the centroid of the math shape.
* Get the index of the plane origin.
*
* @returns {Point|undefined} The 3D centroid point.
* @returns {Index|undefined} The index.

Check failure on line 194 in src/image/annotation.js

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'Index'.
*/
getCentroid() {
#getOriginIndex() {
let res;
if (typeof this.#viewController !== 'undefined' &&
typeof this.mathShape.getCentroid !== 'undefined') {
// find the slice index of the annotation origin
if (typeof this.#viewController !== 'undefined') {
let origin = this.planeOrigin;
if (typeof this.planePoints !== 'undefined') {
origin = this.planePoints[0];
}
const originPoint =
new Point([origin.getX(), origin.getY(), origin.getZ()]);
const originIndex =
this.#viewController.getIndexFromPosition(originPoint);
res = this.#viewController.getIndexFromPosition(originPoint);
}
return res;
}

/**
* Get the centroid of the math shape.
*
* @returns {Point|undefined} The 3D centroid point.
*/
getCentroid() {
let res;
if (typeof this.#viewController !== 'undefined' &&
typeof this.mathShape.getCentroid !== 'undefined') {
// find the slice index of the annotation origin
const originIndex = this.#getOriginIndex();
const scrollDimIndex = this.#viewController.getScrollDimIndex();
const k = originIndex.getValues()[scrollDimIndex];

// shape center converted to 3D
const planePoint = this.mathShape.getCentroid();
res = this.#viewController.getPositionFromPlanePoint(planePoint, k);
Expand Down Expand Up @@ -254,7 +265,7 @@ export class Annotation {
typeof this.mathShape.quantify !== 'undefined') {
this.quantification = this.mathShape.quantify(
this.#viewController,
this.#viewController.getCurrentIndex(),
this.#getOriginIndex(),
getFlags(this.textExpr)
);
}
Expand Down

0 comments on commit 5c42c57

Please sign in to comment.