-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cornerstone-dicom-sr): Freehand SR hydration support (#1160)
* Fix freehand sr annotation load * Add perimeter and cached stats * Update import * Add perimeter * Update docs
- Loading branch information
1 parent
05f4cce
commit 5e778a1
Showing
7 changed files
with
97 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/tools/src/utilities/contours/calculatePerimeter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Calculates the perimeter of a polyline. | ||
* | ||
* @param polyline - The polyline represented as an array of points. | ||
* @param closed - Indicates whether the polyline is closed or not. | ||
* @returns The perimeter of the polyline. | ||
*/ | ||
function calculatePerimeter(polyline: number[][], closed: boolean): number { | ||
let perimeter = 0; | ||
|
||
for (let i = 0; i < polyline.length - 1; i++) { | ||
const point1 = polyline[i]; | ||
const point2 = polyline[i + 1]; | ||
perimeter += Math.sqrt( | ||
Math.pow(point2[0] - point1[0], 2) + Math.pow(point2[1] - point1[1], 2) | ||
); | ||
} | ||
|
||
if (closed) { | ||
const firstPoint = polyline[0]; | ||
const lastPoint = polyline[polyline.length - 1]; | ||
perimeter += Math.sqrt( | ||
Math.pow(lastPoint[0] - firstPoint[0], 2) + | ||
Math.pow(lastPoint[1] - firstPoint[1], 2) | ||
); | ||
} | ||
|
||
return perimeter; | ||
} | ||
|
||
export default calculatePerimeter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters