forked from InsightSoftwareConsortium/itk-wasm
/
meshJSComponentToIOComponent.js
54 lines (51 loc) · 1.32 KB
/
meshJSComponentToIOComponent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const IntTypes = require('./IntTypes.js')
const FloatTypes = require('./FloatTypes.js')
const meshJSComponentToIOComponent = (module, componentType) => {
let ioComponentType = null
switch (componentType) {
case IntTypes.UInt8: {
ioComponentType = module.IOComponentType.UCHAR
break
}
case IntTypes.Int8: {
ioComponentType = module.IOComponentType.CHAR
break
}
case IntTypes.UInt16: {
ioComponentType = module.IOComponentType.USHORT
break
}
case IntTypes.Int16: {
ioComponentType = module.IOComponentType.SHORT
break
}
case IntTypes.UInt32: {
ioComponentType = module.IOComponentType.UINT
break
}
case IntTypes.Int32: {
ioComponentType = module.IOComponentType.INT
break
}
case IntTypes.UInt64: {
ioComponentType = module.IOComponentType.ULONGLONG
break
}
case IntTypes.Int64: {
ioComponentType = module.IOComponentType.LONGLONG
break
}
case FloatTypes.Float32: {
ioComponentType = module.IOComponentType.FLOAT
break
}
case FloatTypes.Float64: {
ioComponentType = module.IOComponentType.DOUBLE
break
}
default:
throw new Error('Unknown IO component type')
}
return ioComponentType
}
module.exports = meshJSComponentToIOComponent