Skip to content

Commit 684e304

Browse files
author
hackermd
committed
Hide implementation details of roi class
1 parent 1c86f0e commit 684e304

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/roi.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { generateUID } from './utils.js';
22

3+
const _uid = Symbol('uid');
4+
const _scoord3d = Symbol('scoord3d');
35

46
/* Region of interest.
57
*/
@@ -11,18 +13,29 @@ class ROI {
1113
*/
1214
constructor(options) {
1315
if (!('scoord3d' in options)) {
14-
console.error('spatial coordinates are required for ROI')
16+
throw new Error('spatial coordinates are required for ROI')
17+
}
18+
if (!(typeof(options.scoord3d) === 'object' || options.scoord3d !== null)) {
19+
throw new Error('scoord3d of ROI must be a Scoord3D object')
1520
}
1621
if (!('uid' in options)) {
17-
this.uid = generateUID();
22+
this[_uid] = generateUID();
1823
} else {
19-
if (!(typeof options.uid === 'string' || options.uid instanceof String)) {
24+
if (!(typeof(options.uid) === 'string' || options.uid instanceof String)) {
2025
throw new Error('uid of ROI must be a string')
2126
}
22-
this.uid = options.uid;
27+
this[_uid] = options.uid;
2328
}
24-
this.scoord3d = options.scoord3d;
25-
this.properties = options.properties ? options.properties : {};
29+
this[_scoord3d] = options.scoord3d;
30+
// TODO: store SOPInstanceUID, SOPClassUID and FrameNumbers as reference
31+
}
32+
33+
get uid() {
34+
return this[_uid];
35+
}
36+
37+
get scoord3d() {
38+
return this[_scoord3d];
2639
}
2740

2841
}

0 commit comments

Comments
 (0)