VTK
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----------------------------------------------------------------------------*/
48#ifndef vtkFastSplatter_h
49#define vtkFastSplatter_h
50
51#include "vtkImagingHybridModule.h" // For export macro
52#include "vtkImageAlgorithm.h"
53
54class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
55{
56public:
59 virtual void PrintSelf(ostream &os, vtkIndent indent);
60
62
68 vtkSetVector6Macro(ModelBounds,double);
69 vtkGetVectorMacro(ModelBounds,double,6);
71
73
76 vtkSetVector3Macro( OutputDimensions, int );
77 vtkGetVector3Macro( OutputDimensions, int );
79
80 enum { NoneLimit, ClampLimit, ScaleLimit, FreezeScaleLimit };
81
83
89 vtkSetMacro(LimitMode, int);
90 vtkGetMacro(LimitMode, int);
91 void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
92 void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
93 void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
94 void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
96
98
101 vtkSetMacro(MinValue, double);
102 vtkGetMacro(MinValue, double);
103 vtkSetMacro(MaxValue, double);
104 vtkGetMacro(MaxValue, double);
106
108
112 vtkGetMacro(NumberOfPointsSplatted, int);
114
121
122protected:
125
126 double ModelBounds[6];
127 int OutputDimensions[3];
128
130 double MinValue;
131 double MaxValue;
133
135
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 &) VTK_DELETE_FUNCTION;
163 void operator=(const vtkFastSplatter &) VTK_DELETE_FUNCTION;
164};
165
166//-----------------------------------------------------------------------------
167
168template<class T>
169void vtkFastSplatterClamp(T *array, vtkIdType arraySize,
170 T minValue, T maxValue)
171{
172 for (vtkIdType i = 0; i < arraySize; i++)
173 {
174 if (array[i] < minValue) array[i] = minValue;
175 if (array[i] > maxValue) array[i] = maxValue;
176 }
177}
178
179//-----------------------------------------------------------------------------
180
181template<class T>
182void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples,
183 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) min = *a;
200 if (max < *a) max = *a;
201 }
202
203 // Bias everything so that 0 is really the minimum.
204 if (min != 0)
205 {
206 for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
207 {
208 *a -= min;
209 }
210 }
211
212 // Scale the values.
213 if (max != min)
214 {
215 for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
216 {
217 *a = ((maxValue-minValue)*(*a))/(max-min);
218 }
219 }
220
221 // Bias everything again so that it lies in the correct range.
222 if (minValue != 0)
223 {
224 for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
225 {
226 *a += minValue;
227 }
228 }
229 if (c == 0)
230 {
231 *dataMinValue = min;
232 *dataMaxValue = max;
233 }
234 }
235}
236
237
238//-----------------------------------------------------------------------------
239
240template<class T>
242 int numComponents, vtkIdType numTuples,
243 T minValue, T maxValue,
244 double min, double max)
245{
246 T *a;
247
248 vtkIdType t;
249 for (int c = 0; c < numComponents; c++)
250 {
251 // Bias everything so that 0 is really the minimum.
252 if (min != 0)
253 {
254 for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
255 {
256 *a -= static_cast<T>(min);
257 }
258 }
259
260 // Scale the values.
261 if (max != min)
262 {
263 for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
264 {
265 *a = static_cast<T>(((maxValue-minValue)*(*a))/(max-min));
266 }
267 }
268
269 // Bias everything again so that it lies in the correct range.
270 if (minValue != 0)
271 {
272 for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
273 {
274 *a += minValue;
275 }
276 }
277 }
278}
279
280#endif //vtkFastSplatter_h
Proxy object to connect input/output ports.
A splatter optimized for splatting single kernels.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called in response to a REQUEST_DATA request from the executive.
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkImageData * Buckets
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
void SetLimitModeToFreezeScale()
void SetLimitModeToNone()
void SetLimitModeToClamp()
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to collect information from their inputs and set information f...
virtual ~vtkFastSplatter()
static vtkFastSplatter * New()
void SetSplatConnection(vtkAlgorithmOutput *)
Convenience function for connecting the splat algorithm source.
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
void SetLimitModeToScale()
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
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)
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287
#define max(a, b)