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) 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,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,
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() override {}
288 
289  int FillInputPortInformation(int port, vtkInformation* info) override;
292  vtkInformationVector *) override;
295  vtkInformationVector *) 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  vtkTypeBool NormalWarping; // on/off warping of splat via normal
303  double Eccentricity;// elliptic distortion due to normals
304  vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
305  double ScaleFactor; // splat size influenced by scale factor
306  vtkTypeBool 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&) = delete;
333  void operator=(const vtkGaussianSplatter&) = delete;
334 };
335 
336 #endif
vtkGaussianSplatter::SetAccumulationModeToMax
void SetAccumulationModeToMax()
Definition: vtkGaussianSplatter.h:215
vtkImageAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
double
double
Definition: vtkVectorOperators.h:166
vtkGaussianSplatter::Capping
vtkTypeBool Capping
Definition: vtkGaussianSplatter.h:306
VTK_ACCUMULATION_MODE_MAX
#define VTK_ACCUMULATION_MODE_MAX
Definition: vtkGaussianSplatter.h:80
vtkGaussianSplatter::~vtkGaussianSplatter
~vtkGaussianSplatter() override
Definition: vtkGaussianSplatter.h:287
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkImageAlgorithm.h
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:37
vtkCompositeDataSet
abstract superclass for composite (multi-block or AMR) datasets
Definition: vtkCompositeDataSet.h:45
vtkGaussianSplatter::ScaleFactor
double ScaleFactor
Definition: vtkGaussianSplatter.h:305
vtkGaussianSplatter::NormalWarping
vtkTypeBool NormalWarping
Definition: vtkGaussianSplatter.h:302
vtkX3D::port
Definition: vtkX3D.h:447
VTK_ACCUMULATION_MODE_SUM
#define VTK_ACCUMULATION_MODE_SUM
Definition: vtkGaussianSplatter.h:81
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkGaussianSplatter::SamplePoint
double SamplePoint(double x[3])
Definition: vtkGaussianSplatter.h:249
vtkGaussianSplatter::ScalarWarping
vtkTypeBool ScalarWarping
Definition: vtkGaussianSplatter.h:304
vtkGaussianSplatter::Eccentricity
double Eccentricity
Definition: vtkGaussianSplatter.h:303
vtkGaussianSplatter::ScalarSampling
double ScalarSampling(double s)
Definition: vtkGaussianSplatter.h:312
vtkGaussianSplatter::SetAccumulationModeToMin
void SetAccumulationModeToMin()
Definition: vtkGaussianSplatter.h:213
vtkGaussianSplatter::ExponentFactor
double ExponentFactor
Definition: vtkGaussianSplatter.h:300
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkGaussianSplatter::SetScalar
void SetScalar(int idx, double dist2, double *sPtr)
Definition: vtkGaussianSplatter.h:251
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkX3D::info
Definition: vtkX3D.h:376
vtkImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkGaussianSplatter::Radius
double Radius
Definition: vtkGaussianSplatter.h:299
vtkGaussianSplatter::CapValue
double CapValue
Definition: vtkGaussianSplatter.h:307
vtkGaussianSplatter::AccumulationMode
int AccumulationMode
Definition: vtkGaussianSplatter.h:308
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
VTK_ACCUMULATION_MODE_MIN
#define VTK_ACCUMULATION_MODE_MIN
Definition: vtkGaussianSplatter.h:79
vtkGaussianSplatter
splat points into a volume with an elliptical, Gaussian distribution
Definition: vtkGaussianSplatter.h:87
vtkImageAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkGaussianSplatter::SetAccumulationModeToSum
void SetAccumulationModeToSum()
Definition: vtkGaussianSplatter.h:217
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:169
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkGaussianSplatter::PositionSampling
double PositionSampling(double)
Definition: vtkGaussianSplatter.h:314