VTK  9.6.20260111
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
51
52#ifndef vtkFastSplatter_h
53#define vtkFastSplatter_h
54
55#include "vtkImageAlgorithm.h"
56#include "vtkImagingHybridModule.h" // For export macro
57
58VTK_ABI_NAMESPACE_BEGIN
59class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
60{
61public:
64 void PrintSelf(ostream& os, vtkIndent indent) override;
65
67
73 vtkSetVector6Macro(ModelBounds, double);
74 vtkGetVectorMacro(ModelBounds, double, 6);
76
78
81 vtkSetVector3Macro(OutputDimensions, int);
82 vtkGetVector3Macro(OutputDimensions, int);
84
85 enum
86 {
91 };
92
94
100 vtkSetMacro(LimitMode, int);
101 vtkGetMacro(LimitMode, int);
107
109
112 vtkSetMacro(MinValue, double);
113 vtkGetMacro(MinValue, double);
114 vtkSetMacro(MaxValue, double);
115 vtkGetMacro(MaxValue, double);
117
119
123 vtkGetMacro(NumberOfPointsSplatted, int);
125
132
133protected:
136
137 double ModelBounds[6];
139
141 double MinValue;
142 double MaxValue;
144
146
147 int FillInputPortInformation(int port, vtkInformation* info) override;
151
152 // Used internally for converting points in world space to indices in
153 // the output image.
154 double Origin[3];
155 double Spacing[3];
156
157 // This is updated every time the filter executes
159
160 // Used internally to track the data range. When the limit mode is
161 // set to FreezeScale, the data will be scaled as if this were the
162 // range regardless of what it actually is.
165
166private:
167 vtkFastSplatter(const vtkFastSplatter&) = delete;
168 void operator=(const vtkFastSplatter&) = delete;
169};
170
171//-----------------------------------------------------------------------------
172
173template <class T>
174VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterClampWorker instead")
175void vtkFastSplatterClamp(T* array, vtkIdType arraySize, T minValue, T maxValue)
176{
177 for (vtkIdType i = 0; i < arraySize; i++)
178 {
179 if (array[i] < minValue)
180 array[i] = minValue;
181 if (array[i] > maxValue)
182 array[i] = maxValue;
183 }
184}
185
186//-----------------------------------------------------------------------------
187
188template <class T>
189VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterScaleWorker instead")
190void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue,
191 double* dataMinValue, double* dataMaxValue)
192{
193 T* a;
194 T min, max;
195 *dataMinValue = 0;
196 *dataMaxValue = 0;
197 vtkIdType t;
198 for (int c = 0; c < numComponents; c++)
199 {
200 // Find the min and max values in the array.
201 a = array + c;
202 min = max = *a;
203 a += numComponents;
204 for (t = 1; t < numTuples; t++, a += numComponents)
205 {
206 if (min > *a)
207 min = *a;
208 if (max < *a)
209 max = *a;
210 }
211
212 // Bias everything so that 0 is really the minimum.
213 if (min != 0)
214 {
215 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
216 {
217 *a -= min;
218 }
219 }
220
221 // Scale the values.
222 if (max != min)
223 {
224 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
225 {
226 *a = ((maxValue - minValue) * (*a)) / (max - min);
227 }
228 }
229
230 // Bias everything again so that it lies in the correct range.
231 if (minValue != 0)
232 {
233 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
234 {
235 *a += minValue;
236 }
237 }
238 if (c == 0)
239 {
240 *dataMinValue = min;
241 *dataMaxValue = max;
242 }
243 }
244}
245
246//-----------------------------------------------------------------------------
247
248template <class T>
249VTK_DEPRECATED_IN_9_6_0("Use vtkArrayDispatch and vtkFastSplatterFrozenScaleWorker instead")
251 T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
252{
253 T* a;
254
255 vtkIdType t;
256 for (int c = 0; c < numComponents; c++)
257 {
258 // Bias everything so that 0 is really the minimum.
259 if (min != 0)
260 {
261 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
262 {
263 *a -= static_cast<T>(min);
264 }
265 }
266
267 // Scale the values.
268 if (max != min)
269 {
270 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
271 {
272 *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
273 }
274 }
275
276 // Bias everything again so that it lies in the correct range.
277 if (minValue != 0)
278 {
279 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
280 {
281 *a += minValue;
282 }
283 }
284 }
285}
286
287VTK_ABI_NAMESPACE_END
288#endif // vtkFastSplatter_h
Proxy object to connect input/output ports.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
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:108
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)