VTK  9.3.0
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
42#ifndef vtkFastSplatter_h
43#define vtkFastSplatter_h
44
45#include "vtkImageAlgorithm.h"
46#include "vtkImagingHybridModule.h" // For export macro
47
48VTK_ABI_NAMESPACE_BEGIN
49class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
50{
51public:
54 void PrintSelf(ostream& os, vtkIndent indent) override;
55
57
63 vtkSetVector6Macro(ModelBounds, double);
64 vtkGetVectorMacro(ModelBounds, double, 6);
66
68
71 vtkSetVector3Macro(OutputDimensions, int);
72 vtkGetVector3Macro(OutputDimensions, int);
74
75 enum
76 {
80 FreezeScaleLimit
81 };
82
84
90 vtkSetMacro(LimitMode, int);
91 vtkGetMacro(LimitMode, int);
92 void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
93 void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
94 void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
95 void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
97
99
102 vtkSetMacro(MinValue, double);
103 vtkGetMacro(MinValue, double);
104 vtkSetMacro(MaxValue, double);
105 vtkGetMacro(MaxValue, double);
107
109
113 vtkGetMacro(NumberOfPointsSplatted, int);
115
122
123protected:
126
127 double ModelBounds[6];
128 int OutputDimensions[3];
129
131 double MinValue;
132 double MaxValue;
134
136
137 int FillInputPortInformation(int port, vtkInformation* info) override;
141
142 // Used internally for converting points in world space to indices in
143 // the output image.
144 double Origin[3];
145 double Spacing[3];
146
147 // This is updated every time the filter executes
149
150 // Used internally to track the data range. When the limit mode is
151 // set to FreezeScale, the data will be scaled as if this were the
152 // range regardless of what it actually is.
155
156private:
157 vtkFastSplatter(const vtkFastSplatter&) = delete;
158 void operator=(const vtkFastSplatter&) = delete;
159};
160
161//-----------------------------------------------------------------------------
162
163template <class T>
164void vtkFastSplatterClamp(T* array, vtkIdType arraySize, T minValue, T maxValue)
165{
166 for (vtkIdType i = 0; i < arraySize; i++)
167 {
168 if (array[i] < minValue)
169 array[i] = minValue;
170 if (array[i] > maxValue)
171 array[i] = maxValue;
172 }
173}
174
175//-----------------------------------------------------------------------------
176
177template <class T>
178void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue,
179 double* dataMinValue, double* dataMaxValue)
180{
181 T* a;
182 T min, max;
183 *dataMinValue = 0;
184 *dataMaxValue = 0;
185 vtkIdType t;
186 for (int c = 0; c < numComponents; c++)
187 {
188 // Find the min and max values in the array.
189 a = array + c;
190 min = max = *a;
191 a += numComponents;
192 for (t = 1; t < numTuples; t++, a += numComponents)
193 {
194 if (min > *a)
195 min = *a;
196 if (max < *a)
197 max = *a;
198 }
199
200 // Bias everything so that 0 is really the minimum.
201 if (min != 0)
202 {
203 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
204 {
205 *a -= min;
206 }
207 }
208
209 // Scale the values.
210 if (max != min)
211 {
212 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
213 {
214 *a = ((maxValue - minValue) * (*a)) / (max - min);
215 }
216 }
217
218 // Bias everything again so that it lies in the correct range.
219 if (minValue != 0)
220 {
221 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
222 {
223 *a += minValue;
224 }
225 }
226 if (c == 0)
227 {
228 *dataMinValue = min;
229 *dataMaxValue = max;
230 }
231 }
232}
233
234//-----------------------------------------------------------------------------
235
236template <class T>
238 T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
239{
240 T* a;
241
242 vtkIdType t;
243 for (int c = 0; c < numComponents; c++)
244 {
245 // Bias everything so that 0 is really the minimum.
246 if (min != 0)
247 {
248 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
249 {
250 *a -= static_cast<T>(min);
251 }
252 }
253
254 // Scale the values.
255 if (max != min)
256 {
257 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
258 {
259 *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
260 }
261 }
262
263 // Bias everything again so that it lies in the correct range.
264 if (minValue != 0)
265 {
266 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
267 {
268 *a += minValue;
269 }
270 }
271 }
272}
273
274VTK_ABI_NAMESPACE_END
275#endif // vtkFastSplatter_h
Proxy object to connect input/output ports.
A splatter optimized for splatting single kernels.
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.
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...
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
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:315
#define max(a, b)