@@ -18,6 +18,7 @@ namespace Zeiss.PiWeb.Volume
18
18
using System . IO ;
19
19
using System . Text ;
20
20
using System . Xml ;
21
+ using Zeiss . PiWeb . ColorScale ;
21
22
22
23
#endregion
23
24
@@ -26,6 +27,24 @@ namespace Zeiss.PiWeb.Volume
26
27
/// </summary>
27
28
public sealed class VolumeMetadata
28
29
{
30
+ #region fields
31
+
32
+ private ushort _SizeX ;
33
+ private ushort _SizeY ;
34
+ private ushort _SizeZ ;
35
+
36
+ private double _ResolutionX ;
37
+ private double _ResolutionY ;
38
+ private double _ResolutionZ ;
39
+
40
+ private ushort _PositionX ;
41
+ private ushort _PositionY ;
42
+ private ushort _PositionZ ;
43
+
44
+ private ColorScale ? _ColorScale ;
45
+
46
+ #endregion
47
+
29
48
#region constructors
30
49
31
50
private VolumeMetadata ( )
@@ -57,7 +76,6 @@ public VolumeMetadata(
57
76
SizeX = sizeX ;
58
77
SizeY = sizeY ;
59
78
SizeZ = sizeZ ;
60
-
61
79
ResolutionX = resolutionX ;
62
80
ResolutionY = resolutionY ;
63
81
ResolutionZ = resolutionZ ;
@@ -78,53 +96,58 @@ public VolumeMetadata(
78
96
/// <summary>
79
97
/// The number of Voxels in X-Dimension.
80
98
/// </summary>
81
- public ushort PositionX { get ; private set ; }
99
+ public ushort PositionX { get => _PositionX ; init => _PositionX = value ; }
82
100
83
101
/// <summary>
84
102
/// The number of Voxels in Y-Dimension.
85
103
/// </summary>
86
- public ushort PositionY { get ; private set ; }
104
+ public ushort PositionY { get => _PositionY ; init => _PositionY = value ; }
87
105
88
106
/// <summary>
89
107
/// The number of Voxels in Z-Dimension.
90
108
/// </summary>
91
- public ushort PositionZ { get ; private set ; }
109
+ public ushort PositionZ { get => _PositionZ ; init => _PositionZ = value ; }
92
110
93
111
/// <summary>
94
112
/// The number of Voxels in X-Dimension.
95
113
/// </summary>
96
- public ushort SizeX { get ; private set ; }
114
+ public ushort SizeX { get => _SizeX ; init => _SizeX = value ; }
97
115
98
116
/// <summary>
99
117
/// The number of Voxels in Y-Dimension.
100
118
/// </summary>
101
- public ushort SizeY { get ; private set ; }
119
+ public ushort SizeY { get => _SizeY ; init => _SizeY = value ; }
102
120
103
121
/// <summary>
104
122
/// The number of Voxels in Z-Dimension.
105
123
/// </summary>
106
- public ushort SizeZ { get ; private set ; }
124
+ public ushort SizeZ { get => _SizeZ ; init => _SizeZ = value ; }
107
125
108
126
/// <summary>
109
127
/// The size of a Voxel in X-Dimension (mm).
110
128
/// </summary>
111
- public double ResolutionX { get ; private set ; }
129
+ public double ResolutionX { get => _ResolutionX ; init => _ResolutionX = value ; }
112
130
113
131
/// <summary>
114
132
/// The size of a Voxel in Y-Dimension (mm).
115
133
/// </summary>
116
- public double ResolutionY { get ; private set ; }
134
+ public double ResolutionY { get => _ResolutionY ; init => _ResolutionY = value ; }
117
135
118
136
/// <summary>
119
137
/// The size of a Voxel in Z-Dimension (mm).
120
138
/// </summary>
121
- public double ResolutionZ { get ; private set ; }
139
+ public double ResolutionZ { get => _ResolutionZ ; init => _ResolutionZ = value ; }
122
140
123
141
/// <summary>
124
142
/// Gets or sets the metadata.
125
143
/// </summary>
126
144
public ICollection < Property > Properties { get ; } = new List < Property > ( ) ;
127
145
146
+ /// <summary>
147
+ /// The color scale that should be used to colorize the grayscale values of the volume.
148
+ /// </summary>
149
+ public ColorScale ? ColorScale { get => _ColorScale ; init => _ColorScale = value ; }
150
+
128
151
#endregion
129
152
130
153
#region methods
@@ -235,6 +258,13 @@ internal void Serialize( Stream stream, bool upgradeVersionNumber = true )
235
258
}
236
259
}
237
260
261
+ if ( ColorScale is not null )
262
+ {
263
+ writer . WriteStartElement ( "ColorScale" ) ;
264
+ ColorScale . Write ( writer ) ;
265
+ writer . WriteEndElement ( ) ;
266
+ }
267
+
238
268
writer . WriteEndElement ( ) ;
239
269
writer . WriteEndDocument ( ) ;
240
270
}
@@ -264,36 +294,39 @@ internal static VolumeMetadata Deserialize( Stream stream )
264
294
result . FileVersion = new Version ( reader . ReadString ( ) ) ;
265
295
break ;
266
296
case "SizeX" :
267
- result . SizeX = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
297
+ result . _SizeX = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
268
298
break ;
269
299
case "SizeY" :
270
- result . SizeY = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
300
+ result . _SizeY = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
271
301
break ;
272
302
case "SizeZ" :
273
- result . SizeZ = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
303
+ result . _SizeZ = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
274
304
break ;
275
305
case "ResolutionX" :
276
- result . ResolutionX = double . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
306
+ result . _ResolutionX = double . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
277
307
break ;
278
308
case "ResolutionY" :
279
- result . ResolutionY = double . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
309
+ result . _ResolutionY = double . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
280
310
break ;
281
311
case "ResolutionZ" :
282
- result . ResolutionZ = double . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
312
+ result . _ResolutionZ = double . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
283
313
break ;
284
314
case "Property" :
285
315
var property = Property . Deserialize ( reader ) ;
286
316
if ( property is not null )
287
317
result . Properties . Add ( property ) ;
288
318
break ;
289
319
case "PositionX" :
290
- result . PositionX = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
320
+ result . _PositionX = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
291
321
break ;
292
322
case "PositionY" :
293
- result . PositionY = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
323
+ result . _PositionY = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
294
324
break ;
295
325
case "PositionZ" :
296
- result . PositionZ = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
326
+ result . _PositionZ = ushort . Parse ( reader . ReadString ( ) , CultureInfo . InvariantCulture ) ;
327
+ break ;
328
+ case "ColorScale" :
329
+ result . _ColorScale = ColorScale . Read ( reader ) ;
297
330
break ;
298
331
}
299
332
}
0 commit comments