From 5c42c578455cbcd36745c643472c7213ed353cfe Mon Sep 17 00:00:00 2001 From: ivmartel Date: Wed, 15 Jan 2025 18:15:31 +0100 Subject: [PATCH] Use origin index in quantif, fixes #1842 --- src/image/annotation.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/image/annotation.js b/src/image/annotation.js index 71a41785ed..4b063e662a 100644 --- a/src/image/annotation.js +++ b/src/image/annotation.js @@ -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. */ - 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); @@ -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) ); }