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 =========================================================================*/
142 #ifndef vtkGaussianSplatter_h
143 #define vtkGaussianSplatter_h
144 
145 #include "vtkImageAlgorithm.h"
146 #include "vtkImagingHybridModule.h" // For export macro
147 
148 #include <cmath> // for std::exp
149 
150 #define VTK_ACCUMULATION_MODE_MIN 0
151 #define VTK_ACCUMULATION_MODE_MAX 1
152 #define VTK_ACCUMULATION_MODE_SUM 2
153 
154 class vtkDoubleArray;
155 class vtkCompositeDataSet;
156 class vtkGaussianSplatterAlgorithm;
157 
158 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
159 {
160 public:
162  void PrintSelf(ostream& os, vtkIndent indent) override;
163 
170 
172 
176  void SetSampleDimensions(int i, int j, int k);
177  void SetSampleDimensions(int dim[3]);
178  vtkGetVectorMacro(SampleDimensions, int, 3);
180 
182 
188  vtkSetVector6Macro(ModelBounds, double);
189  vtkGetVectorMacro(ModelBounds, double, 6);
191 
193 
198  vtkSetClampMacro(Radius, double, 0.0, 1.0);
199  vtkGetMacro(Radius, double);
201 
203 
208  vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
209  vtkGetMacro(ScaleFactor, double);
211 
213 
218  vtkSetMacro(ExponentFactor, double);
219  vtkGetMacro(ExponentFactor, double);
221 
223 
228  vtkSetMacro(NormalWarping, vtkTypeBool);
229  vtkGetMacro(NormalWarping, vtkTypeBool);
230  vtkBooleanMacro(NormalWarping, vtkTypeBool);
232 
234 
241  vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
242  vtkGetMacro(Eccentricity, double);
244 
246 
249  vtkSetMacro(ScalarWarping, vtkTypeBool);
250  vtkGetMacro(ScalarWarping, vtkTypeBool);
251  vtkBooleanMacro(ScalarWarping, vtkTypeBool);
253 
255 
260  vtkSetMacro(Capping, vtkTypeBool);
261  vtkGetMacro(Capping, vtkTypeBool);
262  vtkBooleanMacro(Capping, vtkTypeBool);
264 
266 
270  vtkSetMacro(CapValue, double);
271  vtkGetMacro(CapValue, double);
273 
275 
281  vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
282  vtkGetMacro(AccumulationMode, int);
283  void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
284  void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
285  void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
288 
290 
294  vtkSetMacro(NullValue, double);
295  vtkGetMacro(NullValue, double);
297 
299 
303  void ComputeModelBounds(vtkDataSet* input, vtkImageData* output, vtkInformation* outInfo);
305  vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
307 
309 
314  friend class vtkGaussianSplatterAlgorithm;
315  double SamplePoint(double x[3]) // for compilers who can't handle this
316  {
317  return (this->*Sample)(x);
318  }
319  void SetScalar(vtkIdType idx, double dist2, double* sPtr)
320  {
321  double v = (this->*SampleFactor)(this->S) *
322  std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
324 
325  if (!this->Visited[idx])
326  {
327  this->Visited[idx] = 1;
328  *sPtr = v;
329  }
330  else
331  {
332  switch (this->AccumulationMode)
333  {
335  if (*sPtr > v)
336  {
337  *sPtr = v;
338  }
339  break;
341  if (*sPtr < v)
342  {
343  *sPtr = v;
344  }
345  break;
347  *sPtr += v;
348  break;
349  }
350  } // not first visit
351  }
352 
353 protected:
355  ~vtkGaussianSplatter() override = default;
356 
360  void Cap(vtkDoubleArray* s);
361 
362  int SampleDimensions[3]; // dimensions of volume to splat into
363  double Radius; // maximum distance splat propagates (as fraction 0->1)
364  double ExponentFactor; // scale exponent of gaussian function
365  double ModelBounds[6]; // bounding box of splatting dimensions
366  vtkTypeBool NormalWarping; // on/off warping of splat via normal
367  double Eccentricity; // elliptic distortion due to normals
368  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
369  double ScaleFactor; // splat size influenced by scale factor
370  vtkTypeBool Capping; // Cap side of volume to close surfaces
371  double CapValue; // value to use for capping
372  int AccumulationMode; // how to combine scalar values
373 
374  double Gaussian(double x[3]);
375  double EccentricGaussian(double x[3]);
376  double ScalarSampling(double s) { return this->ScaleFactor * s; }
377  double PositionSampling(double) { return this->ScaleFactor; }
378 
379 private:
380  double Radius2;
381  double (vtkGaussianSplatter::*Sample)(double x[3]);
382  double (vtkGaussianSplatter::*SampleFactor)(double s);
383  char* Visited;
384  double Eccentricity2;
385  double* P;
386  double* N;
387  double S;
388  double Origin[3];
389  double Spacing[3];
390  double SplatDistance[3];
391  double NullValue;
392 
393 private:
394  vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
395  void operator=(const vtkGaussianSplatter&) = delete;
396 };
397 
398 #endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
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:157
a simple class to control print indentation
Definition: vtkIndent.h:113
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