VTK
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 =========================================================================*/
79 #ifndef vtkGaussianSplatter_h
80 #define vtkGaussianSplatter_h
81 
82 #include "vtkImagingHybridModule.h" // For export macro
83 #include "vtkImageAlgorithm.h"
84 
85 #define VTK_ACCUMULATION_MODE_MIN 0
86 #define VTK_ACCUMULATION_MODE_MAX 1
87 #define VTK_ACCUMULATION_MODE_SUM 2
88 
89 class vtkDoubleArray;
91 class vtkGaussianSplatterAlgorithm;
92 
93 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
94 {
95 public:
97  void PrintSelf(ostream& os, vtkIndent indent) override;
98 
104  static vtkGaussianSplatter *New();
105 
107 
111  void SetSampleDimensions(int i, int j, int k);
112  void SetSampleDimensions(int dim[3]);
113  vtkGetVectorMacro(SampleDimensions,int,3);
115 
117 
123  vtkSetVector6Macro(ModelBounds,double);
124  vtkGetVectorMacro(ModelBounds,double,6);
126 
128 
133  vtkSetClampMacro(Radius,double,0.0,1.0);
134  vtkGetMacro(Radius,double);
136 
138 
143  vtkSetClampMacro(ScaleFactor,double,0.0,VTK_DOUBLE_MAX);
144  vtkGetMacro(ScaleFactor,double);
146 
148 
153  vtkSetMacro(ExponentFactor,double);
154  vtkGetMacro(ExponentFactor,double);
156 
158 
163  vtkSetMacro(NormalWarping,vtkTypeBool);
164  vtkGetMacro(NormalWarping,vtkTypeBool);
165  vtkBooleanMacro(NormalWarping,vtkTypeBool);
167 
169 
176  vtkSetClampMacro(Eccentricity,double,0.001,VTK_DOUBLE_MAX);
177  vtkGetMacro(Eccentricity,double);
179 
181 
184  vtkSetMacro(ScalarWarping,vtkTypeBool);
185  vtkGetMacro(ScalarWarping,vtkTypeBool);
186  vtkBooleanMacro(ScalarWarping,vtkTypeBool);
188 
190 
195  vtkSetMacro(Capping,vtkTypeBool);
196  vtkGetMacro(Capping,vtkTypeBool);
197  vtkBooleanMacro(Capping,vtkTypeBool);
199 
201 
205  vtkSetMacro(CapValue,double);
206  vtkGetMacro(CapValue,double);
208 
210 
216  vtkSetClampMacro(AccumulationMode,int,
218  vtkGetMacro(AccumulationMode,int);
220  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN);}
222  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX);}
224  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM);}
225  const char *GetAccumulationModeAsString();
227 
229 
233  vtkSetMacro(NullValue,double);
234  vtkGetMacro(NullValue,double);
236 
238 
242  void ComputeModelBounds(vtkDataSet *input, vtkImageData *output,
243  vtkInformation *outInfo);
244  void ComputeModelBounds(vtkCompositeDataSet *input, vtkImageData *output,
245  vtkInformation *outInfo);
247 
249 
254  friend class vtkGaussianSplatterAlgorithm;
255  double SamplePoint(double x[3]) //for compilers who can't handle this
256  {return (this->*Sample)(x);}
257  void SetScalar(int idx, double dist2, double *sPtr)
258  {
259  double v = (this->*SampleFactor)(this->S) * exp(static_cast<double>
260  (this->ExponentFactor*(dist2)/(this->Radius2)));
262 
263  if ( ! this->Visited[idx] )
264  {
265  this->Visited[idx] = 1;
266  *sPtr = v;
267  }
268  else
269  {
270  switch (this->AccumulationMode)
271  {
273  if ( *sPtr > v )
274  {
275  *sPtr = v;
276  }
277  break;
279  if ( *sPtr < v )
280  {
281  *sPtr = v;
282  }
283  break;
285  *sPtr += v;
286  break;
287  }
288  }//not first visit
289  }
290 
291 protected:
293  ~vtkGaussianSplatter() override {}
294 
295  int FillInputPortInformation(int port, vtkInformation* info) override;
298  vtkInformationVector *) override;
301  vtkInformationVector *) override;
302  void Cap(vtkDoubleArray *s);
303 
304  int SampleDimensions[3]; // dimensions of volume to splat into
305  double Radius; // maximum distance splat propagates (as fraction 0->1)
306  double ExponentFactor; // scale exponent of gaussian function
307  double ModelBounds[6]; // bounding box of splatting dimensions
308  vtkTypeBool NormalWarping; // on/off warping of splat via normal
309  double Eccentricity;// elliptic distortion due to normals
310  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
311  double ScaleFactor; // splat size influenced by scale factor
312  vtkTypeBool Capping; // Cap side of volume to close surfaces
313  double CapValue; // value to use for capping
314  int AccumulationMode; // how to combine scalar values
315 
316  double Gaussian(double x[3]);
317  double EccentricGaussian(double x[3]);
318  double ScalarSampling(double s)
319  {return this->ScaleFactor * s;}
320  double PositionSampling(double)
321  {return this->ScaleFactor;}
322 
323 private:
324  double Radius2;
325  double (vtkGaussianSplatter::*Sample)(double x[3]);
326  double (vtkGaussianSplatter::*SampleFactor)(double s);
327  char *Visited;
328  double Eccentricity2;
329  double *P;
330  double *N;
331  double S;
332  double Origin[3];
333  double Spacing[3];
334  double SplatDistance[3];
335  double NullValue;
336 
337 private:
338  vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
339  void operator=(const vtkGaussianSplatter&) = delete;
340 };
341 
342 #endif
vtkTypeBool ScalarWarping
Provide access to templated helper class.
void SetAccumulationModeToMin()
Specify the scalar accumulation mode.
double Eccentricity
Provide access to templated helper class.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:169
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
#define VTK_ACCUMULATION_MODE_MAX
void SetAccumulationModeToMax()
Specify the scalar accumulation mode.
int AccumulationMode
Provide access to templated helper class.
double Radius
Provide access to templated helper class.
splat points into a volume with an elliptical, Gaussian distribution
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:69
abstract superclass for composite (multi-block or AMR) datasets
double CapValue
Provide access to templated helper class.
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
double PositionSampling(double)
Provide access to templated helper class.
#define VTK_ACCUMULATION_MODE_SUM
void SetAccumulationModeToSum()
Specify the scalar accumulation mode.
#define VTK_ACCUMULATION_MODE_MIN
vtkTypeBool Capping
Provide access to templated helper class.
double SamplePoint(double x[3])
Provide access to templated helper class.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
Generic algorithm superclass for image algs.
~vtkGaussianSplatter() override
Provide access to templated helper class.
void SetScalar(int idx, double dist2, double *sPtr)
Provide access to templated helper class.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool NormalWarping
Provide access to templated helper class.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
double ScaleFactor
Provide access to templated helper class.
double ExponentFactor
Provide access to templated helper class.
double ScalarSampling(double s)
Provide access to templated helper class.