File: vtkVolumeRayCastSpaceLeapingImageFilter.h

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 118,972 kB
  • sloc: cpp: 1,442,790; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 68; objc: 17
file content (240 lines) | stat: -rw-r--r-- 9,835 bytes parent folder | download | duplicates (4)
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
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkFixedPointVolumeRayCastMapper.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.

=========================================================================*/
// .NAME vtkVolumeRayCastSpaceLeapingImageFilter - Builds the space leaping data structure.
// .SECTION Description
// This is an optimized multi-threaded imaging filter that builds the space
// leaping datastructure, used by vtkFixedPointVolumeRayCastMapper. Empty
// space leaping is used to skip large empty regions in the scalar
// opacity and/or the gradient opacity transfer functions. Depending on
// the various options set by vtkFixedPointVolumeRayCastMapper, the class
// will internally invoke one of the many optmized routines to compute the
// min/max/gradient-max values within a fixed block size, trying to
// compute everything in a single multi-threaded pass through the data
//
// The block size may be changed at compile time. Its ifdef'ed to 4 in the CXX
// file.

#ifndef vtkVolumeRayCastSpaceLeapingImageFilter_h
#define vtkVolumeRayCastSpaceLeapingImageFilter_h

#include "vtkRenderingVolumeModule.h" // For export macro
#include "vtkThreadedImageAlgorithm.h"

class vtkDataArray;

class VTKRENDERINGVOLUME_EXPORT vtkVolumeRayCastSpaceLeapingImageFilter : public vtkThreadedImageAlgorithm
{
public:
  vtkTypeMacro(vtkVolumeRayCastSpaceLeapingImageFilter,vtkThreadedImageAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  static vtkVolumeRayCastSpaceLeapingImageFilter *New();

  // Description:
  // Set the scalars.
  virtual void SetCurrentScalars( vtkDataArray * );
  vtkGetObjectMacro( CurrentScalars, vtkDataArray );

  // Description:
  // Do we use independent components, or dependent components ?
  vtkSetMacro( IndependentComponents, int );
  vtkGetMacro( IndependentComponents, int );

  // Description:
  // Compute gradient opacity ?
  vtkSetMacro( ComputeGradientOpacity, int );
  vtkGetMacro( ComputeGradientOpacity, int );
  vtkBooleanMacro( ComputeGradientOpacity, int );

  // Description:
  // Compute the min max structure ?.
  vtkSetMacro( ComputeMinMax, int );
  vtkGetMacro( ComputeMinMax, int );
  vtkBooleanMacro( ComputeMinMax, int );

  // Description:
  // Update the gradient opacity flags. (The scalar opacity flags are always
  // updated upon execution of this filter.)
  vtkSetMacro( UpdateGradientOpacityFlags, int );
  vtkGetMacro( UpdateGradientOpacityFlags, int );
  vtkBooleanMacro( UpdateGradientOpacityFlags, int );

  // Description:
  // Get the last execution time. This is updated every
  // time the scalars or the gradient opacity values are computed
  unsigned long GetLastMinMaxBuildTime()
    { return LastMinMaxBuildTime.GetMTime(); }

  // Description:
  // Get the last execution time. This is updated every time the flags bits
  // are re-computed.
  unsigned long GetLastMinMaxFlagTime()
    { return LastMinMaxFlagTime.GetMTime(); }

  // Description:
  // Is the difference between max and min of the data less than 32768? If so,
  // and if the data is not of float/double type, use a simple offset mapping.
  // If the difference between max and min is 32768 or greater, or the data
  // is of type float or double, we must use an offset / scaling mapping.
  // In this case, the array size will be 32768 - we need to figure out the
  // offset and scale factor.
  vtkSetVector4Macro( TableShift, float );
  vtkGetVector4Macro( TableShift, float );
  vtkSetVector4Macro( TableScale, float );
  vtkGetVector4Macro( TableScale, float );
  vtkSetVector4Macro( TableSize,  int   );
  vtkGetVector4Macro( TableSize,  int   );

  // Description:
  // Get the number of independent components for which we need to keep track
  // of min/max
  int GetNumberOfIndependentComponents();

  // Description:
  // Get the raw pointer to the final computed space leaping datastructure.
  // The result is only valid after Update() has been called on the filter.
  // Note that this filter holds onto its memory. The dimensions of the min-
  // max volume are in dims. The 4th value in the array indicates the number
  // of independent components, (also queried via
  // GetNumberOfIndependentComponents())
  unsigned short * GetMinMaxVolume( int dims[4] );

  // Description:
  // INTERNAL - Do not use
  // Set the last cached min-max volume, as used by
  // vtkFixedPointVolumeRayCastMapper.
  virtual void SetCache(vtkImageData * imageCache);

  // Description:
  // Compute the extents and dimensions of the input that's required to
  // generate an output min-max structure given by outExt.
  // INTERNAL - Do not use
  static void ComputeInputExtentsForOutput( int inExt[6],
      int inDim[3], int outExt[6], vtkImageData *inData );

  // Description:
  // Get the first non-zero scalar opacity and gradient opacity indices for
  // each independent copmonent
  // INTERNAL - Do not use.
  unsigned short * GetMinNonZeroScalarIndex();
  unsigned char  * GetMinNonZeroGradientMagnitudeIndex();

  //BTX
  // Description:
  // Pointer to the pre-computed gradient magnitude structure. This is pre-
  // computed by the vtkFixedPointVolumeRayCastMapper class. This should be
  // set if one has the ComputeGradientOpacity flag enabled.
  void SetGradientMagnitude( unsigned char ** gradientMagnitude );
  unsigned char **GetGradientMagnitude();

  // Description:
  // Set the scalar opacity and gradient opacity tables computed for each
  // component by the vtkFixedPointVolumeRayCastMapper
  void SetScalarOpacityTable( int c, unsigned short * t);
  void SetGradientOpacityTable( int c, unsigned short * t );
  //ETX

  // Description:
  // INTERNAL - Do not use
  // Compute the offset within an image of whole extents wholeExt, to access
  // the data starting at extents ext.
  vtkIdType ComputeOffset(const int ext[6], const int wholeExt[6],
      int nComponents);

  //BTX
  // This method helps debug. It writes out a specific component of the
  // computed min-max-volume structure
  //static void WriteMinMaxVolume( int component, unsigned short *minMaxVolume,
  //                           int minMaxVolumeSize[4], const char *filename );
  //ETX

protected:
  vtkVolumeRayCastSpaceLeapingImageFilter();
  ~vtkVolumeRayCastSpaceLeapingImageFilter();

  int               IndependentComponents;
  vtkTimeStamp      LastMinMaxBuildTime;
  vtkTimeStamp      LastMinMaxFlagTime;
  vtkDataArray   *  CurrentScalars;
  float             TableShift[4];
  float             TableScale[4];
  int               TableSize[4];
  int               ComputeGradientOpacity;
  int               ComputeMinMax;
  int               UpdateGradientOpacityFlags;
  unsigned short *  MinNonZeroScalarIndex;
  unsigned char  *  MinNonZeroGradientMagnitudeIndex;
  unsigned char  ** GradientMagnitude;
  unsigned short  * ScalarOpacityTable[4];
  unsigned short  * GradientOpacityTable[4];
  vtkImageData    * Cache;


  void InternalRequestUpdateExtent(int *, int*);

  // Description:
  // See superclass for details
  virtual int RequestUpdateExtent(vtkInformation *,
                                  vtkInformationVector **,
                                  vtkInformationVector *);
  void ThreadedRequestData(       vtkInformation *request,
                                  vtkInformationVector **inputVector,
                                  vtkInformationVector *outputVector,
                                  vtkImageData ***inData,
                                  vtkImageData **outData,
                                  int outExt[6], int id);
  virtual int RequestData(        vtkInformation* request,
                                  vtkInformationVector** inputVector,
                                  vtkInformationVector* outputVector);
  virtual int RequestInformation( vtkInformation *,
                                  vtkInformationVector**,
                                  vtkInformationVector *);

  // Description:
  // Compute the first non-zero scalar opacity and gradient opacity values
  // that are encountered when marching from the beginning of the transfer
  // function tables.
  void ComputeFirstNonZeroOpacityIndices();

  // Description:
  // Fill the flags after processing the min/max/gradient structure. This
  // optimized version is invoked when only scalar opacity table is needed.
  void FillScalarOpacityFlags(
      vtkImageData *minMaxVolume, int outExt[6] );

  // Description:
  // Fill the flags after processing the min/max/gradient structure. This
  // optimized version is invoked when both scalar and gradient opacity
  // tables need to be visited.
  void FillScalarAndGradientOpacityFlags(
      vtkImageData *minMaxVolume, int outExt[6] );

  // Description:
  // Allocate the output data. If we have a cache with the same metadata as
  // the output we are going to generate, re-use the cache as we may not be
  // updating all data in the min-max structure.
  virtual void AllocateOutputData(vtkImageData *out,
                                  vtkInformation* outInfo,
                                  int *uExtent);
  virtual vtkImageData *AllocateOutputData(vtkDataObject *out,
                                           vtkInformation *outInfo);

private:
  vtkVolumeRayCastSpaceLeapingImageFilter(const vtkVolumeRayCastSpaceLeapingImageFilter&);  // Not implemented.
  void operator=(const vtkVolumeRayCastSpaceLeapingImageFilter&);  // Not implemented.
};

#endif