VTK  9.3.0
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
67#ifndef vtkGaussianSplatter_h
68#define vtkGaussianSplatter_h
69
70#include "vtkImageAlgorithm.h"
71#include "vtkImagingHybridModule.h" // For export macro
72
73#include <cmath> // for std::exp
74
75#define VTK_ACCUMULATION_MODE_MIN 0
76#define VTK_ACCUMULATION_MODE_MAX 1
77#define VTK_ACCUMULATION_MODE_SUM 2
78
79VTK_ABI_NAMESPACE_BEGIN
80class vtkDoubleArray;
82class vtkGaussianSplatterAlgorithm;
83
84class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
85{
86public:
88 void PrintSelf(ostream& os, vtkIndent indent) override;
89
96
98
102 void SetSampleDimensions(int i, int j, int k);
103 void SetSampleDimensions(int dim[3]);
104 vtkGetVectorMacro(SampleDimensions, int, 3);
106
108
114 vtkSetVector6Macro(ModelBounds, double);
115 vtkGetVectorMacro(ModelBounds, double, 6);
117
119
124 vtkSetClampMacro(Radius, double, 0.0, 1.0);
125 vtkGetMacro(Radius, double);
127
129
134 vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
135 vtkGetMacro(ScaleFactor, double);
137
139
144 vtkSetMacro(ExponentFactor, double);
145 vtkGetMacro(ExponentFactor, double);
147
149
154 vtkSetMacro(NormalWarping, vtkTypeBool);
155 vtkGetMacro(NormalWarping, vtkTypeBool);
156 vtkBooleanMacro(NormalWarping, vtkTypeBool);
158
160
167 vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
168 vtkGetMacro(Eccentricity, double);
170
172
175 vtkSetMacro(ScalarWarping, vtkTypeBool);
176 vtkGetMacro(ScalarWarping, vtkTypeBool);
177 vtkBooleanMacro(ScalarWarping, vtkTypeBool);
179
181
186 vtkSetMacro(Capping, vtkTypeBool);
187 vtkGetMacro(Capping, vtkTypeBool);
188 vtkBooleanMacro(Capping, vtkTypeBool);
190
192
196 vtkSetMacro(CapValue, double);
197 vtkGetMacro(CapValue, double);
199
201
207 vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
208 vtkGetMacro(AccumulationMode, int);
209 void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
210 void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
211 void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
214
216
220 vtkSetMacro(NullValue, double);
221 vtkGetMacro(NullValue, double);
223
225
231 vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
233
235
240 friend class vtkGaussianSplatterAlgorithm;
241 double SamplePoint(double x[3]) // for compilers who can't handle this
242 {
243 return (this->*Sample)(x);
244 }
245 void SetScalar(vtkIdType idx, double dist2, double* sPtr)
246 {
247 double v = (this->*SampleFactor)(this->S) *
248 std::exp(static_cast<double>(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 if (*sPtr > v)
262 {
263 *sPtr = v;
264 }
265 break;
267 if (*sPtr < v)
268 {
269 *sPtr = v;
270 }
271 break;
273 *sPtr += v;
274 break;
275 }
276 } // not first visit
277 }
278
279protected:
281 ~vtkGaussianSplatter() override = default;
282
283 int FillInputPortInformation(int port, vtkInformation* info) override;
287
288 int SampleDimensions[3]; // dimensions of volume to splat into
289 double Radius; // maximum distance splat propagates (as fraction 0->1)
290 double ExponentFactor; // scale exponent of gaussian function
291 double ModelBounds[6]; // bounding box of splatting dimensions
292 vtkTypeBool NormalWarping; // on/off warping of splat via normal
293 double Eccentricity; // elliptic distortion due to normals
294 vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
295 double ScaleFactor; // splat size influenced by scale factor
296 vtkTypeBool Capping; // Cap side of volume to close surfaces
297 double CapValue; // value to use for capping
298 int AccumulationMode; // how to combine scalar values
299
300 double Gaussian(double x[3]);
301 double EccentricGaussian(double x[3]);
302 double ScalarSampling(double s) { return this->ScaleFactor * s; }
303 double PositionSampling(double) { return this->ScaleFactor; }
304
305private:
306 double Radius2;
307 double (vtkGaussianSplatter::*Sample)(double x[3]);
308 double (vtkGaussianSplatter::*SampleFactor)(double s);
309 char* Visited;
310 double Eccentricity2;
311 double* P;
312 double* N;
313 double S;
314 double Origin[3];
315 double Spacing[3];
316 double SplatDistance[3];
317 double NullValue;
318
320 void operator=(const vtkGaussianSplatter&) = delete;
321};
322
323VTK_ABI_NAMESPACE_END
324#endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition vtkDataSet.h:53
dynamic, self-adjusting array of double
splat points into a volume with an elliptical, Gaussian distribution
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.
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.
Generic algorithm superclass for image algs.
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:315
#define VTK_DOUBLE_MAX
Definition vtkType.h:154