VTK  9.6.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
32
33#ifndef vtkFastSplatter_h
34#define vtkFastSplatter_h
35
36#include "vtkImageAlgorithm.h"
37#include "vtkImagingHybridModule.h" // For export macro
38
39VTK_ABI_NAMESPACE_BEGIN
40class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
41{
42public:
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 {
72 };
73
75
81 vtkSetMacro(LimitMode, int);
82 vtkGetMacro(LimitMode, int);
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
113
114protected:
117
118 double ModelBounds[6];
120
122 double MinValue;
123 double MaxValue;
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
147private:
148 vtkFastSplatter(const vtkFastSplatter&) = delete;
149 void operator=(const vtkFastSplatter&) = delete;
150};
151
152//-----------------------------------------------------------------------------
153
154template <class T>
155VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterClampWorker instead")
156void 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
169template <class T>
170VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterScaleWorker instead")
171void 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
229template <class T>
230VTK_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
268VTK_ABI_NAMESPACE_END
269#endif // vtkFastSplatter_h
Proxy object to connect input/output ports.
int FillInputPortInformation(int port, vtkInformation *info) override
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to translate the update extent requests from each output port ...
vtkImageData * Buckets
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetLimitModeToFreezeScale()
Set/get the way voxel values will be limited.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
void SetLimitModeToNone()
Set/get the way voxel values will be limited.
virtual void SetLimitMode(int)
Set/get the way voxel values will be limited.
void SetLimitModeToClamp()
Set/get the way voxel values will be limited.
static vtkFastSplatter * New()
void SetSplatConnection(vtkAlgorithmOutput *)
Convenience function for connecting the splat algorithm source.
void SetLimitModeToScale()
Set/get the way voxel values will be limited.
~vtkFastSplatter() override
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
#define VTK_DEPRECATED_IN_9_6_0(reason)
void vtkFastSplatterClamp(T *array, vtkIdType arraySize, T minValue, T maxValue)
void vtkFastSplatterFrozenScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double *dataMinValue, double *dataMaxValue)
int vtkIdType
Definition vtkType.h:368
#define max(a, b)