VTK  9.2.5
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 =========================================================================*/
148 #ifndef vtkGaussianSplatter_h
149 #define vtkGaussianSplatter_h
150 
151 #include "vtkImageAlgorithm.h"
152 #include "vtkImagingHybridModule.h" // For export macro
153 
154 #include <cmath> // for std::exp
155 
156 #define VTK_ACCUMULATION_MODE_MIN 0
157 #define VTK_ACCUMULATION_MODE_MAX 1
158 #define VTK_ACCUMULATION_MODE_SUM 2
159 
160 class vtkDoubleArray;
161 class vtkCompositeDataSet;
162 class vtkGaussianSplatterAlgorithm;
163 
164 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
165 {
166 public:
168  void PrintSelf(ostream& os, vtkIndent indent) override;
169 
176 
178 
182  void SetSampleDimensions(int i, int j, int k);
183  void SetSampleDimensions(int dim[3]);
184  vtkGetVectorMacro(SampleDimensions, int, 3);
186 
188 
194  vtkSetVector6Macro(ModelBounds, double);
195  vtkGetVectorMacro(ModelBounds, double, 6);
197 
199 
204  vtkSetClampMacro(Radius, double, 0.0, 1.0);
205  vtkGetMacro(Radius, double);
207 
209 
214  vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
215  vtkGetMacro(ScaleFactor, double);
217 
219 
224  vtkSetMacro(ExponentFactor, double);
225  vtkGetMacro(ExponentFactor, double);
227 
229 
234  vtkSetMacro(NormalWarping, vtkTypeBool);
235  vtkGetMacro(NormalWarping, vtkTypeBool);
236  vtkBooleanMacro(NormalWarping, vtkTypeBool);
238 
240 
247  vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
248  vtkGetMacro(Eccentricity, double);
250 
252 
255  vtkSetMacro(ScalarWarping, vtkTypeBool);
256  vtkGetMacro(ScalarWarping, vtkTypeBool);
257  vtkBooleanMacro(ScalarWarping, vtkTypeBool);
259 
261 
266  vtkSetMacro(Capping, vtkTypeBool);
267  vtkGetMacro(Capping, vtkTypeBool);
268  vtkBooleanMacro(Capping, vtkTypeBool);
270 
272 
276  vtkSetMacro(CapValue, double);
277  vtkGetMacro(CapValue, double);
279 
281 
287  vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
288  vtkGetMacro(AccumulationMode, int);
289  void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
290  void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
291  void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
294 
296 
300  vtkSetMacro(NullValue, double);
301  vtkGetMacro(NullValue, double);
303 
305 
309  void ComputeModelBounds(vtkDataSet* input, vtkImageData* output, vtkInformation* outInfo);
311  vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
313 
315 
320  friend class vtkGaussianSplatterAlgorithm;
321  double SamplePoint(double x[3]) // for compilers who can't handle this
322  {
323  return (this->*Sample)(x);
324  }
325  void SetScalar(vtkIdType idx, double dist2, double* sPtr)
326  {
327  double v = (this->*SampleFactor)(this->S) *
328  std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
330 
331  if (!this->Visited[idx])
332  {
333  this->Visited[idx] = 1;
334  *sPtr = v;
335  }
336  else
337  {
338  switch (this->AccumulationMode)
339  {
341  if (*sPtr > v)
342  {
343  *sPtr = v;
344  }
345  break;
347  if (*sPtr < v)
348  {
349  *sPtr = v;
350  }
351  break;
353  *sPtr += v;
354  break;
355  }
356  } // not first visit
357  }
358 
359 protected:
361  ~vtkGaussianSplatter() override = default;
362 
366  void Cap(vtkDoubleArray* s);
367 
368  int SampleDimensions[3]; // dimensions of volume to splat into
369  double Radius; // maximum distance splat propagates (as fraction 0->1)
370  double ExponentFactor; // scale exponent of gaussian function
371  double ModelBounds[6]; // bounding box of splatting dimensions
372  vtkTypeBool NormalWarping; // on/off warping of splat via normal
373  double Eccentricity; // elliptic distortion due to normals
374  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
375  double ScaleFactor; // splat size influenced by scale factor
376  vtkTypeBool Capping; // Cap side of volume to close surfaces
377  double CapValue; // value to use for capping
378  int AccumulationMode; // how to combine scalar values
379 
380  double Gaussian(double x[3]);
381  double EccentricGaussian(double x[3]);
382  double ScalarSampling(double s) { return this->ScaleFactor * s; }
383  double PositionSampling(double) { return this->ScaleFactor; }
384 
385 private:
386  double Radius2;
387  double (vtkGaussianSplatter::*Sample)(double x[3]);
388  double (vtkGaussianSplatter::*SampleFactor)(double s);
389  char* Visited;
390  double Eccentricity2;
391  double* P;
392  double* N;
393  double S;
394  double Origin[3];
395  double Spacing[3];
396  double SplatDistance[3];
397  double NullValue;
398 
399 private:
400  vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
401  void operator=(const vtkGaussianSplatter&) = delete;
402 };
403 
404 #endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:172
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:163
a simple class to control print indentation
Definition: vtkIndent.h:119
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