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 "vtkImagingHybridModule.h" // For export macro
51 #include "vtkImageAlgorithm.h"
52 
54 {
55 public:
57  static vtkFastSplatter *New();
58  virtual void PrintSelf(ostream &os, vtkIndent indent);
59 
61 
65  vtkSetVector6Macro(ModelBounds,double);
66  vtkGetVectorMacro(ModelBounds,double,6);
68 
70 
71  vtkSetVector3Macro( OutputDimensions, int );
72  vtkGetVector3Macro( OutputDimensions, int );
74 
75 //BTX
76  enum { NoneLimit, ClampLimit, ScaleLimit, FreezeScaleLimit };
77 //ETX
78 
80 
85  vtkSetMacro(LimitMode, int);
86  vtkGetMacro(LimitMode, int);
87  void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
88  void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
89  void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
90  void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
92 
94 
95  vtkSetMacro(MinValue, double);
96  vtkGetMacro(MinValue, double);
97  vtkSetMacro(MaxValue, double);
98  vtkGetMacro(MaxValue, double);
100 
102 
104  vtkGetMacro(NumberOfPointsSplatted, int);
106 
110  void SetSplatConnection(vtkAlgorithmOutput*);
111 
112 protected:
113  vtkFastSplatter();
114  virtual ~vtkFastSplatter();
115 
116  double ModelBounds[6];
117  int OutputDimensions[3];
118 
120  double MinValue;
121  double MaxValue;
122  double FrozenScale;
123 
125 
127  virtual int RequestInformation(vtkInformation *,
130  virtual int RequestUpdateExtent(vtkInformation*,
133  virtual int RequestData(vtkInformation *,
136 
137  // Used internally for converting points in world space to indices in
138  // the output image.
139  double Origin[3];
140  double Spacing[3];
141 
142  // This is updated every time the filter executes
144 
145  // Used internally to track the data range. When the limit mode is
146  // set to FreezeScale, the data will be scaled as if this were the
147  // range regardless of what it actually is.
150 
151 private:
152  vtkFastSplatter(const vtkFastSplatter &); // Not implemented
153  void operator=(const vtkFastSplatter &); // Not implemented
154 };
155 
156 //BTX
157 
158 //-----------------------------------------------------------------------------
159 
160 template<class T>
161 void vtkFastSplatterClamp(T *array, vtkIdType arraySize,
162  T minValue, T maxValue)
163 {
164  for (vtkIdType i = 0; i < arraySize; i++)
165  {
166  if (array[i] < minValue) array[i] = minValue;
167  if (array[i] > maxValue) array[i] = maxValue;
168  }
169 }
170 
171 //-----------------------------------------------------------------------------
172 
173 template<class T>
174 void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples,
175  T minValue, T maxValue,
176  double *dataMinValue, double *dataMaxValue)
177 {
178  T *a;
179  T min, max;
180  *dataMinValue = 0;
181  *dataMaxValue = 0;
182  vtkIdType t;
183  for (int c = 0; c < numComponents; c++)
184  {
185  // Find the min and max values in the array.
186  a = array+c;
187  min = max = *a;
188  a += numComponents;
189  for (t = 1; t < numTuples; t++, a += numComponents)
190  {
191  if (min > *a) min = *a;
192  if (max < *a) max = *a;
193  }
194 
195  // Bias everything so that 0 is really the minimum.
196  if (min != 0)
197  {
198  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
199  {
200  *a -= min;
201  }
202  }
203 
204  // Scale the values.
205  if (max != min)
206  {
207  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
208  {
209  *a = ((maxValue-minValue)*(*a))/(max-min);
210  }
211  }
212 
213  // Bias everything again so that it lies in the correct range.
214  if (minValue != 0)
215  {
216  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
217  {
218  *a += minValue;
219  }
220  }
221  if (c == 0)
222  {
223  *dataMinValue = min;
224  *dataMaxValue = max;
225  }
226  }
227 }
228 
229 
230 //-----------------------------------------------------------------------------
231 
232 template<class T>
234  int numComponents, vtkIdType numTuples,
235  T minValue, T maxValue,
236  double min, double max)
237 {
238  T *a;
239 
240  vtkIdType t;
241  for (int c = 0; c < numComponents; c++)
242  {
243  // Bias everything so that 0 is really the minimum.
244  if (min != 0)
245  {
246  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
247  {
248  *a -= static_cast<T>(min);
249  }
250  }
251 
252  // Scale the values.
253  if (max != min)
254  {
255  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
256  {
257  *a = static_cast<T>(((maxValue-minValue)*(*a))/(max-min));
258  }
259  }
260 
261  // Bias everything again so that it lies in the correct range.
262  if (minValue != 0)
263  {
264  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
265  {
266  *a += minValue;
267  }
268  }
269  }
270 }
271 
272 //ETX
273 
274 #endif //vtkFastSplatter_h
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:247
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:38
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
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()
#define VTKIMAGINGHYBRID_EXPORT
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()