VTK  9.2.6
vtkFastSplatter.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkFastSplatter.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15/*----------------------------------------------------------------------------
16 Copyright (c) Sandia Corporation
17 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18----------------------------------------------------------------------------*/
57#ifndef vtkFastSplatter_h
58#define vtkFastSplatter_h
59
60#include "vtkImageAlgorithm.h"
61#include "vtkImagingHybridModule.h" // For export macro
62
63class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
64{
65public:
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
71
77 vtkSetVector6Macro(ModelBounds, double);
78 vtkGetVectorMacro(ModelBounds, double, 6);
80
82
85 vtkSetVector3Macro(OutputDimensions, int);
86 vtkGetVector3Macro(OutputDimensions, int);
88
89 enum
90 {
94 FreezeScaleLimit
95 };
96
98
104 vtkSetMacro(LimitMode, int);
105 vtkGetMacro(LimitMode, int);
106 void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
107 void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
108 void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
109 void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
111
113
116 vtkSetMacro(MinValue, double);
117 vtkGetMacro(MinValue, double);
118 vtkSetMacro(MaxValue, double);
119 vtkGetMacro(MaxValue, double);
121
123
127 vtkGetMacro(NumberOfPointsSplatted, int);
129
136
137protected:
140
141 double ModelBounds[6];
142 int OutputDimensions[3];
143
145 double MinValue;
146 double MaxValue;
148
150
151 int FillInputPortInformation(int port, vtkInformation* info) override;
155
156 // Used internally for converting points in world space to indices in
157 // the output image.
158 double Origin[3];
159 double Spacing[3];
160
161 // This is updated every time the filter executes
163
164 // Used internally to track the data range. When the limit mode is
165 // set to FreezeScale, the data will be scaled as if this were the
166 // range regardless of what it actually is.
169
170private:
171 vtkFastSplatter(const vtkFastSplatter&) = delete;
172 void operator=(const vtkFastSplatter&) = delete;
173};
174
175//-----------------------------------------------------------------------------
176
177template <class T>
178void vtkFastSplatterClamp(T* array, vtkIdType arraySize, T minValue, T maxValue)
179{
180 for (vtkIdType i = 0; i < arraySize; i++)
181 {
182 if (array[i] < minValue)
183 array[i] = minValue;
184 if (array[i] > maxValue)
185 array[i] = maxValue;
186 }
187}
188
189//-----------------------------------------------------------------------------
190
191template <class T>
192void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue,
193 double* dataMinValue, double* dataMaxValue)
194{
195 T* a;
196 T min, max;
197 *dataMinValue = 0;
198 *dataMaxValue = 0;
199 vtkIdType t;
200 for (int c = 0; c < numComponents; c++)
201 {
202 // Find the min and max values in the array.
203 a = array + c;
204 min = max = *a;
205 a += numComponents;
206 for (t = 1; t < numTuples; t++, a += numComponents)
207 {
208 if (min > *a)
209 min = *a;
210 if (max < *a)
211 max = *a;
212 }
213
214 // Bias everything so that 0 is really the minimum.
215 if (min != 0)
216 {
217 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
218 {
219 *a -= min;
220 }
221 }
222
223 // Scale the values.
224 if (max != min)
225 {
226 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
227 {
228 *a = ((maxValue - minValue) * (*a)) / (max - min);
229 }
230 }
231
232 // Bias everything again so that it lies in the correct range.
233 if (minValue != 0)
234 {
235 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
236 {
237 *a += minValue;
238 }
239 }
240 if (c == 0)
241 {
242 *dataMinValue = min;
243 *dataMaxValue = max;
244 }
245 }
246}
247
248//-----------------------------------------------------------------------------
249
250template <class T>
252 T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
253{
254 T* a;
255
256 vtkIdType t;
257 for (int c = 0; c < numComponents; c++)
258 {
259 // Bias everything so that 0 is really the minimum.
260 if (min != 0)
261 {
262 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
263 {
264 *a -= static_cast<T>(min);
265 }
266 }
267
268 // Scale the values.
269 if (max != min)
270 {
271 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
272 {
273 *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
274 }
275 }
276
277 // Bias everything again so that it lies in the correct range.
278 if (minValue != 0)
279 {
280 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
281 {
282 *a += minValue;
283 }
284 }
285 }
286}
287
288#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:49
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:332
#define max(a, b)