@cornerstonejs/core 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/RenderingEngine/StackViewport.js +1 -1
- package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/cjs/utilities/imageToWorldCoords.d.ts +2 -0
- package/dist/cjs/utilities/imageToWorldCoords.js +17 -0
- package/dist/cjs/utilities/imageToWorldCoords.js.map +1 -0
- package/dist/cjs/utilities/index.d.ts +3 -1
- package/dist/cjs/utilities/index.js +5 -1
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/cjs/utilities/worldToImageCoords.d.ts +3 -0
- package/dist/cjs/utilities/worldToImageCoords.js +31 -0
- package/dist/cjs/utilities/worldToImageCoords.js.map +1 -0
- package/dist/esm/RenderingEngine/StackViewport.js +1 -1
- package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/esm/utilities/imageToWorldCoords.d.ts +2 -0
- package/dist/esm/utilities/imageToWorldCoords.js +14 -0
- package/dist/esm/utilities/imageToWorldCoords.js.map +1 -0
- package/dist/esm/utilities/index.d.ts +3 -1
- package/dist/esm/utilities/index.js +3 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/worldToImageCoords.d.ts +3 -0
- package/dist/esm/utilities/worldToImageCoords.js +29 -0
- package/dist/esm/utilities/worldToImageCoords.js.map +1 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix';
|
|
2
|
+
import { metaData } from '..';
|
|
3
|
+
function worldToImageCoords(imageId, worldCoords) {
|
|
4
|
+
const imagePlaneModule = metaData.get('imagePlaneModule', imageId);
|
|
5
|
+
if (!imagePlaneModule) {
|
|
6
|
+
throw new Error(`No imagePlaneModule found for imageId: ${imageId}`);
|
|
7
|
+
}
|
|
8
|
+
const { columnCosines, columnPixelSpacing, rowCosines, rowPixelSpacing, imagePositionPatient: origin, rows, columns, } = imagePlaneModule;
|
|
9
|
+
const newOrigin = vec3.create();
|
|
10
|
+
vec3.scaleAndAdd(newOrigin, origin, columnCosines, -columnPixelSpacing / 2);
|
|
11
|
+
vec3.scaleAndAdd(newOrigin, newOrigin, rowCosines, -rowPixelSpacing / 2);
|
|
12
|
+
const sub = vec3.create();
|
|
13
|
+
vec3.sub(sub, worldCoords, newOrigin);
|
|
14
|
+
const rowDistance = vec3.dot(sub, rowCosines);
|
|
15
|
+
const columnDistance = vec3.dot(sub, columnCosines);
|
|
16
|
+
const imageCoords = [
|
|
17
|
+
rowDistance / rowPixelSpacing,
|
|
18
|
+
columnDistance / columnPixelSpacing,
|
|
19
|
+
];
|
|
20
|
+
if (imageCoords[0] < 0 ||
|
|
21
|
+
imageCoords[0] >= columns ||
|
|
22
|
+
imageCoords[1] < 0 ||
|
|
23
|
+
imageCoords[1] >= rows) {
|
|
24
|
+
throw new Error(`The image coordinates are outside of the image, imageCoords: ${imageCoords}`);
|
|
25
|
+
}
|
|
26
|
+
return imageCoords;
|
|
27
|
+
}
|
|
28
|
+
export default worldToImageCoords;
|
|
29
|
+
//# sourceMappingURL=worldToImageCoords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worldToImageCoords.js","sourceRoot":"","sources":["../../../src/utilities/worldToImageCoords.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAa9B,SAAS,kBAAkB,CACzB,OAAe,EACf,WAAmB;IAEnB,MAAM,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAEnE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,0CAA0C,OAAO,EAAE,CAAC,CAAC;KACtE;IA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