forked from Kitware/VTK
/
vtkImageResliceMapper.h
287 lines (249 loc) · 9.11 KB
/
vtkImageResliceMapper.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/*=========================================================================
Program: Visualization Toolkit
Module: vtkImageResliceMapper.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkImageResliceMapper
* @brief map a slice of a vtkImageData to the screen
*
* vtkImageResliceMapper will cut a 3D image with an abitrary slice plane
* and draw the results on the screen. The slice can be set to automatically
* follow the camera, so that the camera controls the slicing.
* @par Thanks:
* Thanks to David Gobbi at the Seaman Family MR Centre and Dept. of Clinical
* Neurosciences, Foothills Medical Centre, Calgary, for providing this class.
* @sa
* vtkImageSlice vtkImageProperty vtkImageSliceMapper
*/
#ifndef vtkImageResliceMapper_h
#define vtkImageResliceMapper_h
#include "vtkRenderingImageModule.h" // For export macro
#include "vtkImageMapper3D.h"
class vtkImageSliceMapper;
class vtkRenderer;
class vtkRenderWindow;
class vtkCamera;
class vtkLookupTable;
class vtkImageSlice;
class vtkImageData;
class vtkImageResliceToColors;
class vtkMatrix4x4;
class vtkAbstractImageInterpolator;
class VTKRENDERINGIMAGE_EXPORT vtkImageResliceMapper : public vtkImageMapper3D
{
public:
static vtkImageResliceMapper *New();
vtkTypeMacro(vtkImageResliceMapper,vtkImageMapper3D);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Set the slice that will be used to cut through the image.
* This slice should be in world coordinates, rather than
* data coordinates. Use SliceFacesCamera and SliceAtFocalPoint
* if you want the slice to automatically follow the camera.
*/
virtual void SetSlicePlane(vtkPlane *plane);
//@{
/**
* When using SliceAtFocalPoint, this causes the slicing to occur at
* the closest slice to the focal point, instead of the default behavior
* where a new slice is interpolated between the original slices. This
* flag is ignored if the slicing is oblique to the original slices.
*/
vtkSetMacro(JumpToNearestSlice, int);
vtkBooleanMacro(JumpToNearestSlice, int);
vtkGetMacro(JumpToNearestSlice, int);
//@}
//@{
/**
* The slab thickness, for thick slicing (default: zero)
*/
vtkSetMacro(SlabThickness, double);
vtkGetMacro(SlabThickness, double);
//@}
//@{
/**
* The slab type, for thick slicing (default: Mean).
* The resulting view is a parallel projection through the volume. This
* method can be used to generate a facsimile of a digitally-reconstructed
* radiograph or a minimum-intensity projection as long as perspective
* geometry is not required. Note that the Sum mode provides an output
* with units of intensity times distance, while all other modes provide
* an output with units of intensity.
*/
vtkSetClampMacro(SlabType, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
vtkGetMacro(SlabType, int);
void SetSlabTypeToMin() {
this->SetSlabType(VTK_IMAGE_SLAB_MIN); };
void SetSlabTypeToMax() {
this->SetSlabType(VTK_IMAGE_SLAB_MAX); };
void SetSlabTypeToMean() {
this->SetSlabType(VTK_IMAGE_SLAB_MEAN); };
void SetSlabTypeToSum() {
this->SetSlabType(VTK_IMAGE_SLAB_SUM); };
virtual const char *GetSlabTypeAsString();
//@}
//@{
/**
* Set the number of slab samples to use as a factor of the number
* of input slices within the slab thickness. The default value
* is 2, but 1 will increase speed with very little loss of quality.
*/
vtkSetClampMacro(SlabSampleFactor, int, 1, 2);
vtkGetMacro(SlabSampleFactor, int);
//@}
//@{
/**
* Set the reslice sample frequency as in relation to the input image
* sample frequency. The default value is 1, but higher values can be
* used to improve the results. This is cheaper than turning on
* ResampleToScreenPixels.
*/
vtkSetClampMacro(ImageSampleFactor, int, 1, 16);
vtkGetMacro(ImageSampleFactor, int);
//@}
//@{
/**
* Automatically reduce the rendering quality for greater speed
* when doing an interactive render. This is on by default.
*/
vtkSetMacro(AutoAdjustImageQuality, int);
vtkBooleanMacro(AutoAdjustImageQuality, int);
vtkGetMacro(AutoAdjustImageQuality, int);
//@}
//@{
/**
* Resample the image directly to the screen pixels, instead of
* using a texture to scale the image after resampling. This is
* slower and uses more memory, but provides high-quality results.
* It is On by default.
*/
vtkSetMacro(ResampleToScreenPixels, int);
vtkBooleanMacro(ResampleToScreenPixels, int);
vtkGetMacro(ResampleToScreenPixels, int);
//@}
//@{
/**
* Keep the color mapping stage distinct from the reslicing stage.
* This will improve the quality and possibly the speed of interactive
* window/level operations, but it uses more memory and might slow down
* interactive slicing operations. On by default.
*/
vtkSetMacro(SeparateWindowLevelOperation, int);
vtkBooleanMacro(SeparateWindowLevelOperation, int);
vtkGetMacro(SeparateWindowLevelOperation, int);
//@}
//@{
/**
* Set a custom interpolator. This will only be used if the
* ResampleToScreenPixels option is on.
*/
virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
virtual vtkAbstractImageInterpolator *GetInterpolator();
//@}
/**
* This should only be called by the renderer.
*/
void Render(vtkRenderer *renderer, vtkImageSlice *prop) override;
/**
* Release any graphics resources that are being consumed by
* this mapper. The parameter window is used to determine
* which graphic resources to release.
*/
void ReleaseGraphicsResources(vtkWindow *) override;
/**
* Get the mtime for the mapper.
*/
vtkMTimeType GetMTime() override;
//@{
/**
* The bounding box (array of six doubles) of the data expressed as
* (xmin,xmax, ymin,ymax, zmin,zmax).
*/
double *GetBounds() override;
void GetBounds(double bounds[6]) override
{ this->vtkAbstractMapper3D::GetBounds(bounds); };
//@}
/**
* Handle requests from the pipeline executive.
*/
int ProcessRequest(vtkInformation* request,
vtkInformationVector** inInfo,
vtkInformationVector* outInfo) override;
protected:
vtkImageResliceMapper();
~vtkImageResliceMapper() override;
/**
* Do a checkerboard pattern to the alpha of an RGBA image
*/
void CheckerboardImage(
vtkImageData *input, vtkCamera *camera, vtkImageProperty *property);
/**
* Update the slice-to-world matrix from the camera.
*/
void UpdateSliceToWorldMatrix(vtkCamera *camera);
/**
* Check if the vtkProp3D matrix has changed, and if so, set
* the WorldToDataMatrix to its inverse.
*/
void UpdateWorldToDataMatrix(vtkImageSlice *prop);
/**
* Update the reslice matrix, which is the slice-to-data matrix.
*/
void UpdateResliceMatrix(vtkRenderer *ren, vtkImageSlice *prop);
/**
* Set all of the reslicing parameters. This requires that
* the SliceToWorld and WorldToData matrices are up-to-date.
*/
void UpdateResliceInformation(vtkRenderer *ren);
/**
* Set the interpolation.
*/
void UpdateResliceInterpolation(vtkImageProperty *property);
/**
* Update anything related to the image coloring.
*/
void UpdateColorInformation(vtkImageProperty *property);
/**
* Make a polygon by cutting the data bounds with a plane.
*/
void UpdatePolygonCoords(vtkRenderer *ren);
//@{
/**
* Override Update to handle some tricky details.
*/
void Update(int port) override;
void Update() override;
int Update(int port, vtkInformationVector* requests) override;
int Update(vtkInformation* requests) override;
//@}
/**
* Garbage collection for reference loops.
*/
void ReportReferences(vtkGarbageCollector*) override;
vtkImageSliceMapper *SliceMapper; // Does the OpenGL rendering
int JumpToNearestSlice; // Adjust SliceAtFocalPoint
int AutoAdjustImageQuality; // LOD-style behavior
int SeparateWindowLevelOperation; // Do window/level as a separate step
double SlabThickness; // Current slab thickness
int SlabType; // Current slab mode
int SlabSampleFactor; // Sampling factor for slab mode
int ImageSampleFactor; // Sampling factor for image pixels
int ResampleToScreenPixels; // Use software interpolation only
int InternalResampleToScreenPixels; // Use software interpolation only
int ResliceNeedUpdate; // Execute reslice on next render
vtkImageResliceToColors *ImageReslice; // For software interpolation
vtkMatrix4x4 *ResliceMatrix; // Cached reslice matrix
vtkMatrix4x4 *WorldToDataMatrix; // World to Data transform matrix
vtkMatrix4x4 *SliceToWorldMatrix; // Slice to World transform matrix
vtkTimeStamp UpdateTime;
private:
vtkImageResliceMapper(const vtkImageResliceMapper&) = delete;
void operator=(const vtkImageResliceMapper&) = delete;
};
#endif