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 ----------------------------------------------------------------------------*/
45 #ifndef vtkFastSplatter_h
46 #define vtkFastSplatter_h
47 
48 #include "vtkImagingHybridModule.h" // For export macro
49 #include "vtkImageAlgorithm.h"
50 
51 class VTKIMAGINGHYBRID_EXPORT vtkFastSplatter : public vtkImageAlgorithm
52 {
53 public:
55  static vtkFastSplatter *New();
56  void PrintSelf(ostream &os, vtkIndent indent) override;
57 
59 
65  vtkSetVector6Macro(ModelBounds,double);
66  vtkGetVectorMacro(ModelBounds,double,6);
68 
70 
73  vtkSetVector3Macro( OutputDimensions, int );
74  vtkGetVector3Macro( OutputDimensions, int );
76 
77  enum { NoneLimit, ClampLimit, ScaleLimit, FreezeScaleLimit };
78 
80 
86  vtkSetMacro(LimitMode, int);
87  vtkGetMacro(LimitMode, int);
88  void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
89  void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
90  void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
91  void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
93 
95 
98  vtkSetMacro(MinValue, double);
99  vtkGetMacro(MinValue, double);
100  vtkSetMacro(MaxValue, double);
101  vtkGetMacro(MaxValue, double);
103 
105 
109  vtkGetMacro(NumberOfPointsSplatted, int);
111 
117  void SetSplatConnection(vtkAlgorithmOutput*);
118 
119 protected:
120  vtkFastSplatter();
121  ~vtkFastSplatter() override;
122 
123  double ModelBounds[6];
124  int OutputDimensions[3];
125 
127  double MinValue;
128  double MaxValue;
129  double FrozenScale;
130 
132 
133  int FillInputPortInformation(int port, vtkInformation *info) override;
136  vtkInformationVector *) override;
139  vtkInformationVector*) override;
142  vtkInformationVector *) override;
143 
144  // Used internally for converting points in world space to indices in
145  // the output image.
146  double Origin[3];
147  double Spacing[3];
148 
149  // This is updated every time the filter executes
151 
152  // Used internally to track the data range. When the limit mode is
153  // set to FreezeScale, the data will be scaled as if this were the
154  // range regardless of what it actually is.
157 
158 private:
159  vtkFastSplatter(const vtkFastSplatter &) = delete;
160  void operator=(const vtkFastSplatter &) = delete;
161 };
162 
163 //-----------------------------------------------------------------------------
164 
165 template<class T>
166 void vtkFastSplatterClamp(T *array, vtkIdType arraySize,
167  T minValue, T maxValue)
168 {
169  for (vtkIdType i = 0; i < arraySize; i++)
170  {
171  if (array[i] < minValue) array[i] = minValue;
172  if (array[i] > maxValue) array[i] = maxValue;
173  }
174 }
175 
176 //-----------------------------------------------------------------------------
177 
178 template<class T>
179 void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples,
180  T minValue, T maxValue,
181  double *dataMinValue, double *dataMaxValue)
182 {
183  T *a;
184  T min, max;
185  *dataMinValue = 0;
186  *dataMaxValue = 0;
187  vtkIdType t;
188  for (int c = 0; c < numComponents; c++)
189  {
190  // Find the min and max values in the array.
191  a = array+c;
192  min = max = *a;
193  a += numComponents;
194  for (t = 1; t < numTuples; t++, a += numComponents)
195  {
196  if (min > *a) min = *a;
197  if (max < *a) max = *a;
198  }
199 
200  // Bias everything so that 0 is really the minimum.
201  if (min != 0)
202  {
203  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
204  {
205  *a -= min;
206  }
207  }
208 
209  // Scale the values.
210  if (max != min)
211  {
212  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
213  {
214  *a = ((maxValue-minValue)*(*a))/(max-min);
215  }
216  }
217 
218  // Bias everything again so that it lies in the correct range.
219  if (minValue != 0)
220  {
221  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
222  {
223  *a += minValue;
224  }
225  }
226  if (c == 0)
227  {
228  *dataMinValue = min;
229  *dataMaxValue = max;
230  }
231  }
232 }
233 
234 
235 //-----------------------------------------------------------------------------
236 
237 template<class T>
239  int numComponents, vtkIdType numTuples,
240  T minValue, T maxValue,
241  double min, double max)
242 {
243  T *a;
244 
245  vtkIdType t;
246  for (int c = 0; c < numComponents; c++)
247  {
248  // Bias everything so that 0 is really the minimum.
249  if (min != 0)
250  {
251  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
252  {
253  *a -= static_cast<T>(min);
254  }
255  }
256 
257  // Scale the values.
258  if (max != min)
259  {
260  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
261  {
262  *a = static_cast<T>(((maxValue-minValue)*(*a))/(max-min));
263  }
264  }
265 
266  // Bias everything again so that it lies in the correct range.
267  if (minValue != 0)
268  {
269  for (t = 0, a = array+c; t < numTuples; t++, a += numComponents)
270  {
271  *a += minValue;
272  }
273  }
274  }
275 }
276 
277 #endif //vtkFastSplatter_h
vtkImageAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
vtkFastSplatter::MaxValue
double MaxValue
Definition: vtkFastSplatter.h:128
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkImageAlgorithm.h
vtkFastSplatter::LastDataMaxValue
double LastDataMaxValue
Definition: vtkFastSplatter.h:156
vtkFastSplatter::FrozenScale
double FrozenScale
Definition: vtkFastSplatter.h:129
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:37
vtkFastSplatter::NumberOfPointsSplatted
int NumberOfPointsSplatted
Definition: vtkFastSplatter.h:150
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkFastSplatter::SetLimitModeToNone
void SetLimitModeToNone()
Definition: vtkFastSplatter.h:88
vtkFastSplatterFrozenScale
void vtkFastSplatterFrozenScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
Definition: vtkFastSplatter.h:238
vtkX3D::port
Definition: vtkX3D.h:447
vtkFastSplatterScale
void vtkFastSplatterScale(T *array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double *dataMinValue, double *dataMaxValue)
Definition: vtkFastSplatter.h:179
vtkFastSplatter::Buckets
vtkImageData * Buckets
Definition: vtkFastSplatter.h:131
vtkImageAlgorithm::RequestUpdateExtent
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkFastSplatter::LastDataMinValue
double LastDataMinValue
Definition: vtkFastSplatter.h:155
vtkFastSplatter
A splatter optimized for splatting single kernels.
Definition: vtkFastSplatter.h:51
vtkFastSplatterClamp
void vtkFastSplatterClamp(T *array, vtkIdType arraySize, T minValue, T maxValue)
Definition: vtkFastSplatter.h:166
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkX3D::info
Definition: vtkX3D.h:376
vtkImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkFastSplatter::SetLimitModeToFreezeScale
void SetLimitModeToFreezeScale()
Definition: vtkFastSplatter.h:91
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:36
vtkFastSplatter::MinValue
double MinValue
Definition: vtkFastSplatter.h:127
vtkImageAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkFastSplatter::SetLimitModeToScale
void SetLimitModeToScale()
Definition: vtkFastSplatter.h:90
vtkFastSplatter::SetLimitModeToClamp
void SetLimitModeToClamp()
Definition: vtkFastSplatter.h:89
vtkFastSplatter::LimitMode
int LimitMode
Definition: vtkFastSplatter.h:126
vtkFastSplatter::ScaleLimit
Definition: vtkFastSplatter.h:77