VTK  9.3.0
vtkImageMapper3D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkImageMapper3D_h
21 #define vtkImageMapper3D_h
22 
23 #include "vtkAbstractMapper3D.h"
24 #include "vtkRenderingCoreModule.h" // For export macro
25 #include "vtkThreads.h" // for VTK_MAX_THREADS
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkRenderer;
29 class vtkProp3D;
30 class vtkPoints;
31 class vtkMatrix4x4;
32 class vtkLookupTable;
33 class vtkScalarsToColors;
34 class vtkImageSlice;
35 class vtkImageProperty;
36 class vtkImageData;
37 class vtkMultiThreader;
38 class vtkImageToImageMapper3DFriendship;
39 
40 class VTKRENDERINGCORE_EXPORT vtkImageMapper3D : public vtkAbstractMapper3D
41 {
42 public:
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
49  virtual void Render(vtkRenderer* renderer, vtkImageSlice* prop) = 0;
50 
56  void ReleaseGraphicsResources(vtkWindow*) override = 0;
57 
59 
62  void SetInputData(vtkImageData* input);
67 
69 
75  vtkSetMacro(Border, vtkTypeBool);
76  vtkBooleanMacro(Border, vtkTypeBool);
77  vtkGetMacro(Border, vtkTypeBool);
79 
81 
87  vtkSetMacro(Background, vtkTypeBool);
88  vtkBooleanMacro(Background, vtkTypeBool);
89  vtkGetMacro(Background, vtkTypeBool);
91 
93 
98  vtkSetMacro(SliceAtFocalPoint, vtkTypeBool);
99  vtkBooleanMacro(SliceAtFocalPoint, vtkTypeBool);
100  vtkGetMacro(SliceAtFocalPoint, vtkTypeBool);
102 
104 
109  vtkSetMacro(SliceFacesCamera, vtkTypeBool);
110  vtkBooleanMacro(SliceFacesCamera, vtkTypeBool);
111  vtkGetMacro(SliceFacesCamera, vtkTypeBool);
113 
115 
122  vtkGetObjectMacro(SlicePlane, vtkPlane);
124 
130  virtual void GetSlicePlaneInDataCoords(vtkMatrix4x4* propMatrix, double plane[4]);
131 
133 
136  vtkSetClampMacro(NumberOfThreads, int, 1, VTK_MAX_THREADS);
137  vtkGetMacro(NumberOfThreads, int);
139 
141 
150  vtkSetMacro(Streaming, vtkTypeBool);
151  vtkGetMacro(Streaming, vtkTypeBool);
152  vtkBooleanMacro(Streaming, vtkTypeBool);
154 
155  // return the bounds in index space
156  virtual void GetIndexBounds(double extent[6]) = 0;
157 
158 protected:
160  ~vtkImageMapper3D() override;
161 
163 
169 
174  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo) override;
175 
180  static void CheckerboardRGBA(unsigned char* data, int xsize, int ysize, double originx,
181  double originy, double spacingx, double spacingy);
182 
188  unsigned char* MakeTextureData(vtkImageProperty* property, vtkImageData* input, int extent[6],
189  int& xsize, int& ysize, int& bytesPerPixel, bool& reuseTexture, bool& reuseData);
190 
195  void MakeTextureGeometry(const int extent[6], double coords[12], double tcoords[8]);
196 
204  virtual void ComputeTextureSize(
205  const int extent[6], int& xdim, int& ydim, int imageSize[2], int textureSize[2]);
206 
212 
216  vtkImageSlice* GetCurrentProp() { return this->CurrentProp; }
217 
223 
228  void GetBackgroundColor(vtkImageProperty* property, double color[4]);
229 
236 
237  // The slice.
241 
242  // Information about the image, updated by UpdateInformation
243  double DataSpacing[3];
244  double DataOrigin[3];
245  double DataDirection[9];
246  int DataWholeExtent[6];
247 
248  // Set by vtkImageStack when doing multi-pass rendering
252 
253 private:
254  // The prop this mapper is attached to, or zero if none.
255  vtkImageSlice* CurrentProp;
256  vtkRenderer* CurrentRenderer;
257 
258  // The cached data-to-world matrix
259  vtkMatrix4x4* DataToWorldMatrix;
260 
261  vtkImageMapper3D(const vtkImageMapper3D&) = delete;
262  void operator=(const vtkImageMapper3D&) = delete;
263 
264  friend class vtkImageToImageMapper3DFriendship;
265 };
266 
267 VTK_ABI_NAMESPACE_END
268 #endif
abstract class specifies interface to map 3D data
general representation of visualization data
Definition: vtkDataObject.h:55
abstract class to specify dataset behavior
Definition: vtkDataSet.h:53
topologically and geometrically regular array of data
Definition: vtkImageData.h:43
abstract class for mapping images to the screen
virtual void GetSlicePlaneInDataCoords(vtkMatrix4x4 *propMatrix, double plane[4])
Get the plane as a homogeneous 4-vector that gives the plane equation coefficients.
virtual void ComputeTextureSize(const int extent[6], int &xdim, int &ydim, int imageSize[2], int textureSize[2])
Given an extent that describes a slice (it must have unit thickness in one of the three directions),...
vtkDataObject * GetDataObjectInput()
The input data for this mapper.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static void CheckerboardRGBA(unsigned char *data, int xsize, int ysize, double originx, double originy, double spacingx, double spacingy)
Checkerboard the alpha component of an RGBA image.
vtkScalarsToColors * DefaultLookupTable
vtkMultiThreader * Threader
int FillOutputPortInformation(int port, vtkInformation *info) override
See algorithm for more info.
vtkTypeBool SliceFacesCamera
void GetBackgroundColor(vtkImageProperty *property, double color[4])
Get the background color, by using the first color in the supplied lookup table, or black if there is...
vtkMatrix4x4 * GetDataToWorldMatrix()
Get the data-to-world matrix for this mapper, according to the assembly path for its prop.
virtual void Render(vtkRenderer *renderer, vtkImageSlice *prop)=0
This should only be called by the renderer.
unsigned char * MakeTextureData(vtkImageProperty *property, vtkImageData *input, int extent[6], int &xsize, int &ysize, int &bytesPerPixel, bool &reuseTexture, bool &reuseData)
Perform window/level and color mapping operations to produce unsigned char data that can be used as a...
vtkDataSet * GetDataSetInput()
The input data for this mapper.
vtkTypeBool Background
virtual void GetIndexBounds(double extent[6])=0
void ReleaseGraphicsResources(vtkWindow *) override=0
Release any graphics resources that are being consumed by this mapper.
vtkImageData * GetInput()
The input data for this mapper.
void MakeTextureGeometry(const int extent[6], double coords[12], double tcoords[8])
Compute the coordinates and texture coordinates for the image, given an extent that describes a singl...
~vtkImageMapper3D() override
void SetInputData(vtkImageData *input)
The input data for this mapper.
vtkTypeBool Streaming
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo) override
Handle requests from the pipeline executive.
int FillInputPortInformation(int port, vtkInformation *info) override
See algorithm for more info.
vtkRenderer * GetCurrentRenderer()
Get the renderer associated with this mapper, or zero if none.
vtkImageSlice * GetCurrentProp()
Get the vtkImage prop associated with this mapper, or zero if none.
vtkTypeBool SliceAtFocalPoint
image display properties
represents an image in a 3D scene
Definition: vtkImageSlice.h:39
a simple class to control print indentation
Definition: vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
A class for performing multithreaded execution.
perform various plane computations
Definition: vtkPlane.h:26
represent and manipulate 3D points
Definition: vtkPoints.h:29
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:39
abstract specification for renderers
Definition: vtkRenderer.h:62
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
@ Background
Definition: vtkX3D.h:71
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
@ extent
Definition: vtkX3D.h:345
@ color
Definition: vtkX3D.h:221
@ data
Definition: vtkX3D.h:315
int vtkTypeBool
Definition: vtkABI.h:64