VTK  9.2.6
vtkGaussianSplatter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGaussianSplatter.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 =========================================================================*/
79 #ifndef vtkGaussianSplatter_h
80 #define vtkGaussianSplatter_h
81 
82 #include "vtkImageAlgorithm.h"
83 #include "vtkImagingHybridModule.h" // For export macro
84 
85 #include <cmath> // for std::exp
86 
87 #define VTK_ACCUMULATION_MODE_MIN 0
88 #define VTK_ACCUMULATION_MODE_MAX 1
89 #define VTK_ACCUMULATION_MODE_SUM 2
90 
91 class vtkDoubleArray;
93 class vtkGaussianSplatterAlgorithm;
94 
95 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
96 {
97 public:
99  void PrintSelf(ostream& os, vtkIndent indent) override;
100 
106  static vtkGaussianSplatter* New();
107 
109 
113  void SetSampleDimensions(int i, int j, int k);
114  void SetSampleDimensions(int dim[3]);
115  vtkGetVectorMacro(SampleDimensions, int, 3);
117 
119 
125  vtkSetVector6Macro(ModelBounds, double);
126  vtkGetVectorMacro(ModelBounds, double, 6);
128 
130 
135  vtkSetClampMacro(Radius, double, 0.0, 1.0);
136  vtkGetMacro(Radius, double);
138 
140 
145  vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
146  vtkGetMacro(ScaleFactor, double);
148 
150 
155  vtkSetMacro(ExponentFactor, double);
156  vtkGetMacro(ExponentFactor, double);
158 
160 
165  vtkSetMacro(NormalWarping, vtkTypeBool);
166  vtkGetMacro(NormalWarping, vtkTypeBool);
167  vtkBooleanMacro(NormalWarping, vtkTypeBool);
169 
171 
178  vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
179  vtkGetMacro(Eccentricity, double);
181 
183 
186  vtkSetMacro(ScalarWarping, vtkTypeBool);
187  vtkGetMacro(ScalarWarping, vtkTypeBool);
188  vtkBooleanMacro(ScalarWarping, vtkTypeBool);
190 
192 
197  vtkSetMacro(Capping, vtkTypeBool);
198  vtkGetMacro(Capping, vtkTypeBool);
199  vtkBooleanMacro(Capping, vtkTypeBool);
201 
203 
207  vtkSetMacro(CapValue, double);
208  vtkGetMacro(CapValue, double);
210 
212 
218  vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
219  vtkGetMacro(AccumulationMode, int);
220  void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
221  void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
222  void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
223  const char* GetAccumulationModeAsString();
225 
227 
231  vtkSetMacro(NullValue, double);
232  vtkGetMacro(NullValue, double);
234 
236 
240  void ComputeModelBounds(vtkDataSet* input, vtkImageData* output, vtkInformation* outInfo);
241  void ComputeModelBounds(
242  vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
244 
246 
251  friend class vtkGaussianSplatterAlgorithm;
252  double SamplePoint(double x[3]) // for compilers who can't handle this
253  {
254  return (this->*Sample)(x);
255  }
256  void SetScalar(vtkIdType idx, double dist2, double* sPtr)
257  {
258  double v = (this->*SampleFactor)(this->S) *
259  std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
261 
262  if (!this->Visited[idx])
263  {
264  this->Visited[idx] = 1;
265  *sPtr = v;
266  }
267  else
268  {
269  switch (this->AccumulationMode)
270  {
272  if (*sPtr > v)
273  {
274  *sPtr = v;
275  }
276  break;
278  if (*sPtr < v)
279  {
280  *sPtr = v;
281  }
282  break;
284  *sPtr += v;
285  break;
286  }
287  } // not first visit
288  }
289 
290 protected:
292  ~vtkGaussianSplatter() override = default;
293 
294  int FillInputPortInformation(int port, vtkInformation* info) override;
297  void Cap(vtkDoubleArray* s);
298 
299  int SampleDimensions[3]; // dimensions of volume to splat into
300  double Radius; // maximum distance splat propagates (as fraction 0->1)
301  double ExponentFactor; // scale exponent of gaussian function
302  double ModelBounds[6]; // bounding box of splatting dimensions
303  vtkTypeBool NormalWarping; // on/off warping of splat via normal
304  double Eccentricity; // elliptic distortion due to normals
305  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
306  double ScaleFactor; // splat size influenced by scale factor
307  vtkTypeBool Capping; // Cap side of volume to close surfaces
308  double CapValue; // value to use for capping
309  int AccumulationMode; // how to combine scalar values
310 
311  double Gaussian(double x[3]);
312  double EccentricGaussian(double x[3]);
313  double ScalarSampling(double s) { return this->ScaleFactor * s; }
314  double PositionSampling(double) { return this->ScaleFactor; }
315 
316 private:
317  double Radius2;
318  double (vtkGaussianSplatter::*Sample)(double x[3]);
319  double (vtkGaussianSplatter::*SampleFactor)(double s);
320  char* Visited;
321  double Eccentricity2;
322  double* P;
323  double* N;
324  double S;
325  double Origin[3];
326  double Spacing[3];
327  double SplatDistance[3];
328  double NullValue;
329 
330 private:
331  vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
332  void operator=(const vtkGaussianSplatter&) = delete;
333 };
334 
335 #endif
void SetAccumulationModeToMin()
Specify the scalar accumulation mode.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
#define VTK_ACCUMULATION_MODE_MAX
int vtkIdType
Definition: vtkType.h:332
void SetAccumulationModeToMax()
Specify the scalar accumulation mode.
splat points into a volume with an elliptical, Gaussian distribution
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:69
abstract superclass for composite (multi-block or AMR) datasets
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...
double PositionSampling(double)
#define VTK_ACCUMULATION_MODE_SUM
void SetAccumulationModeToSum()
Specify the scalar accumulation mode.
void SetScalar(vtkIdType idx, double dist2, double *sPtr)
Provide access to templated helper class.
#define VTK_ACCUMULATION_MODE_MIN
double SamplePoint(double x[3])
Provide access to templated helper class.
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.
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.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
double ScalarSampling(double s)