VTK  9.2.6
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 "vtkImageAlgorithm.h"
52 #include "vtkImagingHybridModule.h" // For export macro
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
81  {
85  FreezeScaleLimit
86  };
87 
89 
95  vtkSetMacro(LimitMode, int);
96  vtkGetMacro(LimitMode, int);
97  void SetLimitModeToNone() { this->SetLimitMode(NoneLimit); }
98  void SetLimitModeToClamp() { this->SetLimitMode(ClampLimit); }
99  void SetLimitModeToScale() { this->SetLimitMode(ScaleLimit); }
100  void SetLimitModeToFreezeScale() { this->SetLimitMode(FreezeScaleLimit); }
102 
104 
107  vtkSetMacro(MinValue, double);
108  vtkGetMacro(MinValue, double);
109  vtkSetMacro(MaxValue, double);
110  vtkGetMacro(MaxValue, double);
112 
114 
118  vtkGetMacro(NumberOfPointsSplatted, int);
120 
126  void SetSplatConnection(vtkAlgorithmOutput*);
127 
128 protected:
129  vtkFastSplatter();
130  ~vtkFastSplatter() override;
131 
132  double ModelBounds[6];
133  int OutputDimensions[3];
134 
136  double MinValue;
137  double MaxValue;
138  double FrozenScale;
139 
141 
142  int FillInputPortInformation(int port, vtkInformation* info) 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, T minValue, T maxValue)
170 {
171  for (vtkIdType i = 0; i < arraySize; i++)
172  {
173  if (array[i] < minValue)
174  array[i] = minValue;
175  if (array[i] > maxValue)
176  array[i] = maxValue;
177  }
178 }
179 
180 //-----------------------------------------------------------------------------
181 
182 template <class T>
183 void vtkFastSplatterScale(T* array, int numComponents, vtkIdType numTuples, 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)
200  min = *a;
201  if (max < *a)
202  max = *a;
203  }
204 
205  // Bias everything so that 0 is really the minimum.
206  if (min != 0)
207  {
208  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
209  {
210  *a -= min;
211  }
212  }
213 
214  // Scale the values.
215  if (max != min)
216  {
217  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
218  {
219  *a = ((maxValue - minValue) * (*a)) / (max - min);
220  }
221  }
222 
223  // Bias everything again so that it lies in the correct range.
224  if (minValue != 0)
225  {
226  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
227  {
228  *a += minValue;
229  }
230  }
231  if (c == 0)
232  {
233  *dataMinValue = min;
234  *dataMaxValue = max;
235  }
236  }
237 }
238 
239 //-----------------------------------------------------------------------------
240 
241 template <class T>
243  T* array, int numComponents, vtkIdType numTuples, T minValue, T maxValue, double min, double max)
244 {
245  T* a;
246 
247  vtkIdType t;
248  for (int c = 0; c < numComponents; c++)
249  {
250  // Bias everything so that 0 is really the minimum.
251  if (min != 0)
252  {
253  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
254  {
255  *a -= static_cast<T>(min);
256  }
257  }
258 
259  // Scale the values.
260  if (max != min)
261  {
262  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
263  {
264  *a = static_cast<T>(((maxValue - minValue) * (*a)) / (max - min));
265  }
266  }
267 
268  // Bias everything again so that it lies in the correct range.
269  if (minValue != 0)
270  {
271  for (t = 0, a = array + c; t < numTuples; t++, a += numComponents)
272  {
273  *a += minValue;
274  }
275  }
276  }
277 }
278 
279 #endif // vtkFastSplatter_h
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:332
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:53
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.