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
vtkGaussianSplatter::SetAccumulationModeToMax
void SetAccumulationModeToMax()
Specify the scalar accumulation mode.
Definition: vtkGaussianSplatter.h:284
vtkGaussianSplatter::~vtkGaussianSplatter
~vtkGaussianSplatter() override=default
vtkGaussianSplatter::SetScalar
void SetScalar(vtkIdType idx, double dist2, double *sPtr)
Provide access to templated helper class.
Definition: vtkGaussianSplatter.h:319
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkGaussianSplatter::Capping
vtkTypeBool Capping
Definition: vtkGaussianSplatter.h:370
VTK_ACCUMULATION_MODE_MAX
#define VTK_ACCUMULATION_MODE_MAX
Definition: vtkGaussianSplatter.h:151
vtkGaussianSplatter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkGaussianSplatter::ComputeModelBounds
void ComputeModelBounds(vtkCompositeDataSet *input, vtkImageData *output, vtkInformation *outInfo)
Compute the size of the sample bounding box automatically from the input data.
vtkImageAlgorithm.h
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:57
vtkGaussianSplatter::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
vtkCompositeDataSet
abstract superclass for composite (multi-block or AMR) datasets
Definition: vtkCompositeDataSet.h:68
vtkGaussianSplatter::ScaleFactor
double ScaleFactor
Definition: vtkGaussianSplatter.h:369
vtkGaussianSplatter::NormalWarping
vtkTypeBool NormalWarping
Definition: vtkGaussianSplatter.h:366
vtkGaussianSplatter::RequestInformation
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkX3D::port
@ port
Definition: vtkX3D.h:453
VTK_ACCUMULATION_MODE_SUM
#define VTK_ACCUMULATION_MODE_SUM
Definition: vtkGaussianSplatter.h:152
vtkGaussianSplatter::SamplePoint
double SamplePoint(double x[3])
Provide access to templated helper class.
Definition: vtkGaussianSplatter.h:315
vtkGaussianSplatter::ScalarWarping
vtkTypeBool ScalarWarping
Definition: vtkGaussianSplatter.h:368
vtkGaussianSplatter::Gaussian
double Gaussian(double x[3])
vtkGaussianSplatter::Eccentricity
double Eccentricity
Definition: vtkGaussianSplatter.h:367
vtkGaussianSplatter::ScalarSampling
double ScalarSampling(double s)
Definition: vtkGaussianSplatter.h:376
vtkGaussianSplatter::SetAccumulationModeToMin
void SetAccumulationModeToMin()
Specify the scalar accumulation mode.
Definition: vtkGaussianSplatter.h:283
vtkGaussianSplatter::ExponentFactor
double ExponentFactor
Definition: vtkGaussianSplatter.h:364
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkGaussianSplatter::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
vtkGaussianSplatter::vtkGaussianSplatter
vtkGaussianSplatter()
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
vtkGaussianSplatter::New
static vtkGaussianSplatter * New()
Construct object with dimensions=(50,50,50); automatic computation of bounds; a splat radius of 0....
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkGaussianSplatter::Radius
double Radius
Definition: vtkGaussianSplatter.h:363
vtkGaussianSplatter::CapValue
double CapValue
Definition: vtkGaussianSplatter.h:371
vtkGaussianSplatter::AccumulationMode
int AccumulationMode
Definition: vtkGaussianSplatter.h:372
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
VTK_ACCUMULATION_MODE_MIN
#define VTK_ACCUMULATION_MODE_MIN
Definition: vtkGaussianSplatter.h:150
vtkGaussianSplatter::ComputeModelBounds
void ComputeModelBounds(vtkDataSet *input, vtkImageData *output, vtkInformation *outInfo)
Compute the size of the sample bounding box automatically from the input data.
vtkGaussianSplatter::GetAccumulationModeAsString
const char * GetAccumulationModeAsString()
Specify the scalar accumulation mode.
vtkGaussianSplatter::Cap
void Cap(vtkDoubleArray *s)
vtkGaussianSplatter
splat points into a volume with an elliptical, Gaussian distribution
Definition: vtkGaussianSplatter.h:159
vtkGaussianSplatter::SetAccumulationModeToSum
void SetAccumulationModeToSum()
Specify the scalar accumulation mode.
Definition: vtkGaussianSplatter.h:285
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkGaussianSplatter::EccentricGaussian
double EccentricGaussian(double x[3])
vtkGaussianSplatter::SetSampleDimensions
void SetSampleDimensions(int i, int j, int k)
Set / get the dimensions of the sampling structured point set.
vtkGaussianSplatter::SetSampleDimensions
void SetSampleDimensions(int dim[3])
Set / get the dimensions of the sampling structured point set.
vtkGaussianSplatter::PositionSampling
double PositionSampling(double)
Definition: vtkGaussianSplatter.h:377