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 =========================================================================*/
73 #ifndef vtkGaussianSplatter_h
74 #define vtkGaussianSplatter_h
75 
76 #include "vtkImagingHybridModule.h" // For export macro
77 #include "vtkImageAlgorithm.h"
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) VTK_OVERRIDE;
92 
98  static vtkGaussianSplatter *New();
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,int);
158  vtkGetMacro(NormalWarping,int);
159  vtkBooleanMacro(NormalWarping,int);
161 
163 
170  vtkSetClampMacro(Eccentricity,double,0.001,VTK_DOUBLE_MAX);
171  vtkGetMacro(Eccentricity,double);
173 
175 
178  vtkSetMacro(ScalarWarping,int);
179  vtkGetMacro(ScalarWarping,int);
180  vtkBooleanMacro(ScalarWarping,int);
182 
184 
189  vtkSetMacro(Capping,int);
190  vtkGetMacro(Capping,int);
191  vtkBooleanMacro(Capping,int);
193 
195 
199  vtkSetMacro(CapValue,double);
200  vtkGetMacro(CapValue,double);
202 
204 
210  vtkSetClampMacro(AccumulationMode,int,
212  vtkGetMacro(AccumulationMode,int);
214  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN);}
216  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX);}
218  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM);}
219  const char *GetAccumulationModeAsString();
221 
223 
227  vtkSetMacro(NullValue,double);
228  vtkGetMacro(NullValue,double);
230 
232 
236  void ComputeModelBounds(vtkDataSet *input, vtkImageData *output,
237  vtkInformation *outInfo);
238  void ComputeModelBounds(vtkCompositeDataSet *input, vtkImageData *output,
239  vtkInformation *outInfo);
241 
243 
248  friend class vtkGaussianSplatterAlgorithm;
249  double SamplePoint(double x[3]) //for compilers who can't handle this
250  {return (this->*Sample)(x);}
251  void SetScalar(int idx, double dist2, double *sPtr)
252  {
253  double v = (this->*SampleFactor)(this->S) * exp(static_cast<double>
254  (this->ExponentFactor*(dist2)/(this->Radius2)));
256 
257  if ( ! this->Visited[idx] )
258  {
259  this->Visited[idx] = 1;
260  *sPtr = v;
261  }
262  else
263  {
264  switch (this->AccumulationMode)
265  {
267  if ( *sPtr > v )
268  {
269  *sPtr = v;
270  }
271  break;
273  if ( *sPtr < v )
274  {
275  *sPtr = v;
276  }
277  break;
279  *sPtr += v;
280  break;
281  }
282  }//not first visit
283  }
284 
285 protected:
287  ~vtkGaussianSplatter() VTK_OVERRIDE {}
288 
289  int FillInputPortInformation(int port, vtkInformation* info) VTK_OVERRIDE;
292  vtkInformationVector *) VTK_OVERRIDE;
295  vtkInformationVector *) VTK_OVERRIDE;
296  void Cap(vtkDoubleArray *s);
297 
298  int SampleDimensions[3]; // dimensions of volume to splat into
299  double Radius; // maximum distance splat propagates (as fraction 0->1)
300  double ExponentFactor; // scale exponent of gaussian function
301  double ModelBounds[6]; // bounding box of splatting dimensions
302  int NormalWarping; // on/off warping of splat via normal
303  double Eccentricity;// elliptic distortion due to normals
304  int ScalarWarping; // on/off warping of splat via scalar
305  double ScaleFactor; // splat size influenced by scale factor
306  int Capping; // Cap side of volume to close surfaces
307  double CapValue; // value to use for capping
308  int AccumulationMode; // how to combine scalar values
309 
310  double Gaussian(double x[3]);
311  double EccentricGaussian(double x[3]);
312  double ScalarSampling(double s)
313  {return this->ScaleFactor * s;}
314  double PositionSampling(double)
315  {return this->ScaleFactor;}
316 
317 private:
318  double Radius2;
319  double (vtkGaussianSplatter::*Sample)(double x[3]);
320  double (vtkGaussianSplatter::*SampleFactor)(double s);
321  char *Visited;
322  double Eccentricity2;
323  double *P;
324  double *N;
325  double S;
326  double Origin[3];
327  double Spacing[3];
328  double SplatDistance[3];
329  double NullValue;
330 
331 private:
332  vtkGaussianSplatter(const vtkGaussianSplatter&) VTK_DELETE_FUNCTION;
333  void operator=(const vtkGaussianSplatter&) VTK_DELETE_FUNCTION;
334 };
335 
336 #endif
void SetAccumulationModeToMin()
Specify the scalar accumulation mode.
int Capping
Provide access to templated helper class.
double Eccentricity
Provide access to templated helper class.
int ScalarWarping
Provide access to templated helper class.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:167
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
#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
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:33
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
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.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#define VTK_ACCUMULATION_MODE_MIN
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.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.
int NormalWarping
Provide access to templated helper class.
double ExponentFactor
Provide access to templated helper class.
double ScalarSampling(double s)
Provide access to templated helper class.