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----------------------------------------------------------------------------*/
47
48#ifndef vtkFastSplatter_h
49#define vtkFastSplatter_h
50
51#include "vtkImageAlgorithm.h"
52#include "vtkImagingHybridModule.h" // For export macro
53
54class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
55{
56public:
59 void PrintSelf(ostream& os, vtkIndent indent) override;
60
62
68 vtkSetVector6Macro(ModelBounds, double);
69 vtkGetVectorMacro(ModelBounds, double, 6);
71
73
76 vtkSetVector3Macro(OutputDimensions, int);
77 vtkGetVector3Macro(OutputDimensions, int);
79
80 enum
81 {
86 };
87
89
95 vtkSetMacro(LimitMode, int);
96 vtkGetMacro(LimitMode, int);
102
104
107 vtkSetMacro(MinValue, double);
108 vtkGetMacro(MinValue, double);
109 vtkSetMacro(MaxValue, double);
110 vtkGetMacro(MaxValue, double);
112
114
118 vtkGetMacro(NumberOfPointsSplatted, int);
120
127
128protected:
131
132 double ModelBounds[6];
134
136 double MinValue;
137 double MaxValue;
139
141
142 int FillInputPortInformation(int port, vtkInformation* info) override;
146
147 // Used internally for converting points in world space to indices in
148 // the output image.
149 double Origin[3];
150 double Spacing[3];
151
152 // This is updated every time the filter executes
154
155 // Used internally to track the data range. When the limit mode is
156 // set to FreezeScale, the data will be scaled as if this were the
157 // range regardless of what it actually is.
160
161private:
162 vtkFastSplatter(const vtkFastSplatter&) = delete;
163 void operator=(const vtkFastSplatter&) = delete;
164};
165
166//-----------------------------------------------------------------------------
167
168template <class T>
169void vtkFastSplatterClamp(T* array, vtkIdType arraySize, T minValue, T maxValue)
170{
171 for (vtkIdType i = 0; i < arraySize; i++)
172 {
173 if (array[i] < minValue)
174 array[i] = minValue;
175 if (array[i] > maxValue)
176 array[i] = maxValue;
177 }
178}
179
180//-----------------------------------------------------------------------------
181
182template <class T>
183void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue,
184 double* dataMinValue, double* dataMaxValue)
185{
186 T* a;
187 T min, max;
188 *dataMinValue = 0;
189 *dataMaxValue = 0;
190 vtkIdType t;
191 for (int c = 0; c < numComponents; c++)
192 {
193 // Find the min and max values in the array.
194 a = array + c;
195 min = max = *a;
196 a += numComponents;
197 for (t = 1; t < numTuples; t++, a += numComponents)
198 {
199 if (min > *a)
200 min = *a;
201 if (max < *a)
202 max = *a;
203 }
204
205 // Bias everything so that 0 is really the minimum.
206 if (min != 0)
207 {
208 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
209 {
210 *a -= min;
211 }
212 }
213
214 // Scale the values.
215 if (max != min)
216 {
217 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
218 {
219 *a = ((maxValue - minValue) * (*a)) / (max - min);
220 }
221 }
222
223 // Bias everything again so that it lies in the correct range.
224 if (minValue != 0)
225 {
226 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
227 {
228 *a += minValue;
229 }
230 }
231 if (c == 0)
232 {
233 *dataMinValue = min;
234 *dataMaxValue = max;
235 }
236 }
237}
238
239//-----------------------------------------------------------------------------
240
241template <class T>
243 T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
244{
245 T* a;
246
247 vtkIdType t;
248 for (int c = 0; c < numComponents; c++)
249 {
250 // Bias everything so that 0 is really the minimum.
251 if (min != 0)
252 {
253 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
254 {
255 *a -= static_cast<T>(min);
256 }
257 }
258
259 // Scale the values.
260 if (max != min)
261 {
262 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
263 {
264 *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
265 }
266 }
267
268 // Bias everything again so that it lies in the correct range.
269 if (minValue != 0)
270 {
271 for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
272 {
273 *a += minValue;
274 }
275 }
276 }
277}
278
279#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:40
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)