VTK  9.1.0
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----------------------------------------------------------------------------*/
54#ifndef vtkFastSplatter_h
55#define vtkFastSplatter_h
56
57#include "vtkImageAlgorithm.h"
58#include "vtkImagingHybridModule.h" // For export macro
59
60class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
61{
62public:
65 void PrintSelf(ostream& os, vtkIndent indent) override;
66
68
74 vtkSetVector6Macro(ModelBounds, double);
75 vtkGetVectorMacro(ModelBounds, double, 6);
77
79
82 vtkSetVector3Macro(OutputDimensions, int);
83 vtkGetVector3Macro(OutputDimensions, int);
85
86 enum
87 {
91 FreezeScaleLimit
92 };
93
95
101 vtkSetMacro(LimitMode, int);
102 vtkGetMacro(LimitMode, int);
103 void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
104 void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
105 void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
106 void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
108
110
113 vtkSetMacro(MinValue, double);
114 vtkGetMacro(MinValue, double);
115 vtkSetMacro(MaxValue, double);
116 vtkGetMacro(MaxValue, double);
118
120
124 vtkGetMacro(NumberOfPointsSplatted, int);
126
133
134protected:
137
138 double ModelBounds[6];
139 int OutputDimensions[3];
140
142 double MinValue;
143 double MaxValue;
145
147
152
153 // Used internally for converting points in world space to indices in
154 // the output image.
155 double Origin[3];
156 double Spacing[3];
157
158 // This is updated every time the filter executes
160
161 // Used internally to track the data range. When the limit mode is
162 // set to FreezeScale, the data will be scaled as if this were the
163 // range regardless of what it actually is.
166
167private:
168 vtkFastSplatter(const vtkFastSplatter&) = delete;
169 void operator=(const vtkFastSplatter&) = delete;
170};
171
172//-----------------------------------------------------------------------------
173
174template <class T>
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>
189void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue,
190 double* dataMinValue, double* dataMaxValue)
191{
192 T* a;
193 T min, max;
194 *dataMinValue = 0;
195 *dataMaxValue = 0;
196 vtkIdType t;
197 for (int c = 0; c < numComponents; c++)
198 {
199 // Find the min and max values in the array.
200 a = array + c;
201 min = max = *a;
202 a += numComponents;
203 for (t = 1; t < numTuples; t++, a += numComponents)
204 {
205 if (min > *a)
206 min = *a;
207 if (max < *a)
208 max = *a;
209 }
210
211 // Bias everything so that 0 is really the minimum.
212 if (min != 0)
213 {
214 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
215 {
216 *a -= min;
217 }
218 }
219
220 // Scale the values.
221 if (max != min)
222 {
223 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
224 {
225 *a = ((maxValue - minValue) * (*a)) / (max - min);
226 }
227 }
228
229 // Bias everything again so that it lies in the correct range.
230 if (minValue != 0)
231 {
232 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
233 {
234 *a += minValue;
235 }
236 }
237 if (c == 0)
238 {
239 *dataMinValue = min;
240 *dataMaxValue = max;
241 }
242 }
243}
244
245//-----------------------------------------------------------------------------
246
247template <class T>
249 T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
250{
251 T* a;
252
253 vtkIdType t;
254 for (int c = 0; c < numComponents; c++)
255 {
256 // Bias everything so that 0 is really the minimum.
257 if (min != 0)
258 {
259 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
260 {
261 *a -= static_cast<T>(min);
262 }
263 }
264
265 // Scale the values.
266 if (max != min)
267 {
268 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
269 {
270 *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
271 }
272 }
273
274 // Bias everything again so that it lies in the correct range.
275 if (minValue != 0)
276 {
277 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
278 {
279 *a += minValue;
280 }
281 }
282 }
283}
284
285#endif // vtkFastSplatter_h
Proxy object to connect input/output ports.
A splatter optimized for splatting single kernels.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
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
Definition: vtkImageData.h:57
a simple class to control print indentation
Definition: vtkIndent.h:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
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)