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 ----------------------------------------------------------------------------*/
47 #ifndef __vtkFastSplatter_h
48 #define __vtkFastSplatter_h
49 
50 #include "vtkImageAlgorithm.h"
51 
53 {
54 public:
56  static vtkFastSplatter *New();
57  virtual void PrintSelf(ostream &os, vtkIndent indent);
58 
60 
64  vtkSetVector6Macro(ModelBounds,double);
65  vtkGetVectorMacro(ModelBounds,double,6);
67 
69 
70  vtkSetVector3Macro( OutputDimensions, int );
71  vtkGetVector3Macro( OutputDimensions, int );
73 
74 //BTX
75  enum { NoneLimit, ClampLimit, ScaleLimit, FreezeScaleLimit };
76 //ETX
77 
79 
84  vtkSetMacro(LimitMode, int);
85  vtkGetMacro(LimitMode, int);
86  void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
87  void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
88  void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
89  void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
91 
93 
94  vtkSetMacro(MinValue, double);
95  vtkGetMacro(MinValue, double);
96  vtkSetMacro(MaxValue, double);
97  vtkGetMacro(MaxValue, double);
99 
101 
103  vtkGetMacro(NumberOfPointsSplatted, int);
105 
109  void SetSplatConnection(vtkAlgorithmOutput*);
110 
111 protected:
112  vtkFastSplatter();
113  virtual ~vtkFastSplatter();
114 
115  double ModelBounds[6];
116  int OutputDimensions[3];
117 
119  double MinValue;
120  double MaxValue;
121  double FrozenScale;
122 
124 
126  virtual int RequestInformation(vtkInformation *,
129  virtual int RequestUpdateExtent(vtkInformation*,
132  virtual int RequestData(vtkInformation *,
135 
136  // Used internally for converting points in world space to indices in
137  // the output image.
138  double Origin[3];
139  double Spacing[3];
140 
141  // This is updated every time the filter executes
143 
144  // Used internally to track the data range. When the limit mode is
145  // set to FreezeScale, the data will be scaled as if this were the
146  // range regardless of what it actually is.
149 
150 private:
151  vtkFastSplatter(const vtkFastSplatter &); // Not implemented
152  void operator=(const vtkFastSplatter &); // Not implemented
153 };
154 
155 //BTX
156 
157 //-----------------------------------------------------------------------------
158 
159 template<class T>
160 void vtkFastSplatterClamp(T *array, vtkIdType arraySize,
161  T minValue, T maxValue)
162 {
163  for (vtkIdType i = 0; i < arraySize; i++)
164  {
165  if (array[i] < minValue) array[i] = minValue;
166  if (array[i] > maxValue) array[i] = maxValue;
167  }
168 }
169 
170 //-----------------------------------------------------------------------------
171 
172 template<class T>
173 void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples,
174  T minValue, T maxValue,
175  double *dataMinValue, double *dataMaxValue)
176 {
177  T *a;
178  T min, max;
179  *dataMinValue = 0;
180  *dataMaxValue = 0;
181  vtkIdType t;
182  for (int c = 0; c < numComponents; c++)
183  {
184  // Find the min and max values in the array.
185  a = array+c;
186  min = max = *a;
187  a += numComponents;
188  for (t = 1; t < numTuples; t++, a += numComponents)
189  {
190  if (min > *a) min = *a;
191  if (max < *a) max = *a;
192  }
193 
194  // Bias everything so that 0 is really the minimum.
195  if (min != 0)
196  {
197  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
198  {
199  *a -= min;
200  }
201  }
202 
203  // Scale the values.
204  if (max != min)
205  {
206  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
207  {
208  *a = ((maxValue-minValue)*(*a))/(max-min);
209  }
210  }
211 
212  // Bias everything again so that it lies in the correct range.
213  if (minValue != 0)
214  {
215  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
216  {
217  *a += minValue;
218  }
219  }
220  if (c == 0)
221  {
222  *dataMinValue = min;
223  *dataMaxValue = max;
224  }
225  }
226 }
227 
228 
229 //-----------------------------------------------------------------------------
230 
231 template<class T>
233  int numComponents, vtkIdType numTuples,
234  T minValue, T maxValue,
235  double min, double max)
236 {
237  T *a;
238 
239  vtkIdType t;
240  for (int c = 0; c < numComponents; c++)
241  {
242  // Bias everything so that 0 is really the minimum.
243  if (min != 0)
244  {
245  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
246  {
247  *a -= static_cast<T>(min);
248  }
249  }
250 
251  // Scale the values.
252  if (max != min)
253  {
254  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
255  {
256  *a = static_cast<T>(((maxValue-minValue)*(*a))/(max-min));
257  }
258  }
259 
260  // Bias everything again so that it lies in the correct range.
261  if (minValue != 0)
262  {
263  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
264  {
265  *a += minValue;
266  }
267  }
268  }
269 }
270 
271 //ETX
272 
273 #endif //__vtkFastSplatter_h
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:255
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Proxy object to connect input/output ports.
A splatter optimized for splatting single kernels.
void SetLimitModeToNone()
a simple class to control print indentation
Definition: vtkIndent.h:37
#define VTK_IMAGING_EXPORT
topologically and geometrically regular array of data
Definition: vtkImageData.h:43
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
void vtkFastSplatterFrozenScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
virtual int FillInputPortInformation(int port, vtkInformation *info)
void SetLimitModeToScale()
Generic algorithm superclass for image algs.
vtkImageData * Buckets
Store zero or more vtkInformation instances.
void PrintSelf(ostream &os, vtkIndent indent)
static vtkAlgorithm * New()
void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double *dataMinValue, double *dataMaxValue)
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
void vtkFastSplatterClamp(T *array, vtkIdType arraySize, T minValue, T maxValue)
void SetLimitModeToFreezeScale()
#define max(a, b)
void SetLimitModeToClamp()