From ce0c5c9b1c2ef7df9d571c113f37571261cad26f Mon Sep 17 00:00:00 2001 From: ladeirarodolfo <39910206+ladeirarodolfo@users.noreply.github.com> Date: Mon, 5 Sep 2022 11:13:17 -0300 Subject: [PATCH] fix: wrong ushape calculation when loading SR/freehand from server (#199) --- .../annotation/planarFreehandROITool/renderMethods.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/tools/src/tools/annotation/planarFreehandROITool/renderMethods.ts b/packages/tools/src/tools/annotation/planarFreehandROITool/renderMethods.ts index 095c42bbd..586cd17c7 100644 --- a/packages/tools/src/tools/annotation/planarFreehandROITool/renderMethods.ts +++ b/packages/tools/src/tools/annotation/planarFreehandROITool/renderMethods.ts @@ -52,6 +52,10 @@ function renderContour( svgDrawingHelper: SVGDrawingHelper, annotation: PlanarFreehandROIAnnotation ): void { + // prevent drawing or further calculation in case viewport data is not ready yet + if (!enabledElement?.viewport?.getImageData()) { + return; + } // Check if the contour is an open contour if (annotation.data.isOpenContour) { // If its an open contour, check i its a U-shaped contour @@ -212,6 +216,11 @@ function renderOpenUShapedContour( this.renderOpenContour(enabledElement, svgDrawingHelper, annotation); + // prevent rendering u shape in case openUShapeContourVectorToPeak is not set yet + if (!openUShapeContourVectorToPeak) { + return; + } + const firstCanvasPoint = viewport.worldToCanvas(polyline[0]); const lastCanvasPoint = viewport.worldToCanvas(polyline[polyline.length - 1]);