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 
54 class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
55 {
56 public:
58  static vtkFastSplatter *New();
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 { 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 
120  void SetSplatConnection(vtkAlgorithmOutput*);
121 
122 protected:
123  vtkFastSplatter();
124  ~vtkFastSplatter() override;
125 
126  double ModelBounds[6];
127  int OutputDimensions[3];
128 
130  double MinValue;
131  double MaxValue;
132  double FrozenScale;
133 
135 
136  int FillInputPortInformation(int port, vtkInformation *info) override;
139  vtkInformationVector *) override;
142  vtkInformationVector*) override;
145  vtkInformationVector *) 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 
161 private:
162  vtkFastSplatter(const vtkFastSplatter &) = delete;
163  void operator=(const vtkFastSplatter &) = delete;
164 };
165 
166 //-----------------------------------------------------------------------------
167 
168 template<class T>
169 void 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 
181 template<class T>
182 void 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 
240 template<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
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:347
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
Proxy object to connect input/output ports.
A splatter optimized for splatting single kernels.
void SetLimitModeToNone()
Set/get the way voxel values will be limited.
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
void vtkFastSplatterFrozenScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
void SetLimitModeToScale()
Set/get the way voxel values will be limited.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
Generic algorithm superclass for image algs.
vtkImageData * Buckets
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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)
This is called in response to a REQUEST_DATA request from the executive.
void vtkFastSplatterClamp(T *array, vtkIdType arraySize, T minValue, T maxValue)
void SetLimitModeToFreezeScale()
Set/get the way voxel values will be limited.
#define max(a, b)
void SetLimitModeToClamp()
Set/get the way voxel values will be limited.