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 =========================================================================*/
88 #ifndef vtkGaussianSplatter_h
89 #define vtkGaussianSplatter_h
90 
91 #include "vtkImageAlgorithm.h"
92 #include "vtkImagingHybridModule.h" // For export macro
93 
94 #include <cmath> // for std::exp
95 
96 #define VTK_ACCUMULATION_MODE_MIN 0
97 #define VTK_ACCUMULATION_MODE_MAX 1
98 #define VTK_ACCUMULATION_MODE_SUM 2
99 
100 class vtkDoubleArray;
101 class vtkCompositeDataSet;
102 class vtkGaussianSplatterAlgorithm;
103 
104 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
105 {
106 public:
108  void PrintSelf(ostream& os, vtkIndent indent) override;
109 
116 
118 
122  void SetSampleDimensions(int i, int j, int k);
123  void SetSampleDimensions(int dim[3]);
124  vtkGetVectorMacro(SampleDimensions, int, 3);
126 
128 
134  vtkSetVector6Macro(ModelBounds, double);
135  vtkGetVectorMacro(ModelBounds, double, 6);
137 
139 
144  vtkSetClampMacro(Radius, double, 0.0, 1.0);
145  vtkGetMacro(Radius, double);
147 
149 
154  vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
155  vtkGetMacro(ScaleFactor, double);
157 
159 
164  vtkSetMacro(ExponentFactor, double);
165  vtkGetMacro(ExponentFactor, double);
167 
169 
174  vtkSetMacro(NormalWarping, vtkTypeBool);
175  vtkGetMacro(NormalWarping, vtkTypeBool);
176  vtkBooleanMacro(NormalWarping, vtkTypeBool);
178 
180 
187  vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
188  vtkGetMacro(Eccentricity, double);
190 
192 
195  vtkSetMacro(ScalarWarping, vtkTypeBool);
196  vtkGetMacro(ScalarWarping, vtkTypeBool);
197  vtkBooleanMacro(ScalarWarping, vtkTypeBool);
199 
201 
206  vtkSetMacro(Capping, vtkTypeBool);
207  vtkGetMacro(Capping, vtkTypeBool);
208  vtkBooleanMacro(Capping, vtkTypeBool);
210 
212 
216  vtkSetMacro(CapValue, double);
217  vtkGetMacro(CapValue, double);
219 
221 
227  vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
228  vtkGetMacro(AccumulationMode, int);
229  void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
230  void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
231  void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
234 
236 
240  vtkSetMacro(NullValue, double);
241  vtkGetMacro(NullValue, double);
243 
245 
249  void ComputeModelBounds(vtkDataSet* input, vtkImageData* output, vtkInformation* outInfo);
251  vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
253 
255 
260  friend class vtkGaussianSplatterAlgorithm;
261  double SamplePoint(double x[3]) // for compilers who can't handle this
262  {
263  return (this->*Sample)(x);
264  }
265  void SetScalar(vtkIdType idx, double dist2, double* sPtr)
266  {
267  double v = (this->*SampleFactor)(this->S) *
268  std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
270 
271  if (!this->Visited[idx])
272  {
273  this->Visited[idx] = 1;
274  *sPtr = v;
275  }
276  else
277  {
278  switch (this->AccumulationMode)
279  {
281  if (*sPtr > v)
282  {
283  *sPtr = v;
284  }
285  break;
287  if (*sPtr < v)
288  {
289  *sPtr = v;
290  }
291  break;
293  *sPtr += v;
294  break;
295  }
296  } // not first visit
297  }
298 
299 protected:
301  ~vtkGaussianSplatter() override = default;
302 
306  void Cap(vtkDoubleArray* s);
307 
308  int SampleDimensions[3]; // dimensions of volume to splat into
309  double Radius; // maximum distance splat propagates (as fraction 0->1)
310  double ExponentFactor; // scale exponent of gaussian function
311  double ModelBounds[6]; // bounding box of splatting dimensions
312  vtkTypeBool NormalWarping; // on/off warping of splat via normal
313  double Eccentricity; // elliptic distortion due to normals
314  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
315  double ScaleFactor; // splat size influenced by scale factor
316  vtkTypeBool Capping; // Cap side of volume to close surfaces
317  double CapValue; // value to use for capping
318  int AccumulationMode; // how to combine scalar values
319 
320  double Gaussian(double x[3]);
321  double EccentricGaussian(double x[3]);
322  double ScalarSampling(double s) { return this->ScaleFactor * s; }
323  double PositionSampling(double) { return this->ScaleFactor; }
324 
325 private:
326  double Radius2;
327  double (vtkGaussianSplatter::*Sample)(double x[3]);
328  double (vtkGaussianSplatter::*SampleFactor)(double s);
329  char* Visited;
330  double Eccentricity2;
331  double* P;
332  double* N;
333  double S;
334  double Origin[3];
335  double Spacing[3];
336  double SplatDistance[3];
337  double NullValue;
338 
339 private:
340  vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
341  void operator=(const vtkGaussianSplatter&) = delete;
342 };
343 
344 #endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:72
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:63
a simple class to control print indentation
Definition: vtkIndent.h:49
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