VTK  9.0.1
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 "vtkImageAlgorithm.h"
49 #include "vtkImagingHybridModule.h" // For export macro
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
78  {
82  FreezeScaleLimit
83  };
84 
86 
92  vtkSetMacro(LimitMode, int);
93  vtkGetMacro(LimitMode, int);
94  void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
95  void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
96  void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
97  void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
99 
101 
104  vtkSetMacro(MinValue, double);
105  vtkGetMacro(MinValue, double);
106  vtkSetMacro(MaxValue, double);
107  vtkGetMacro(MaxValue, double);
109 
111 
115  vtkGetMacro(NumberOfPointsSplatted, int);
117 
123  void SetSplatConnection(vtkAlgorithmOutput*);
124 
125 protected:
126  vtkFastSplatter();
127  ~vtkFastSplatter() override;
128 
129  double ModelBounds[6];
130  int OutputDimensions[3];
131 
133  double MinValue;
134  double MaxValue;
135  double FrozenScale;
136 
138 
139  int FillInputPortInformation(int port, vtkInformation* info) 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, T minValue, T maxValue)
167 {
168  for (vtkIdType i = 0; i < arraySize; i++)
169  {
170  if (array[i] < minValue)
171  array[i] = minValue;
172  if (array[i] > maxValue)
173  array[i] = maxValue;
174  }
175 }
176 
177 //-----------------------------------------------------------------------------
178 
179 template <class T>
180 void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, 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)
197  min = *a;
198  if (max < *a)
199  max = *a;
200  }
201 
202  // Bias everything so that 0 is really the minimum.
203  if (min != 0)
204  {
205  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
206  {
207  *a -= min;
208  }
209  }
210 
211  // Scale the values.
212  if (max != min)
213  {
214  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
215  {
216  *a = ((maxValue - minValue) * (*a)) / (max - min);
217  }
218  }
219 
220  // Bias everything again so that it lies in the correct range.
221  if (minValue != 0)
222  {
223  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
224  {
225  *a += minValue;
226  }
227  }
228  if (c == 0)
229  {
230  *dataMinValue = min;
231  *dataMaxValue = max;
232  }
233  }
234 }
235 
236 //-----------------------------------------------------------------------------
237 
238 template <class T>
240  T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
241 {
242  T* a;
243 
244  vtkIdType t;
245  for (int c = 0; c < numComponents; c++)
246  {
247  // Bias everything so that 0 is really the minimum.
248  if (min != 0)
249  {
250  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
251  {
252  *a -= static_cast<T>(min);
253  }
254  }
255 
256  // Scale the values.
257  if (max != min)
258  {
259  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
260  {
261  *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
262  }
263  }
264 
265  // Bias everything again so that it lies in the correct range.
266  if (minValue != 0)
267  {
268  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
269  {
270  *a += minValue;
271  }
272  }
273  }
274 }
275 
276 #endif // vtkFastSplatter_h
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:338
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:33
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
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.