VTK  9.2.6
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=========================================================================*/
78
79#ifndef vtkGaussianSplatter_h
80#define vtkGaussianSplatter_h
81
82#include "vtkImageAlgorithm.h"
83#include "vtkImagingHybridModule.h" // For export macro
84
85#include <cmath> // for std::exp
86
87#define VTK_ACCUMULATION_MODE_MIN 0
88#define VTK_ACCUMULATION_MODE_MAX 1
89#define VTK_ACCUMULATION_MODE_SUM 2
90
91class vtkDoubleArray;
93class vtkGaussianSplatterAlgorithm;
94
95class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
96{
97public:
99 void PrintSelf(ostream& os, vtkIndent indent) override;
100
107
109
113 void SetSampleDimensions(int i, int j, int k);
114 void SetSampleDimensions(int dim[3]);
115 vtkGetVectorMacro(SampleDimensions, int, 3);
117
119
125 vtkSetVector6Macro(ModelBounds, double);
126 vtkGetVectorMacro(ModelBounds, double, 6);
128
130
135 vtkSetClampMacro(Radius, double, 0.0, 1.0);
136 vtkGetMacro(Radius, double);
138
140
145 vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
146 vtkGetMacro(ScaleFactor, double);
148
150
155 vtkSetMacro(ExponentFactor, double);
156 vtkGetMacro(ExponentFactor, double);
158
160
167 vtkBooleanMacro(NormalWarping, vtkTypeBool);
169
171
178 vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
179 vtkGetMacro(Eccentricity, double);
181
183
188 vtkBooleanMacro(ScalarWarping, vtkTypeBool);
190
192
197 vtkSetMacro(Capping, vtkTypeBool);
198 vtkGetMacro(Capping, vtkTypeBool);
199 vtkBooleanMacro(Capping, vtkTypeBool);
201
203
207 vtkSetMacro(CapValue, double);
208 vtkGetMacro(CapValue, double);
210
212
219 vtkGetMacro(AccumulationMode, int);
225
227
231 vtkSetMacro(NullValue, double);
232 vtkGetMacro(NullValue, double);
234
236
242 vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
244
246
252 double SamplePoint(double x[3]) // for compilers who can't handle this
253 {
254 return (this->*Sample)(x);
255 }
256 void SetScalar(vtkIdType idx, double dist2, double* sPtr)
257 {
258 double v = (this->*SampleFactor)(this->S) *
259 std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
261
262 if (!this->Visited[idx])
263 {
264 this->Visited[idx] = 1;
265 *sPtr = v;
266 }
267 else
268 {
269 switch (this->AccumulationMode)
270 {
272 if (*sPtr > v)
273 {
274 *sPtr = v;
275 }
276 break;
278 if (*sPtr < v)
279 {
280 *sPtr = v;
281 }
282 break;
284 *sPtr += v;
285 break;
286 }
287 } // not first visit
288 }
289
290protected:
292 ~vtkGaussianSplatter() override = default;
293
294 int FillInputPortInformation(int port, vtkInformation* info) override;
298
299 int SampleDimensions[3]; // dimensions of volume to splat into
300 double Radius; // maximum distance splat propagates (as fraction 0->1)
301 double ExponentFactor; // scale exponent of gaussian function
302 double ModelBounds[6]; // bounding box of splatting dimensions
303 vtkTypeBool NormalWarping; // on/off warping of splat via normal
304 double Eccentricity; // elliptic distortion due to normals
305 vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
306 double ScaleFactor; // splat size influenced by scale factor
307 vtkTypeBool Capping; // Cap side of volume to close surfaces
308 double CapValue; // value to use for capping
309 int AccumulationMode; // how to combine scalar values
310
311 double Gaussian(double x[3]);
312 double EccentricGaussian(double x[3]);
313 double ScalarSampling(double s) { return this->ScaleFactor * s; }
314 double PositionSampling(double) { return this->ScaleFactor; }
315
316private:
317 double Radius2;
318 double (vtkGaussianSplatter::*Sample)(double x[3]);
319 double (vtkGaussianSplatter::*SampleFactor)(double s);
320 char* Visited;
321 double Eccentricity2;
322 double* P;
323 double* N;
324 double S;
325 double Origin[3];
326 double Spacing[3];
327 double SplatDistance[3];
328 double NullValue;
329
330private:
332 void operator=(const vtkGaussianSplatter&) = delete;
333};
334
335#endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition vtkDataSet.h:63
dynamic, self-adjusting array of double
splat points into a volume with an elliptical, Gaussian distribution
friend class vtkGaussianSplatterAlgorithm
Provide access to templated helper class.
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])
Provide access to templated helper class.
static vtkGaussianSplatter * New()
Construct object with dimensions=(50,50,50); automatic computation of bounds; a splat radius of 0....
double PositionSampling(double)
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetAccumulationModeToSum()
Specify the scalar accumulation mode.
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 SetAccumulationModeToMax()
Specify the scalar accumulation mode.
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)
Compute the size of the sample bounding box automatically from the input data.
~vtkGaussianSplatter() override=default
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)
Provide access to templated helper class.
virtual void SetAccumulationMode(int)
Specify the scalar accumulation mode.
void SetSampleDimensions(int dim[3])
Set / get the dimensions of the sampling structured point set.
void SetAccumulationModeToMin()
Specify the scalar accumulation mode.
void SetSampleDimensions(int i, int j, int k)
Set / get the dimensions of the sampling structured point set.
const char * GetAccumulationModeAsString()
Specify the scalar accumulation mode.
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
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:332
#define VTK_DOUBLE_MAX
Definition vtkType.h:165