VTK  9.1.0
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=========================================================================*/
82#ifndef vtkGaussianSplatter_h
83#define vtkGaussianSplatter_h
84
85#include "vtkImageAlgorithm.h"
86#include "vtkImagingHybridModule.h" // For export macro
87
88#include <cmath> // for std::exp
89
90#define VTK_ACCUMULATION_MODE_MIN 0
91#define VTK_ACCUMULATION_MODE_MAX 1
92#define VTK_ACCUMULATION_MODE_SUM 2
93
94class vtkDoubleArray;
96class vtkGaussianSplatterAlgorithm;
97
98class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
99{
100public:
102 void PrintSelf(ostream& os, vtkIndent indent) override;
103
110
112
116 void SetSampleDimensions(int i, int j, int k);
117 void SetSampleDimensions(int dim[3]);
118 vtkGetVectorMacro(SampleDimensions, int, 3);
120
122
128 vtkSetVector6Macro(ModelBounds, double);
129 vtkGetVectorMacro(ModelBounds, double, 6);
131
133
138 vtkSetClampMacro(Radius, double, 0.0, 1.0);
139 vtkGetMacro(Radius, double);
141
143
148 vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
149 vtkGetMacro(ScaleFactor, double);
151
153
158 vtkSetMacro(ExponentFactor, double);
159 vtkGetMacro(ExponentFactor, double);
161
163
168 vtkSetMacro(NormalWarping, vtkTypeBool);
169 vtkGetMacro(NormalWarping, vtkTypeBool);
170 vtkBooleanMacro(NormalWarping, vtkTypeBool);
172
174
181 vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
182 vtkGetMacro(Eccentricity, double);
184
186
189 vtkSetMacro(ScalarWarping, vtkTypeBool);
190 vtkGetMacro(ScalarWarping, vtkTypeBool);
191 vtkBooleanMacro(ScalarWarping, vtkTypeBool);
193
195
200 vtkSetMacro(Capping, vtkTypeBool);
201 vtkGetMacro(Capping, vtkTypeBool);
202 vtkBooleanMacro(Capping, vtkTypeBool);
204
206
210 vtkSetMacro(CapValue, double);
211 vtkGetMacro(CapValue, double);
213
215
221 vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
222 vtkGetMacro(AccumulationMode, int);
223 void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
224 void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
225 void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
228
230
234 vtkSetMacro(NullValue, double);
235 vtkGetMacro(NullValue, double);
237
239
245 vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
247
249
254 friend class vtkGaussianSplatterAlgorithm;
255 double SamplePoint(double x[3]) // for compilers who can't handle this
256 {
257 return (this->*Sample)(x);
258 }
259 void SetScalar(vtkIdType idx, double dist2, double* sPtr)
260 {
261 double v = (this->*SampleFactor)(this->S) *
262 std::exp(static_cast<double>(this->ExponentFactor * (dist2) / (this->Radius2)));
264
265 if (!this->Visited[idx])
266 {
267 this->Visited[idx] = 1;
268 *sPtr = v;
269 }
270 else
271 {
272 switch (this->AccumulationMode)
273 {
275 if (*sPtr > v)
276 {
277 *sPtr = v;
278 }
279 break;
281 if (*sPtr < v)
282 {
283 *sPtr = v;
284 }
285 break;
287 *sPtr += v;
288 break;
289 }
290 } // not first visit
291 }
292
293protected:
295 ~vtkGaussianSplatter() override = default;
296
301
302 int SampleDimensions[3]; // dimensions of volume to splat into
303 double Radius; // maximum distance splat propagates (as fraction 0->1)
304 double ExponentFactor; // scale exponent of gaussian function
305 double ModelBounds[6]; // bounding box of splatting dimensions
306 vtkTypeBool NormalWarping; // on/off warping of splat via normal
307 double Eccentricity; // elliptic distortion due to normals
308 vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
309 double ScaleFactor; // splat size influenced by scale factor
310 vtkTypeBool Capping; // Cap side of volume to close surfaces
311 double CapValue; // value to use for capping
312 int AccumulationMode; // how to combine scalar values
313
314 double Gaussian(double x[3]);
315 double EccentricGaussian(double x[3]);
316 double ScalarSampling(double s) { return this->ScaleFactor * s; }
317 double PositionSampling(double) { return this->ScaleFactor; }
318
319private:
320 double Radius2;
321 double (vtkGaussianSplatter::*Sample)(double x[3]);
322 double (vtkGaussianSplatter::*SampleFactor)(double s);
323 char* Visited;
324 double Eccentricity2;
325 double* P;
326 double* N;
327 double S;
328 double Origin[3];
329 double Spacing[3];
330 double SplatDistance[3];
331 double NullValue;
332
333private:
335 void operator=(const vtkGaussianSplatter&) = delete;
336};
337
338#endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:66
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
These method should be reimplemented by subclasses that have more than a single input or single outpu...
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
Definition: vtkImageData.h:57
a simple class to control print indentation
Definition: vtkIndent.h:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
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