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 
88 {
89 public:
91  void PrintSelf(ostream& os, vtkIndent indent);
92 
96  static vtkGaussianSplatter *New();
97 
99 
101  void SetSampleDimensions(int i, int j, int k);
102  void SetSampleDimensions(int dim[3]);
103  vtkGetVectorMacro(SampleDimensions,int,3);
105 
107 
111  vtkSetVector6Macro(ModelBounds,double);
112  vtkGetVectorMacro(ModelBounds,double,6);
114 
116 
119  vtkSetClampMacro(Radius,double,0.0,1.0);
120  vtkGetMacro(Radius,double);
122 
124 
127  vtkSetClampMacro(ScaleFactor,double,0.0,VTK_DOUBLE_MAX);
128  vtkGetMacro(ScaleFactor,double);
130 
132 
134  vtkSetMacro(ExponentFactor,double);
135  vtkGetMacro(ExponentFactor,double);
137 
139 
142  vtkSetMacro(NormalWarping,int);
143  vtkGetMacro(NormalWarping,int);
144  vtkBooleanMacro(NormalWarping,int);
146 
148 
153  vtkSetClampMacro(Eccentricity,double,0.001,VTK_DOUBLE_MAX);
154  vtkGetMacro(Eccentricity,double);
156 
158 
159  vtkSetMacro(ScalarWarping,int);
160  vtkGetMacro(ScalarWarping,int);
161  vtkBooleanMacro(ScalarWarping,int);
163 
165 
168  vtkSetMacro(Capping,int);
169  vtkGetMacro(Capping,int);
170  vtkBooleanMacro(Capping,int);
172 
174 
176  vtkSetMacro(CapValue,double);
177  vtkGetMacro(CapValue,double);
179 
181 
185  vtkSetClampMacro(AccumulationMode,int,
187  vtkGetMacro(AccumulationMode,int);
189  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN);}
191  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX);}
193  {this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM);}
194  const char *GetAccumulationModeAsString();
196 
198 
201  vtkSetMacro(NullValue,double);
202  vtkGetMacro(NullValue,double);
204 
206 
208  void ComputeModelBounds(vtkDataSet *input, vtkImageData *output,
209  vtkInformation *outInfo);
210  void ComputeModelBounds(vtkCompositeDataSet *input, vtkImageData *output,
211  vtkInformation *outInfo);
213 
214 //BTX
216 
219  friend class vtkGaussianSplatterAlgorithm;
220  double SamplePoint(double x[3]) //for compilers who can't handle this
221  {return (this->*Sample)(x);}
222  void SetScalar(int idx, double dist2, double *sPtr)
223  {
224  double v = (this->*SampleFactor)(this->S) * exp(static_cast<double>
225  (this->ExponentFactor*(dist2)/(this->Radius2)));
227 
228  if ( ! this->Visited[idx] )
229  {
230  this->Visited[idx] = 1;
231  *sPtr = v;
232  }
233  else
234  {
235  switch (this->AccumulationMode)
236  {
238  if ( *sPtr > v )
239  {
240  *sPtr = v;
241  }
242  break;
244  if ( *sPtr < v )
245  {
246  *sPtr = v;
247  }
248  break;
250  *sPtr += v;
251  break;
252  }
253  }//not first visit
254  }
255 //ETX
256 
257 protected:
260 
262  virtual int RequestInformation (vtkInformation *,
265  virtual int RequestData(vtkInformation *,
268  void Cap(vtkDoubleArray *s);
269 
270  int SampleDimensions[3]; // dimensions of volume to splat into
271  double Radius; // maximum distance splat propagates (as fraction 0->1)
272  double ExponentFactor; // scale exponent of gaussian function
273  double ModelBounds[6]; // bounding box of splatting dimensions
274  int NormalWarping; // on/off warping of splat via normal
275  double Eccentricity;// elliptic distortion due to normals
276  int ScalarWarping; // on/off warping of splat via scalar
277  double ScaleFactor; // splat size influenced by scale factor
278  int Capping; // Cap side of volume to close surfaces
279  double CapValue; // value to use for capping
280  int AccumulationMode; // how to combine scalar values
281 
282  double Gaussian(double x[3]);
283  double EccentricGaussian(double x[3]);
284  double ScalarSampling(double s)
285  {return this->ScaleFactor * s;}
286  double PositionSampling(double)
287  {return this->ScaleFactor;}
288 
289 //BTX
290 private:
291  double Radius2;
292  double (vtkGaussianSplatter::*Sample)(double x[3]);
293  double (vtkGaussianSplatter::*SampleFactor)(double s);
294  char *Visited;
295  double Eccentricity2;
296  double *P;
297  double *N;
298  double S;
299  double Origin[3];
300  double Spacing[3];
301  double SplatDistance[3];
302  double NullValue;
303 //ETX
304 
305 private:
306  vtkGaussianSplatter(const vtkGaussianSplatter&); // Not implemented.
307  void operator=(const vtkGaussianSplatter&); // Not implemented.
308 };
309 
310 #endif
#define VTK_DOUBLE_MAX
Definition: vtkType.h:140
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
#define VTK_ACCUMULATION_MODE_MAX
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
a simple class to control print indentation
Definition: vtkIndent.h:38
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
double PositionSampling(double)
#define VTK_ACCUMULATION_MODE_SUM
virtual int FillInputPortInformation(int port, vtkInformation *info)
#define VTK_ACCUMULATION_MODE_MIN
double SamplePoint(double x[3])
Generic algorithm superclass for image algs.
void SetScalar(int idx, double dist2, double *sPtr)
Store zero or more vtkInformation instances.
void PrintSelf(ostream &os, vtkIndent indent)
static vtkAlgorithm * New()
#define VTKIMAGINGHYBRID_EXPORT
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
double ScalarSampling(double s)