VTK  9.6.1
vtkGaussianSplatter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
66
67#ifndef vtkGaussianSplatter_h
68#define vtkGaussianSplatter_h
69
70#include "vtkImageAlgorithm.h"
71#include "vtkImagingHybridModule.h" // For export macro
72
73#include <algorithm> // std::min, std::max
74#include <cmath> // for std::exp
75
76#define VTK_ACCUMULATION_MODE_MIN 0
77#define VTK_ACCUMULATION_MODE_MAX 1
78#define VTK_ACCUMULATION_MODE_SUM 2
79
80VTK_ABI_NAMESPACE_BEGIN
81class vtkDoubleArray;
83class vtkGaussianSplatterAlgorithm;
84
85class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
86{
87public:
89 void PrintSelf(ostream& os, vtkIndent indent) override;
90
97
99
103 void SetSampleDimensions(int i, int j, int k);
104 void SetSampleDimensions(int dim[3]);
105 vtkGetVectorMacro(SampleDimensions, int, 3);
107
109
115 vtkSetVector6Macro(ModelBounds, double);
116 vtkGetVectorMacro(ModelBounds, double, 6);
118
120
125 vtkSetClampMacro(Radius, double, 0.0, 1.0);
126 vtkGetMacro(Radius, double);
128
130
135 vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
136 vtkGetMacro(ScaleFactor, double);
138
140
145 vtkSetMacro(ExponentFactor, double);
146 vtkGetMacro(ExponentFactor, double);
148
150
157 vtkBooleanMacro(NormalWarping, vtkTypeBool);
159
161
168 vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
169 vtkGetMacro(Eccentricity, double);
171
173
178 vtkBooleanMacro(ScalarWarping, vtkTypeBool);
180
182
187 vtkSetMacro(Capping, vtkTypeBool);
188 vtkGetMacro(Capping, vtkTypeBool);
189 vtkBooleanMacro(Capping, vtkTypeBool);
191
193
197 vtkSetMacro(CapValue, double);
198 vtkGetMacro(CapValue, double);
200
202
209 vtkGetMacro(AccumulationMode, int);
215
217
221 vtkSetMacro(NullValue, double);
222 vtkGetMacro(NullValue, double);
224
226
232 vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
234
236
242 double SamplePoint(double x[3]) // for compilers who can't handle this
243 {
244 return (this->*Sample)(x);
245 }
246 void SetScalar(vtkIdType idx, double dist2, double* sPtr)
247 {
248 double v =
249 (this->*SampleFactor)(this->S) * std::exp(this->ExponentFactor * (dist2) / (this->Radius2));
250
251 if (!this->Visited[idx])
252 {
253 this->Visited[idx] = 1;
254 *sPtr = v;
255 }
256 else
257 {
258 switch (this->AccumulationMode)
259 {
261 *sPtr = std::min(*sPtr, v);
262 break;
264 *sPtr = std::max(*sPtr, v);
265 break;
267 *sPtr += v;
268 break;
269 }
270 } // not first visit
271 }
272
273
274protected:
276 ~vtkGaussianSplatter() override = default;
277
278 int FillInputPortInformation(int port, vtkInformation* info) override;
282
283 int SampleDimensions[3]; // dimensions of volume to splat into
284 double Radius; // maximum distance splat propagates (as fraction 0->1)
285 double ExponentFactor; // scale exponent of gaussian function
286 double ModelBounds[6]; // bounding box of splatting dimensions
287 vtkTypeBool NormalWarping; // on/off warping of splat via normal
288 double Eccentricity; // elliptic distortion due to normals
289 vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
290 double ScaleFactor; // splat size influenced by scale factor
291 vtkTypeBool Capping; // Cap side of volume to close surfaces
292 double CapValue; // value to use for capping
293 int AccumulationMode; // how to combine scalar values
294
295 double Gaussian(double x[3]);
296 double EccentricGaussian(double x[3]);
297 double ScalarSampling(double s) { return this->ScaleFactor * s; }
298 double PositionSampling(double) { return this->ScaleFactor; }
299
300private:
301 double Radius2;
302 double (vtkGaussianSplatter::*Sample)(double x[3]);
303 double (vtkGaussianSplatter::*SampleFactor)(double s);
304 char* Visited;
305 double Eccentricity2;
306 double* P;
307 double* N;
308 double S;
309 double Origin[3];
310 double Spacing[3];
311 double SplatDistance[3];
312 double NullValue;
313
315 void operator=(const vtkGaussianSplatter&) = delete;
316};
317
318VTK_ABI_NAMESPACE_END
319#endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition vtkDataSet.h:57
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
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:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_ACCUMULATION_MODE_SUM
#define VTK_ACCUMULATION_MODE_MIN
#define VTK_ACCUMULATION_MODE_MAX
int vtkIdType
Definition vtkType.h:368
#define VTK_DOUBLE_MAX
Definition vtkType.h:207