VTK  9.7.1
vtkFastSplatter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
33 #ifndef vtkFastSplatter_h
34 #define vtkFastSplatter_h
35 
36 #include "vtkImageAlgorithm.h"
37 #include "vtkImagingHybridModule.h" // For export macro
38 
39 VTK_ABI_NAMESPACE_BEGIN
40 class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
41 {
42 public:
44  static vtkFastSplatter* New();
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48 
54  vtkSetVector6Macro(ModelBounds, double);
55  vtkGetVectorMacro(ModelBounds, double, 6);
57 
59 
62  vtkSetVector3Macro(OutputDimensions, int);
63  vtkGetVector3Macro(OutputDimensions, int);
65 
66  enum
67  {
71  FreezeScaleLimit
72  };
73 
75 
81  vtkSetMacro(LimitMode, int);
82  vtkGetMacro(LimitMode, int);
83  void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
84  void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
85  void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
86  void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
88 
90 
93  vtkSetMacro(MinValue, double);
94  vtkGetMacro(MinValue, double);
95  vtkSetMacro(MaxValue, double);
96  vtkGetMacro(MaxValue, double);
98 
100 
104  vtkGetMacro(NumberOfPointsSplatted, int);
106 
112  void SetSplatConnection(vtkAlgorithmOutput*);
113 
114 protected:
115  vtkFastSplatter();
116  ~vtkFastSplatter() override;
117 
118  double ModelBounds[6];
119  int OutputDimensions[3];
120 
122  double MinValue;
123  double MaxValue;
124  double FrozenScale;
125 
127 
128  int FillInputPortInformation(int port, vtkInformation* info) override;
132 
133  // Used internally for converting points in world space to indices in
134  // the output image.
135  double Origin[3];
136  double Spacing[3];
137 
138  // This is updated every time the filter executes
140 
141  // Used internally to track the data range. When the limit mode is
142  // set to FreezeScale, the data will be scaled as if this were the
143  // range regardless of what it actually is.
146 
147 private:
148  vtkFastSplatter(const vtkFastSplatter&) = delete;
149  void operator=(const vtkFastSplatter&) = delete;
150 };
151 
152 //-----------------------------------------------------------------------------
153 
154 template <class T>
155 VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterClampWorker instead")
156 void vtkFastSplatterClamp(T* array, vtkIdType arraySize, T minValue, T maxValue)
157 {
158  for (vtkIdType i = 0; i < arraySize; i++)
159  {
160  if (array[i] < minValue)
161  array[i] = minValue;
162  if (array[i] > maxValue)
163  array[i] = maxValue;
164  }
165 }
166 
167 //-----------------------------------------------------------------------------
168 
169 template <class T>
170 VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterScaleWorker instead")
171 void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue,
172  double* dataMinValue, double* dataMaxValue)
173 {
174  T* a;
175  T min, max;
176  *dataMinValue = 0;
177  *dataMaxValue = 0;
178  vtkIdType t;
179  for (int c = 0; c < numComponents; c++)
180  {
181  // Find the min and max values in the array.
182  a = array + c;
183  min = max = *a;
184  a += numComponents;
185  for (t = 1; t < numTuples; t++, a += numComponents)
186  {
187  if (min > *a)
188  min = *a;
189  if (max < *a)
190  max = *a;
191  }
192 
193  // Bias everything so that 0 is really the minimum.
194  if (min != 0)
195  {
196  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
197  {
198  *a -= min;
199  }
200  }
201 
202  // Scale the values.
203  if (max != min)
204  {
205  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
206  {
207  *a = ((maxValue - minValue) * (*a)) / (max - min);
208  }
209  }
210 
211  // Bias everything again so that it lies in the correct range.
212  if (minValue != 0)
213  {
214  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
215  {
216  *a += minValue;
217  }
218  }
219  if (c == 0)
220  {
221  *dataMinValue = min;
222  *dataMaxValue = max;
223  }
224  }
225 }
226 
227 //-----------------------------------------------------------------------------
228 
229 template <class T>
230 VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterFrozenScaleWorker instead")
232  T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
233 {
234  T* a;
235 
236  vtkIdType t;
237  for (int c = 0; c < numComponents; c++)
238  {
239  // Bias everything so that 0 is really the minimum.
240  if (min != 0)
241  {
242  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
243  {
244  *a -= static_cast<T>(min);
245  }
246  }
247 
248  // Scale the values.
249  if (max != min)
250  {
251  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
252  {
253  *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
254  }
255  }
256 
257  // Bias everything again so that it lies in the correct range.
258  if (minValue != 0)
259  {
260  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
261  {
262  *a += minValue;
263  }
264  }
265  }
266 }
267 
268 VTK_ABI_NAMESPACE_END
269 #endif // vtkFastSplatter_h
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:363
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
Proxy object to connect input/output ports.
#define VTK_DEPRECATED_IN_9_6_0(reason)
A splatter optimized for splatting single kernels.
void SetLimitModeToNone()
Set/get the way voxel values will be limited.
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
void vtkFastSplatterFrozenScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
void SetLimitModeToScale()
Set/get the way voxel values will be limited.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
Generic algorithm superclass for image algs.
vtkImageData * Buckets
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double *dataMinValue, double *dataMaxValue)
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
void vtkFastSplatterClamp(T *array, vtkIdType arraySize, T minValue, T maxValue)
void SetLimitModeToFreezeScale()
Set/get the way voxel values will be limited.
#define max(a, b)
void SetLimitModeToClamp()
Set/get the way voxel values will be limited.