VTK  9.1.0
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 =========================================================================*/
73 #ifndef vtkGaussianSplatter_h
74 #define vtkGaussianSplatter_h
75 
76 #include "vtkImageAlgorithm.h"
77 #include "vtkImagingHybridModule.h" // For export macro
78 
79 #include <cmath> // for std::exp
80 
81 #define VTK_ACCUMULATION_MODE_MIN 0
82 #define VTK_ACCUMULATION_MODE_MAX 1
83 #define VTK_ACCUMULATION_MODE_SUM 2
84 
85 class vtkDoubleArray;
87 class vtkGaussianSplatterAlgorithm;
88 
89 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
90 {
91 public:
93  void PrintSelf(ostream& os, vtkIndent indent) override;
94 
101 
103 
107  void SetSampleDimensions(int i, int j, int k);
108  void SetSampleDimensions(int dim[3]);
109  vtkGetVectorMacro(SampleDimensions, int, 3);
111 
113 
119  vtkSetVector6Macro(ModelBounds, double);
120  vtkGetVectorMacro(ModelBounds, double, 6);
122 
124 
129  vtkSetClampMacro(Radius, double, 0.0, 1.0);
130  vtkGetMacro(Radius, double);
132 
134 
139  vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
140  vtkGetMacro(ScaleFactor, double);
142 
144 
149  vtkSetMacro(ExponentFactor, double);
150  vtkGetMacro(ExponentFactor, double);
152 
154 
159  vtkSetMacro(NormalWarping, vtkTypeBool);
160  vtkGetMacro(NormalWarping, vtkTypeBool);
161  vtkBooleanMacro(NormalWarping, vtkTypeBool);
163 
165 
172  vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
173  vtkGetMacro(Eccentricity, double);
175 
177 
180  vtkSetMacro(ScalarWarping, vtkTypeBool);
181  vtkGetMacro(ScalarWarping, vtkTypeBool);
182  vtkBooleanMacro(ScalarWarping, vtkTypeBool);
184 
186 
191  vtkSetMacro(Capping, vtkTypeBool);
192  vtkGetMacro(Capping, vtkTypeBool);
193  vtkBooleanMacro(Capping, vtkTypeBool);
195 
197 
201  vtkSetMacro(CapValue, double);
202  vtkGetMacro(CapValue, double);
204 
206 
212  vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
213  vtkGetMacro(AccumulationMode, int);
214  void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
215  void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
216  void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
219 
221 
225  vtkSetMacro(NullValue, double);
226  vtkGetMacro(NullValue, double);
228 
230 
234  void ComputeModelBounds(vtkDataSet* input, vtkImageData* output, vtkInformation* outInfo);
236  vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
238 
240 
245  friend class vtkGaussianSplatterAlgorithm;
246  double SamplePoint(double x[3]) // for compilers who can't handle this
247  {
248  return (this->*Sample)(x);
249  }
250  void SetScalar(vtkIdType idx, double dist2, double* sPtr)
251  {
252  double v = (this->*SampleFactor)(this->S) *
253  std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
255 
256  if (!this->Visited[idx])
257  {
258  this->Visited[idx] = 1;
259  *sPtr = v;
260  }
261  else
262  {
263  switch (this->AccumulationMode)
264  {
266  if (*sPtr > v)
267  {
268  *sPtr = v;
269  }
270  break;
272  if (*sPtr < v)
273  {
274  *sPtr = v;
275  }
276  break;
278  *sPtr += v;
279  break;
280  }
281  } // not first visit
282  }
283 
284 protected:
286  ~vtkGaussianSplatter() override = default;
287 
291  void Cap(vtkDoubleArray* s);
292 
293  int SampleDimensions[3]; // dimensions of volume to splat into
294  double Radius; // maximum distance splat propagates (as fraction 0->1)
295  double ExponentFactor; // scale exponent of gaussian function
296  double ModelBounds[6]; // bounding box of splatting dimensions
297  vtkTypeBool NormalWarping; // on/off warping of splat via normal
298  double Eccentricity; // elliptic distortion due to normals
299  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
300  double ScaleFactor; // splat size influenced by scale factor
301  vtkTypeBool Capping; // Cap side of volume to close surfaces
302  double CapValue; // value to use for capping
303  int AccumulationMode; // how to combine scalar values
304 
305  double Gaussian(double x[3]);
306  double EccentricGaussian(double x[3]);
307  double ScalarSampling(double s) { return this->ScaleFactor * s; }
308  double PositionSampling(double) { return this->ScaleFactor; }
309 
310 private:
311  double Radius2;
312  double (vtkGaussianSplatter::*Sample)(double x[3]);
313  double (vtkGaussianSplatter::*SampleFactor)(double s);
314  char* Visited;
315  double Eccentricity2;
316  double* P;
317  double* N;
318  double S;
319  double Origin[3];
320  double Spacing[3];
321  double SplatDistance[3];
322  double NullValue;
323 
324 private:
325  vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
326  void operator=(const vtkGaussianSplatter&) = delete;
327 };
328 
329 #endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
dynamic, self-adjusting array of double
splat points into a volume with an elliptical, Gaussian distribution
static vtkGaussianSplatter * New()
Construct object with dimensions=(50,50,50); automatic computation of bounds; a splat radius of 0....
double EccentricGaussian(double x[3])
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
double SamplePoint(double x[3])
Provide access to templated helper class.
double PositionSampling(double)
const char * GetAccumulationModeAsString()
Specify the scalar accumulation mode.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetAccumulationModeToSum()
Specify the scalar accumulation mode.
void Cap(vtkDoubleArray *s)
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
double ScalarSampling(double s)
void SetAccumulationModeToMax()
Specify the scalar accumulation mode.
void ComputeModelBounds(vtkDataSet *input, vtkImageData *output, vtkInformation *outInfo)
Compute the size of the sample bounding box automatically from the input data.
void ComputeModelBounds(vtkCompositeDataSet *input, vtkImageData *output, vtkInformation *outInfo)
Compute the size of the sample bounding box automatically from the input data.
~vtkGaussianSplatter() override=default
double Gaussian(double x[3])
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
void SetScalar(vtkIdType idx, double dist2, double *sPtr)
Provide access to templated helper class.
void SetSampleDimensions(int dim[3])
Set / get the dimensions of the sampling structured point set.
void SetAccumulationModeToMin()
Specify the scalar accumulation mode.
void SetSampleDimensions(int i, int j, int k)
Set / get the dimensions of the sampling structured point set.
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_ACCUMULATION_MODE_SUM
#define VTK_ACCUMULATION_MODE_MIN
#define VTK_ACCUMULATION_MODE_MAX
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165