VTK  9.0.3
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 #define VTK_ACCUMULATION_MODE_MIN 0
80 #define VTK_ACCUMULATION_MODE_MAX 1
81 #define VTK_ACCUMULATION_MODE_SUM 2
82 
83 class vtkDoubleArray;
85 class vtkGaussianSplatterAlgorithm;
86 
87 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
88 {
89 public:
91  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
99 
101 
105  void SetSampleDimensions(int i, int j, int k);
106  void SetSampleDimensions(int dim[3]);
107  vtkGetVectorMacro(SampleDimensions, int, 3);
109 
111 
117  vtkSetVector6Macro(ModelBounds, double);
118  vtkGetVectorMacro(ModelBounds, double, 6);
120 
122 
127  vtkSetClampMacro(Radius, double, 0.0, 1.0);
128  vtkGetMacro(Radius, double);
130 
132 
137  vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
138  vtkGetMacro(ScaleFactor, double);
140 
142 
147  vtkSetMacro(ExponentFactor, double);
148  vtkGetMacro(ExponentFactor, double);
150 
152 
157  vtkSetMacro(NormalWarping, vtkTypeBool);
158  vtkGetMacro(NormalWarping, vtkTypeBool);
159  vtkBooleanMacro(NormalWarping, vtkTypeBool);
161 
163 
170  vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
171  vtkGetMacro(Eccentricity, double);
173 
175 
178  vtkSetMacro(ScalarWarping, vtkTypeBool);
179  vtkGetMacro(ScalarWarping, vtkTypeBool);
180  vtkBooleanMacro(ScalarWarping, vtkTypeBool);
182 
184 
189  vtkSetMacro(Capping, vtkTypeBool);
190  vtkGetMacro(Capping, vtkTypeBool);
191  vtkBooleanMacro(Capping, vtkTypeBool);
193 
195 
199  vtkSetMacro(CapValue, double);
200  vtkGetMacro(CapValue, double);
202 
204 
210  vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
211  vtkGetMacro(AccumulationMode, int);
212  void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
213  void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
214  void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
217 
219 
223  vtkSetMacro(NullValue, double);
224  vtkGetMacro(NullValue, double);
226 
228 
232  void ComputeModelBounds(vtkDataSet* input, vtkImageData* output, vtkInformation* outInfo);
234  vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
236 
238 
243  friend class vtkGaussianSplatterAlgorithm;
244  double SamplePoint(double x[3]) // for compilers who can't handle this
245  {
246  return (this->*Sample)(x);
247  }
248  void SetScalar(vtkIdType idx, double dist2, double* sPtr)
249  {
250  double v = (this->*SampleFactor)(this->S) *
251  exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
253 
254  if (!this->Visited[idx])
255  {
256  this->Visited[idx] = 1;
257  *sPtr = v;
258  }
259  else
260  {
261  switch (this->AccumulationMode)
262  {
264  if (*sPtr > v)
265  {
266  *sPtr = v;
267  }
268  break;
270  if (*sPtr < v)
271  {
272  *sPtr = v;
273  }
274  break;
276  *sPtr += v;
277  break;
278  }
279  } // not first visit
280  }
281 
282 protected:
284  ~vtkGaussianSplatter() override {}
285 
289  void Cap(vtkDoubleArray* s);
290 
291  int SampleDimensions[3]; // dimensions of volume to splat into
292  double Radius; // maximum distance splat propagates (as fraction 0->1)
293  double ExponentFactor; // scale exponent of gaussian function
294  double ModelBounds[6]; // bounding box of splatting dimensions
295  vtkTypeBool NormalWarping; // on/off warping of splat via normal
296  double Eccentricity; // elliptic distortion due to normals
297  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
298  double ScaleFactor; // splat size influenced by scale factor
299  vtkTypeBool Capping; // Cap side of volume to close surfaces
300  double CapValue; // value to use for capping
301  int AccumulationMode; // how to combine scalar values
302 
303  double Gaussian(double x[3]);
304  double EccentricGaussian(double x[3]);
305  double ScalarSampling(double s) { return this->ScaleFactor * s; }
306  double PositionSampling(double) { return this->ScaleFactor; }
307 
308 private:
309  double Radius2;
310  double (vtkGaussianSplatter::*Sample)(double x[3]);
311  double (vtkGaussianSplatter::*SampleFactor)(double s);
312  char* Visited;
313  double Eccentricity2;
314  double* P;
315  double* N;
316  double S;
317  double Origin[3];
318  double Spacing[3];
319  double SplatDistance[3];
320  double NullValue;
321 
322 private:
323  vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
324  void operator=(const vtkGaussianSplatter&) = delete;
325 };
326 
327 #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])
double PositionSampling(double)
const char * GetAccumulationModeAsString()
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void Cap(vtkDoubleArray *s)
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
double ScalarSampling(double s)
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)
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)
void SetSampleDimensions(int dim[3])
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:42
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:338
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165