VTK: Imaging/Hybrid/vtkGaussianSplatter.h Source File

| VTK 9.3.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
76 #ifndef vtkGaussianSplatter_h
77 #define vtkGaussianSplatter_h
78
79 #include "vtkImageAlgorithm.h"
80 #include "vtkImagingHybridModule.h" // For export macro
81
82 #include <cmath> // for std::exp
83
84 #define VTK_ACCUMULATION_MODE_MIN 0
85 #define VTK_ACCUMULATION_MODE_MAX 1
86 #define VTK_ACCUMULATION_MODE_SUM 2
87
88 VTK_ABI_NAMESPACE_BEGIN
89 class vtkDoubleArray;
90 class vtkCompositeDataSet;
91 class vtkGaussianSplatterAlgorithm;
92
93 class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
94 {
95 public:
96 vtkTypeMacro(vtkGaussianSplatter, vtkImageAlgorithm);
97 void PrintSelf(ostream& os, vtkIndent indent) override;
98
104 static vtkGaussianSplatter* New();
105
107
111 void SetSampleDimensions(int i, int j, int k);
112 void SetSampleDimensions(int dim[3]);
113 vtkGetVectorMacro(SampleDimensions, int, 3);
115
117
123 vtkSetVector6Macro(ModelBounds, double);
124 vtkGetVectorMacro(ModelBounds, double, 6);
126
128
133 vtkSetClampMacro(Radius, double, 0.0, 1.0);
134 vtkGetMacro(Radius, double);
136
138
143 vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
144 vtkGetMacro(ScaleFactor, double);
146
148
153 vtkSetMacro(ExponentFactor, double);
154 vtkGetMacro(ExponentFactor, double);
156
158
163 vtkSetMacro(NormalWarping, vtkTypeBool);
164 vtkGetMacro(NormalWarping, vtkTypeBool);
165 vtkBooleanMacro(NormalWarping, vtkTypeBool);
167
169
176 vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
177 vtkGetMacro(Eccentricity, double);
179
181
184 vtkSetMacro(ScalarWarping, vtkTypeBool);
185 vtkGetMacro(ScalarWarping, vtkTypeBool);
186 vtkBooleanMacro(ScalarWarping, vtkTypeBool);
188
190
195 vtkSetMacro(Capping, vtkTypeBool);
196 vtkGetMacro(Capping, vtkTypeBool);
197 vtkBooleanMacro(Capping, vtkTypeBool);
199
201
205 vtkSetMacro(CapValue, double);
206 vtkGetMacro(CapValue, double);
208
210
216 vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
217 vtkGetMacro(AccumulationMode, int);
218 void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
219 void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
220 void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
221 const char* GetAccumulationModeAsString();
223
225
229 vtkSetMacro(NullValue, double);
230 vtkGetMacro(NullValue, double);
232
234
238 void ComputeModelBounds(vtkDataSet* input, vtkImageData* output, vtkInformation* outInfo);
239 void ComputeModelBounds(
240 vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
242
244
249 friend class vtkGaussianSplatterAlgorithm;
250 double SamplePoint(double x[3]) // for compilers who can't handle this
251 {
252 return (this->*Sample)(x);
253 }
254 void SetScalar(vtkIdType idx, double dist2, double* sPtr)
255 {
256 double v = (this->*SampleFactor)(this->S) *
257 std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
259
260 if (!this->Visited[idx])
261 {
262 this->Visited[idx] = 1;
263 *sPtr = v;
264 }
265 else
266 {
267 switch (this->AccumulationMode)
268 {
269 case VTK_ACCUMULATION_MODE_MIN:
270 if (*sPtr > v)
271 {
272 *sPtr = v;
273 }
274 break;
275 case VTK_ACCUMULATION_MODE_MAX:
276 if (*sPtr < v)
277 {
278 *sPtr = v;
279 }
280 break;
281 case VTK_ACCUMULATION_MODE_SUM:
282 *sPtr += v;
283 break;
284 }
285 } // not first visit
286 }
287
288 protected:
289 vtkGaussianSplatter();
290 ~vtkGaussianSplatter() override = default;
291
292 int FillInputPortInformation(int port, vtkInformation* info) override;
293 int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
294 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
295 void Cap(vtkDoubleArray* s);
296
297 int SampleDimensions[3]; // dimensions of volume to splat into
298 double Radius; // maximum distance splat propagates (as fraction 0->1)
299 double ExponentFactor; // scale exponent of gaussian function
300 double ModelBounds[6]; // bounding box of splatting dimensions
301 vtkTypeBool NormalWarping; // on/off warping of splat via normal
302 double Eccentricity; // elliptic distortion due to normals
303 vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
304 double ScaleFactor; // splat size influenced by scale factor
305 vtkTypeBool Capping; // Cap side of volume to close surfaces
306 double CapValue; // value to use for capping
307 int AccumulationMode; // how to combine scalar values
308
309 double Gaussian(double x[3]);
310 double EccentricGaussian(double x[3]);
311 double ScalarSampling(double s) { return this->ScaleFactor * s; }
312 double PositionSampling(double) { return this->ScaleFactor; }
313
314 private:
315 double Radius2;
316 double (vtkGaussianSplatter::*Sample)(double x[3]);
317 double (vtkGaussianSplatter::*SampleFactor)(double s);
318 char* Visited;
319 double Eccentricity2;
320 double* P;
321 double* N;
322 double S;
323 double Origin[3];
324 double Spacing[3];
325 double SplatDistance[3];
326 double NullValue;
327
328 vtkGaussianSplatter(const vtkGaussianSplatter&) = delete;
329 void operator=(const vtkGaussianSplatter&) = delete;
330 };
331
332 VTK_ABI_NAMESPACE_END
333 #endif
vtkCompositeDataSet
abstract superclass for composite (multi-block or AMR) datasets
Definition: vtkCompositeDataSet.h:51
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:40
vtkGaussianSplatter
splat points into a volume with an elliptical, Gaussian distribution
Definition: vtkGaussianSplatter.h:94
vtkGaussianSplatter::New
static vtkGaussianSplatter * New()
Construct object with dimensions=(50,50,50); automatic computation of bounds; a splat radius of 0....
vtkGaussianSplatter::Capping
vtkTypeBool Capping
Definition: vtkGaussianSplatter.h:305
vtkGaussianSplatter::EccentricGaussian
double EccentricGaussian(double x[3])
vtkGaussianSplatter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGaussianSplatter::SamplePoint
double SamplePoint(double x[3])
Provide access to templated helper class.
Definition: vtkGaussianSplatter.h:250
vtkGaussianSplatter::PositionSampling
double PositionSampling(double)
Definition: vtkGaussianSplatter.h:312
vtkGaussianSplatter::GetAccumulationModeAsString
const char * GetAccumulationModeAsString()
Specify the scalar accumulation mode.
vtkGaussianSplatter::RequestInformation
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkGaussianSplatter::SetAccumulationModeToSum
void SetAccumulationModeToSum()
Specify the scalar accumulation mode.
Definition: vtkGaussianSplatter.h:220
vtkGaussianSplatter::Cap
void Cap(vtkDoubleArray *s)
vtkGaussianSplatter::vtkGaussianSplatter
vtkGaussianSplatter()
vtkGaussianSplatter::ScalarWarping
vtkTypeBool ScalarWarping
Definition: vtkGaussianSplatter.h:303
vtkGaussianSplatter::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
vtkGaussianSplatter::ScalarSampling
double ScalarSampling(double s)
Definition: vtkGaussianSplatter.h:311
vtkGaussianSplatter::ScaleFactor
double ScaleFactor
Definition: vtkGaussianSplatter.h:304
vtkGaussianSplatter::SetAccumulationModeToMax
void SetAccumulationModeToMax()
Specify the scalar accumulation mode.
Definition: vtkGaussianSplatter.h:219
vtkGaussianSplatter::ComputeModelBounds
void ComputeModelBounds(vtkDataSet *input, vtkImageData *output, vtkInformation *outInfo)
Compute the size of the sample bounding box automatically from the input data.
vtkGaussianSplatter::ComputeModelBounds
void ComputeModelBounds(vtkCompositeDataSet *input, vtkImageData *output, vtkInformation *outInfo)
Compute the size of the sample bounding box automatically from the input data.
vtkGaussianSplatter::NormalWarping
vtkTypeBool NormalWarping
Definition: vtkGaussianSplatter.h:301
vtkGaussianSplatter::ExponentFactor
double ExponentFactor
Definition: vtkGaussianSplatter.h:299
vtkGaussianSplatter::AccumulationMode
int AccumulationMode
Definition: vtkGaussianSplatter.h:307
vtkGaussianSplatter::~vtkGaussianSplatter
~vtkGaussianSplatter() override=default
vtkGaussianSplatter::Gaussian
double Gaussian(double x[3])
vtkGaussianSplatter::Eccentricity
double Eccentricity
Definition: vtkGaussianSplatter.h:302
vtkGaussianSplatter::CapValue
double CapValue
Definition: vtkGaussianSplatter.h:306
vtkGaussianSplatter::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
vtkGaussianSplatter::SetScalar
void SetScalar(vtkIdType idx, double dist2, double *sPtr)
Provide access to templated helper class.
Definition: vtkGaussianSplatter.h:254
vtkGaussianSplatter::SetSampleDimensions
void SetSampleDimensions(int dim[3])
Set / get the dimensions of the sampling structured point set.
vtkGaussianSplatter::Radius
double Radius
Definition: vtkGaussianSplatter.h:298
vtkGaussianSplatter::SetAccumulationModeToMin
void SetAccumulationModeToMin()
Specify the scalar accumulation mode.
Definition: vtkGaussianSplatter.h:218
vtkGaussianSplatter::SetSampleDimensions
void SetSampleDimensions(int i, int j, int k)
Set / get the dimensions of the sampling structured point set.
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:39
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::port
@ port
Definition: vtkX3D.h:447
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
VTK_ACCUMULATION_MODE_SUM
#define VTK_ACCUMULATION_MODE_SUM
Definition: vtkGaussianSplatter.h:86
VTK_ACCUMULATION_MODE_MIN
#define VTK_ACCUMULATION_MODE_MIN
Definition: vtkGaussianSplatter.h:84
VTK_ACCUMULATION_MODE_MAX
#define VTK_ACCUMULATION_MODE_MAX
Definition: vtkGaussianSplatter.h:85
vtkImageAlgorithm.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154