@cornerstonejs/core 0.36.3 → 0.36.5

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.
Files changed (229) hide show
  1. package/dist/cjs/RenderingEngine/VolumeViewport3D.d.ts +1 -0
  2. package/dist/cjs/RenderingEngine/VolumeViewport3D.js +3 -0
  3. package/dist/cjs/RenderingEngine/VolumeViewport3D.js.map +1 -1
  4. package/dist/cjs/utilities/getSliceRange.js +2 -1
  5. package/dist/cjs/utilities/getSliceRange.js.map +1 -1
  6. package/dist/esm/RenderingEngine/VolumeViewport3D.d.ts +1 -0
  7. package/dist/esm/RenderingEngine/VolumeViewport3D.js +3 -0
  8. package/dist/esm/RenderingEngine/VolumeViewport3D.js.map +1 -1
  9. package/dist/esm/utilities/getSliceRange.js +2 -1
  10. package/dist/esm/utilities/getSliceRange.js.map +1 -1
  11. package/dist/umd/index.js +1 -1
  12. package/dist/umd/index.js.map +1 -1
  13. package/package.json +4 -3
  14. package/src/RenderingEngine/BaseVolumeViewport.ts +847 -0
  15. package/src/RenderingEngine/RenderingEngine.ts +1364 -0
  16. package/src/RenderingEngine/StackViewport.ts +2690 -0
  17. package/src/RenderingEngine/Viewport.ts +1244 -0
  18. package/src/RenderingEngine/VolumeViewport.ts +420 -0
  19. package/src/RenderingEngine/VolumeViewport3D.ts +46 -0
  20. package/src/RenderingEngine/getRenderingEngine.ts +34 -0
  21. package/src/RenderingEngine/helpers/addVolumesToViewports.ts +52 -0
  22. package/src/RenderingEngine/helpers/cpuFallback/colors/colormap.ts +343 -0
  23. package/src/RenderingEngine/helpers/cpuFallback/colors/index.ts +4 -0
  24. package/src/RenderingEngine/helpers/cpuFallback/colors/lookupTable.ts +469 -0
  25. package/src/RenderingEngine/helpers/cpuFallback/drawImageSync.ts +58 -0
  26. package/src/RenderingEngine/helpers/cpuFallback/rendering/calculateTransform.ts +136 -0
  27. package/src/RenderingEngine/helpers/cpuFallback/rendering/canvasToPixel.ts +25 -0
  28. package/src/RenderingEngine/helpers/cpuFallback/rendering/computeAutoVoi.ts +47 -0
  29. package/src/RenderingEngine/helpers/cpuFallback/rendering/correctShift.ts +38 -0
  30. package/src/RenderingEngine/helpers/cpuFallback/rendering/createViewport.ts +64 -0
  31. package/src/RenderingEngine/helpers/cpuFallback/rendering/doesImageNeedToBeRendered.ts +36 -0
  32. package/src/RenderingEngine/helpers/cpuFallback/rendering/fitToWindow.ts +22 -0
  33. package/src/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.ts +60 -0
  34. package/src/RenderingEngine/helpers/cpuFallback/rendering/generateLut.ts +83 -0
  35. package/src/RenderingEngine/helpers/cpuFallback/rendering/getDefaultViewport.ts +88 -0
  36. package/src/RenderingEngine/helpers/cpuFallback/rendering/getImageFitScale.ts +52 -0
  37. package/src/RenderingEngine/helpers/cpuFallback/rendering/getImageSize.ts +55 -0
  38. package/src/RenderingEngine/helpers/cpuFallback/rendering/getLut.ts +53 -0
  39. package/src/RenderingEngine/helpers/cpuFallback/rendering/getModalityLut.ts +55 -0
  40. package/src/RenderingEngine/helpers/cpuFallback/rendering/getTransform.ts +17 -0
  41. package/src/RenderingEngine/helpers/cpuFallback/rendering/getVOILut.ts +74 -0
  42. package/src/RenderingEngine/helpers/cpuFallback/rendering/initializeRenderCanvas.ts +37 -0
  43. package/src/RenderingEngine/helpers/cpuFallback/rendering/lutMatches.ts +21 -0
  44. package/src/RenderingEngine/helpers/cpuFallback/rendering/now.ts +13 -0
  45. package/src/RenderingEngine/helpers/cpuFallback/rendering/pixelToCanvas.ts +22 -0
  46. package/src/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.ts +193 -0
  47. package/src/RenderingEngine/helpers/cpuFallback/rendering/renderGrayscaleImage.ts +166 -0
  48. package/src/RenderingEngine/helpers/cpuFallback/rendering/renderPseudoColorImage.ts +203 -0
  49. package/src/RenderingEngine/helpers/cpuFallback/rendering/resetCamera.ts +32 -0
  50. package/src/RenderingEngine/helpers/cpuFallback/rendering/resize.ts +109 -0
  51. package/src/RenderingEngine/helpers/cpuFallback/rendering/saveLastRendered.ts +36 -0
  52. package/src/RenderingEngine/helpers/cpuFallback/rendering/setDefaultViewport.ts +17 -0
  53. package/src/RenderingEngine/helpers/cpuFallback/rendering/setToPixelCoordinateSystem.ts +32 -0
  54. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedColorPixelDataToCanvasImageData.ts +58 -0
  55. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageData.ts +76 -0
  56. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataColorLUT.ts +60 -0
  57. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPET.ts +50 -0
  58. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPseudocolorLUT.ts +66 -0
  59. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPseudocolorLUTPET.ts +68 -0
  60. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataRGBA.ts +81 -0
  61. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedRGBAPixelDataToCanvasImageData.ts +56 -0
  62. package/src/RenderingEngine/helpers/cpuFallback/rendering/transform.ts +126 -0
  63. package/src/RenderingEngine/helpers/cpuFallback/rendering/validator.ts +31 -0
  64. package/src/RenderingEngine/helpers/createVolumeActor.ts +103 -0
  65. package/src/RenderingEngine/helpers/createVolumeMapper.ts +37 -0
  66. package/src/RenderingEngine/helpers/getOrCreateCanvas.ts +58 -0
  67. package/src/RenderingEngine/helpers/index.ts +15 -0
  68. package/src/RenderingEngine/helpers/isRgbaSourceRgbDest.ts +1 -0
  69. package/src/RenderingEngine/helpers/setDefaultVolumeVOI.ts +227 -0
  70. package/src/RenderingEngine/helpers/setVolumesForViewports.ts +52 -0
  71. package/src/RenderingEngine/helpers/viewportTypeToViewportClass.ts +14 -0
  72. package/src/RenderingEngine/helpers/viewportTypeUsesCustomRenderingPipeline.ts +7 -0
  73. package/src/RenderingEngine/helpers/volumeNewImageEventDispatcher.ts +75 -0
  74. package/src/RenderingEngine/index.ts +23 -0
  75. package/src/RenderingEngine/renderingEngineCache.ts +43 -0
  76. package/src/RenderingEngine/vtkClasses/index.js +11 -0
  77. package/src/RenderingEngine/vtkClasses/vtkOffscreenMultiRenderWindow.js +149 -0
  78. package/src/RenderingEngine/vtkClasses/vtkSharedVolumeMapper.js +52 -0
  79. package/src/RenderingEngine/vtkClasses/vtkSlabCamera.d.ts +781 -0
  80. package/src/RenderingEngine/vtkClasses/vtkSlabCamera.js +155 -0
  81. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLRenderWindow.js +47 -0
  82. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLTexture.js +272 -0
  83. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLViewNodeFactory.js +159 -0
  84. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +319 -0
  85. package/src/Settings.ts +294 -0
  86. package/src/cache/cache.ts +854 -0
  87. package/src/cache/classes/Contour.ts +70 -0
  88. package/src/cache/classes/ContourSet.ts +151 -0
  89. package/src/cache/classes/ImageVolume.ts +155 -0
  90. package/src/cache/index.ts +5 -0
  91. package/src/constants/cpuColormaps.ts +1537 -0
  92. package/src/constants/epsilon.ts +3 -0
  93. package/src/constants/index.ts +13 -0
  94. package/src/constants/mprCameraValues.ts +20 -0
  95. package/src/constants/rendering.ts +8 -0
  96. package/src/constants/viewportPresets.ts +357 -0
  97. package/src/enums/BlendModes.ts +23 -0
  98. package/src/enums/ContourType.ts +6 -0
  99. package/src/enums/Events.ts +196 -0
  100. package/src/enums/GeometryType.ts +5 -0
  101. package/src/enums/InterpolationType.ts +13 -0
  102. package/src/enums/OrientationAxis.ts +8 -0
  103. package/src/enums/RequestType.ts +13 -0
  104. package/src/enums/SharedArrayBufferModes.ts +11 -0
  105. package/src/enums/VOILUTFunctionType.ts +10 -0
  106. package/src/enums/ViewportType.ts +21 -0
  107. package/src/enums/index.ts +23 -0
  108. package/src/eventTarget.ts +67 -0
  109. package/src/getEnabledElement.ts +105 -0
  110. package/src/global.ts +8 -0
  111. package/src/index.ts +123 -0
  112. package/src/init.ts +247 -0
  113. package/src/loaders/geometryLoader.ts +108 -0
  114. package/src/loaders/imageLoader.ts +298 -0
  115. package/src/loaders/volumeLoader.ts +477 -0
  116. package/src/metaData.ts +84 -0
  117. package/src/requestPool/imageLoadPoolManager.ts +43 -0
  118. package/src/requestPool/imageRetrievalPoolManager.ts +25 -0
  119. package/src/requestPool/requestPoolManager.ts +329 -0
  120. package/src/types/ActorSliceRange.ts +17 -0
  121. package/src/types/CPUFallbackColormap.ts +23 -0
  122. package/src/types/CPUFallbackColormapData.ts +12 -0
  123. package/src/types/CPUFallbackColormapsData.ts +7 -0
  124. package/src/types/CPUFallbackEnabledElement.ts +71 -0
  125. package/src/types/CPUFallbackLUT.ts +5 -0
  126. package/src/types/CPUFallbackLookupTable.ts +17 -0
  127. package/src/types/CPUFallbackRenderingTools.ts +25 -0
  128. package/src/types/CPUFallbackTransform.ts +16 -0
  129. package/src/types/CPUFallbackViewport.ts +29 -0
  130. package/src/types/CPUFallbackViewportDisplayedArea.ts +15 -0
  131. package/src/types/CPUIImageData.ts +47 -0
  132. package/src/types/ContourData.ts +19 -0
  133. package/src/types/Cornerstone3DConfig.ts +31 -0
  134. package/src/types/CustomEventType.ts +14 -0
  135. package/src/types/EventTypes.ts +403 -0
  136. package/src/types/FlipDirection.ts +9 -0
  137. package/src/types/IActor.ts +23 -0
  138. package/src/types/ICache.ts +28 -0
  139. package/src/types/ICachedGeometry.ts +13 -0
  140. package/src/types/ICachedImage.ts +13 -0
  141. package/src/types/ICachedVolume.ts +12 -0
  142. package/src/types/ICamera.ts +36 -0
  143. package/src/types/IContour.ts +18 -0
  144. package/src/types/IContourSet.ts +56 -0
  145. package/src/types/IDynamicImageVolume.ts +18 -0
  146. package/src/types/IEnabledElement.ts +21 -0
  147. package/src/types/IGeometry.ts +12 -0
  148. package/src/types/IImage.ts +113 -0
  149. package/src/types/IImageData.ts +45 -0
  150. package/src/types/IImageVolume.ts +78 -0
  151. package/src/types/ILoadObject.ts +36 -0
  152. package/src/types/IRegisterImageLoader.ts +10 -0
  153. package/src/types/IRenderingEngine.ts +28 -0
  154. package/src/types/IStackViewport.ts +138 -0
  155. package/src/types/IStreamingImageVolume.ts +13 -0
  156. package/src/types/IStreamingVolumeProperties.ts +14 -0
  157. package/src/types/IViewport.ts +149 -0
  158. package/src/types/IViewportId.ts +9 -0
  159. package/src/types/IVolume.ts +45 -0
  160. package/src/types/IVolumeInput.ts +36 -0
  161. package/src/types/IVolumeViewport.ts +141 -0
  162. package/src/types/ImageLoaderFn.ts +16 -0
  163. package/src/types/ImageSliceData.ts +6 -0
  164. package/src/types/Mat3.ts +16 -0
  165. package/src/types/Metadata.ts +39 -0
  166. package/src/types/OrientationVectors.ts +36 -0
  167. package/src/types/Plane.ts +6 -0
  168. package/src/types/Point2.ts +6 -0
  169. package/src/types/Point3.ts +6 -0
  170. package/src/types/Point4.ts +6 -0
  171. package/src/types/ScalingParameters.ts +27 -0
  172. package/src/types/StackViewportProperties.ts +25 -0
  173. package/src/types/TransformMatrix2D.ts +4 -0
  174. package/src/types/ViewportInputOptions.ts +21 -0
  175. package/src/types/ViewportPreset.ts +14 -0
  176. package/src/types/VolumeLoaderFn.ts +18 -0
  177. package/src/types/VolumeViewportProperties.ts +14 -0
  178. package/src/types/index.ts +157 -0
  179. package/src/types/voi.ts +15 -0
  180. package/src/utilities/actorCheck.ts +24 -0
  181. package/src/utilities/applyPreset.ts +132 -0
  182. package/src/utilities/calculateViewportsSpatialRegistration.ts +74 -0
  183. package/src/utilities/calibratedPixelSpacingMetadataProvider.ts +38 -0
  184. package/src/utilities/createFloat32SharedArray.ts +45 -0
  185. package/src/utilities/createInt16SharedArray.ts +43 -0
  186. package/src/utilities/createLinearRGBTransferFunction.ts +22 -0
  187. package/src/utilities/createSigmoidRGBTransferFunction.ts +63 -0
  188. package/src/utilities/createUInt16SharedArray.ts +43 -0
  189. package/src/utilities/createUint8SharedArray.ts +45 -0
  190. package/src/utilities/deepFreeze.ts +19 -0
  191. package/src/utilities/deepMerge.ts +81 -0
  192. package/src/utilities/getClosestImageId.ts +80 -0
  193. package/src/utilities/getClosestStackImageIndexForPoint.ts +116 -0
  194. package/src/utilities/getImageSliceDataForVolumeViewport.ts +61 -0
  195. package/src/utilities/getMinMax.ts +31 -0
  196. package/src/utilities/getRuntimeId.ts +54 -0
  197. package/src/utilities/getScalarDataType.ts +31 -0
  198. package/src/utilities/getScalingParameters.ts +35 -0
  199. package/src/utilities/getSliceRange.ts +86 -0
  200. package/src/utilities/getSpacingInNormalDirection.ts +44 -0
  201. package/src/utilities/getTargetVolumeAndSpacingInNormalDir.ts +126 -0
  202. package/src/utilities/getViewportImageCornersInWorld.ts +102 -0
  203. package/src/utilities/getViewportsWithImageURI.ts +46 -0
  204. package/src/utilities/getViewportsWithVolumeId.ts +38 -0
  205. package/src/utilities/getVoiFromSigmoidRGBTransferFunction.ts +23 -0
  206. package/src/utilities/getVolumeActorCorners.ts +24 -0
  207. package/src/utilities/getVolumeSliceRangeInfo.ts +52 -0
  208. package/src/utilities/getVolumeViewportScrollInfo.ts +32 -0
  209. package/src/utilities/getVolumeViewportsContainingSameVolumes.ts +58 -0
  210. package/src/utilities/hasNaNValues.ts +12 -0
  211. package/src/utilities/imageIdToURI.ts +10 -0
  212. package/src/utilities/imageToWorldCoords.ts +54 -0
  213. package/src/utilities/index.ts +100 -0
  214. package/src/utilities/indexWithinDimensions.ts +27 -0
  215. package/src/utilities/invertRgbTransferFunction.ts +36 -0
  216. package/src/utilities/isEqual.ts +27 -0
  217. package/src/utilities/isOpposite.ts +23 -0
  218. package/src/utilities/isTypedArray.ts +20 -0
  219. package/src/utilities/loadImageToCanvas.ts +80 -0
  220. package/src/utilities/planar.ts +91 -0
  221. package/src/utilities/renderToCanvas.ts +32 -0
  222. package/src/utilities/scaleRgbTransferFunction.ts +37 -0
  223. package/src/utilities/snapFocalPointToSlice.ts +78 -0
  224. package/src/utilities/spatialRegistrationMetadataProvider.ts +50 -0
  225. package/src/utilities/transformWorldToIndex.ts +16 -0
  226. package/src/utilities/triggerEvent.ts +38 -0
  227. package/src/utilities/uuidv4.ts +13 -0
  228. package/src/utilities/windowLevel.ts +39 -0
  229. package/src/utilities/worldToImageCoords.ts +64 -0
@@ -0,0 +1,70 @@
1
+ import { Point3, ContourData, IContour } from '../../types';
2
+ import { ContourType } from '../../enums';
3
+
4
+ type ContourProps = {
5
+ id: string;
6
+ data: ContourData;
7
+ color: Point3;
8
+ };
9
+
10
+ /**
11
+ * The `Contour` class implements the `IContour` interface and represents a contour in 3D space.
12
+ * It holds information about the contour's id, size in bytes, points, color, and type.
13
+ * The class also provides methods to retrieve the points, color, and type of the contour.
14
+ * Each Contour is part of a ContourSet, and each ContourSet is part of a Geometry.
15
+ */
16
+ export class Contour implements IContour {
17
+ readonly id: string;
18
+ readonly sizeInBytes: number;
19
+ points: Point3[];
20
+ color: Point3;
21
+ type: ContourType;
22
+
23
+ constructor(props: ContourProps) {
24
+ const { points, type } = props.data;
25
+ this.id = props.id;
26
+ this.points = points;
27
+ this.type = type;
28
+ this.color = props.color;
29
+
30
+ this.sizeInBytes = this._getSizeInBytes();
31
+ }
32
+
33
+ _getSizeInBytes(): number {
34
+ let sizeInBytes = 0;
35
+
36
+ // Assuming each point is 1 byte
37
+ sizeInBytes += this.points.length * 3;
38
+ return sizeInBytes;
39
+ }
40
+
41
+ /**
42
+ * It returns the value of the points property of the data object
43
+ * @returns The points property of the data object.
44
+ */
45
+ public getPoints(): Point3[] {
46
+ return this.points;
47
+ }
48
+
49
+ public getFlatPointsArray(): number[] {
50
+ return this.points.map((point) => [...point]).flat();
51
+ }
52
+
53
+ /**
54
+ * This function returns the color of the contour
55
+ * @returns The color of the contour
56
+ */
57
+ public getColor(): Point3 {
58
+ return this.color;
59
+ }
60
+
61
+ /**
62
+ * It returns the type of the contour, closed or open
63
+ * @returns The type of the contour.
64
+ */
65
+ public getType(): ContourType {
66
+ return this.type;
67
+ }
68
+ }
69
+
70
+ export default Contour;
@@ -0,0 +1,151 @@
1
+ import { Point3, IContourSet, IContour, ContourData } from '../../types';
2
+ import Contour from './Contour';
3
+
4
+ type ContourSetProps = {
5
+ id: string;
6
+ data: ContourData[];
7
+ frameOfReferenceUID: string;
8
+ color?: Point3;
9
+ };
10
+
11
+ /**
12
+ * This class represents a set of contours in 3d space.
13
+ * Usually contours are grouped together in a contour set to represent a meaningful shape.
14
+ */
15
+ export class ContourSet implements IContourSet {
16
+ readonly id: string;
17
+ readonly sizeInBytes: number;
18
+ readonly frameOfReferenceUID: string;
19
+ private color: Point3 = [200, 0, 0]; // default color
20
+ contours: IContour[];
21
+
22
+ constructor(props: ContourSetProps) {
23
+ this.id = props.id;
24
+ this.contours = [];
25
+ this.color = props.color ?? this.color;
26
+ this.frameOfReferenceUID = props.frameOfReferenceUID;
27
+
28
+ this._createEachContour(props.data);
29
+ this.sizeInBytes = this._getSizeInBytes();
30
+ }
31
+
32
+ _createEachContour(contourDataArray: ContourData[]): void {
33
+ for (let i = 0; i < contourDataArray.length; i++) {
34
+ const contour = new Contour({
35
+ id: `${this.id}-${i}`,
36
+ data: {
37
+ points: contourDataArray[i].points,
38
+ type: contourDataArray[i].type,
39
+ },
40
+ color: contourDataArray[i].color ?? this.color,
41
+ });
42
+
43
+ this.contours.push(contour);
44
+ }
45
+ }
46
+
47
+ _getSizeInBytes(): number {
48
+ return this.contours.reduce((sizeInBytes, contour) => {
49
+ return sizeInBytes + contour.sizeInBytes;
50
+ }, 0);
51
+ }
52
+
53
+ public getColor(): Point3 {
54
+ // Currently, all contours in a contour set have the same color.
55
+ // This may change in the future.
56
+ return this.color;
57
+ }
58
+
59
+ /**
60
+ * This function returns the contours of the image
61
+ * @returns The contours of the image.
62
+ */
63
+ public getContours(): IContour[] {
64
+ return this.contours;
65
+ }
66
+
67
+ public getSizeInBytes(): number {
68
+ return this.sizeInBytes;
69
+ }
70
+
71
+ /**
72
+ * It returns an array of all the points in the glyph
73
+ * @returns An array of points.
74
+ */
75
+ public getFlatPointsArray(): Point3[] {
76
+ return this.contours.map((contour) => contour.getPoints()).flat();
77
+ }
78
+
79
+ /**
80
+ * This function returns the number of contours in the current shape.
81
+ * @returns The number of contours in the glyph.
82
+ */
83
+ public getNumberOfContours(): number {
84
+ return this.contours.length;
85
+ }
86
+
87
+ /**
88
+ * It loops through each contour in the `contours` array, and adds the number of
89
+ * points in each contour to the `numberOfPoints` variable
90
+ * @returns The number of points in the contours.
91
+ */
92
+ public getTotalNumberOfPoints(): number {
93
+ return this.contours.reduce((numberOfPoints, contour) => {
94
+ return numberOfPoints + contour.getPoints().length;
95
+ }, 0);
96
+ }
97
+
98
+ /**
99
+ * It returns an array of the number of points in each contour.
100
+ * @returns An array of numbers.
101
+ */
102
+ public getNumberOfPointsArray(): number[] {
103
+ return this.contours.reduce((acc, _, i) => {
104
+ acc[i] = this.getNumberOfPointsInAContour(i);
105
+ return acc;
106
+ }, []);
107
+ }
108
+
109
+ /**
110
+ * It returns the points in a contour.
111
+ * @param contourIndex - The index of the contour you want to get the
112
+ * points from.
113
+ * @returns An array of Point3 objects.
114
+ */
115
+ public getPointsInContour(contourIndex: number): Point3[] {
116
+ return this.contours[contourIndex].getPoints();
117
+ }
118
+ /**
119
+ * "This function returns the number of points in a contour."
120
+ *
121
+ * @param contourIndex - The index of the contour you want to get the
122
+ * number of points from.
123
+ * @returns The number of points in the contour.
124
+ */
125
+ public getNumberOfPointsInAContour(contourIndex: number): number {
126
+ return this.getPointsInContour(contourIndex).length;
127
+ }
128
+
129
+ /**
130
+ public convertToClosedSurface(): ClosedSurface {
131
+ const flatPointsArray = this.getFlatPointsArray();
132
+ const numPointsArray = this.getNumberOfPointsArray();
133
+
134
+ const closedSurfaceData = polySeg.convertToClosedSurface(
135
+ flatPointsArray,
136
+ numPointsArray
137
+ );
138
+
139
+ const closedSurface = new ClosedSurface({
140
+ id: this.id,
141
+ data: closedSurfaceData,
142
+ color: this.color,
143
+ });
144
+
145
+ // cache the closed surface
146
+ return closedSurface;
147
+ }
148
+ */
149
+ }
150
+
151
+ export default Contour;
@@ -0,0 +1,155 @@
1
+ import isTypedArray from '../../utilities/isTypedArray';
2
+ import { imageIdToURI } from '../../utilities';
3
+ import { vtkStreamingOpenGLTexture } from '../../RenderingEngine/vtkClasses';
4
+ import {
5
+ IVolume,
6
+ VolumeScalarData,
7
+ Metadata,
8
+ Point3,
9
+ IImageVolume,
10
+ Mat3,
11
+ } from '../../types';
12
+
13
+ /** The base class for volume data. It includes the volume metadata
14
+ * and the volume data along with the loading status.
15
+ */
16
+ export class ImageVolume implements IImageVolume {
17
+ private _imageIds: Array<string>;
18
+ private _imageIdsIndexMap = new Map();
19
+ private _imageURIsIndexMap = new Map();
20
+ /** volume scalar data 3D or 4D */
21
+ protected scalarData: VolumeScalarData | Array<VolumeScalarData>;
22
+
23
+ /** Read-only unique identifier for the volume */
24
+ readonly volumeId: string;
25
+ /** Dimensions of the volume */
26
+ dimensions: Point3;
27
+ /** volume direction in world space */
28
+ direction: Mat3;
29
+ /** volume metadata */
30
+ metadata: Metadata;
31
+ /** volume origin, Note this is an opinionated origin for the volume */
32
+ origin: Point3;
33
+ /** Whether preScaling has been performed on the volume */
34
+ isPrescaled = false;
35
+ /** volume scaling parameters if it contains scaled data */
36
+ scaling?: {
37
+ PET?: {
38
+ // @TODO: Do these values exist?
39
+ SUVlbmFactor?: number;
40
+ SUVbsaFactor?: number;
41
+ // accessed in ProbeTool
42
+ suvbwToSuvlbm?: number;
43
+ suvbwToSuvbsa?: number;
44
+ };
45
+ };
46
+ /** volume size in bytes */
47
+ sizeInBytes?: number; // Seems weird to pass this in? Why not grab it from scalarData.byteLength
48
+ /** volume spacing in 3d world space */
49
+ spacing: Point3;
50
+ /** volume number of voxels */
51
+ numVoxels: number;
52
+ /** volume image data */
53
+ imageData?: any;
54
+ /** open gl texture for the volume */
55
+ vtkOpenGLTexture: any; // No good way of referencing vtk classes as they aren't classes.
56
+ /** load status object for the volume */
57
+ loadStatus?: Record<string, any>;
58
+ /** optional reference volume id if the volume is derived from another volume */
59
+ referencedVolumeId?: string;
60
+ /** whether the metadata for the pixel spacing is not undefined */
61
+ hasPixelSpacing: boolean;
62
+
63
+ constructor(props: IVolume) {
64
+ this.volumeId = props.volumeId;
65
+ this.metadata = props.metadata;
66
+ this.dimensions = props.dimensions;
67
+ this.spacing = props.spacing;
68
+ this.origin = props.origin;
69
+ this.direction = props.direction;
70
+ this.imageData = props.imageData;
71
+ this.scalarData = props.scalarData;
72
+ this.sizeInBytes = props.sizeInBytes;
73
+ this.vtkOpenGLTexture = vtkStreamingOpenGLTexture.newInstance();
74
+ this.numVoxels =
75
+ this.dimensions[0] * this.dimensions[1] * this.dimensions[2];
76
+
77
+ if (props.scaling) {
78
+ this.scaling = props.scaling;
79
+ }
80
+
81
+ if (props.referencedVolumeId) {
82
+ this.referencedVolumeId = props.referencedVolumeId;
83
+ }
84
+ }
85
+
86
+ /** return the image ids for the volume if it is made of separated images */
87
+ public get imageIds(): Array<string> {
88
+ return this._imageIds;
89
+ }
90
+
91
+ /** updates the image ids */
92
+ public set imageIds(newImageIds: Array<string>) {
93
+ this._imageIds = newImageIds;
94
+ this._reprocessImageIds();
95
+ }
96
+
97
+ private _reprocessImageIds() {
98
+ this._imageIdsIndexMap.clear();
99
+ this._imageURIsIndexMap.clear();
100
+
101
+ this._imageIds.forEach((imageId, i) => {
102
+ const imageURI = imageIdToURI(imageId);
103
+
104
+ this._imageIdsIndexMap.set(imageId, i);
105
+ this._imageURIsIndexMap.set(imageURI, i);
106
+ });
107
+ }
108
+
109
+ cancelLoading: () => void;
110
+
111
+ /** return true if it is a 4D volume or false if it is 3D volume */
112
+ public isDynamicVolume(): boolean {
113
+ return false;
114
+ }
115
+
116
+ /**
117
+ * Return the scalar data for 3D volumes or the active scalar data
118
+ * (current time point) for 4D volumes
119
+ */
120
+ public getScalarData(): VolumeScalarData {
121
+ if (isTypedArray(this.scalarData)) {
122
+ return <VolumeScalarData>this.scalarData;
123
+ }
124
+
125
+ throw new Error('Unknow scalar data type');
126
+ }
127
+
128
+ /**
129
+ * return the index of a given imageId
130
+ * @param imageId - imageId
131
+ * @returns imageId index
132
+ */
133
+ public getImageIdIndex(imageId: string): number {
134
+ return this._imageIdsIndexMap.get(imageId);
135
+ }
136
+
137
+ /**
138
+ * return the index of a given imageURI
139
+ * @param imageId - imageURI
140
+ * @returns imageURI index
141
+ */
142
+ public getImageURIIndex(imageURI: string): number {
143
+ return this._imageURIsIndexMap.get(imageURI);
144
+ }
145
+
146
+ /**
147
+ * destroy the volume and make it unusable
148
+ */
149
+ destroy(): void {
150
+ this.vtkOpenGLTexture.delete();
151
+ this.scalarData = null;
152
+ }
153
+ }
154
+
155
+ export default ImageVolume;
@@ -0,0 +1,5 @@
1
+ import cache, { Cache } from './cache';
2
+ import ImageVolume from './classes/ImageVolume';
3
+
4
+ export { ImageVolume, Cache };
5
+ export default cache;