Thanks to visit codestin.com
Credit goes to vtk.org

VTK  9.5.20250921
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
136#ifndef vtkGaussianSplatter_h
137#define vtkGaussianSplatter_h
138
139#include "vtkImageAlgorithm.h"
140#include "vtkImagingHybridModule.h" // For export macro
141
142#include <algorithm> // std::min, std::max
143#include <cmath> // for std::exp
144
145#define VTK_ACCUMULATION_MODE_MIN 0
146#define VTK_ACCUMULATION_MODE_MAX 1
147#define VTK_ACCUMULATION_MODE_SUM 2
148
149VTK_ABI_NAMESPACE_BEGIN
150class vtkDoubleArray;
152class vtkGaussianSplatterAlgorithm;
153
154class VTKIMAGINGHYBRID_EXPORT vtkGaussianSplatter : public vtkImageAlgorithm
155{
156public:
158 void PrintSelf(ostream& os, vtkIndent indent) override;
159
166
168
172 void SetSampleDimensions(int i, int j, int k);
173 void SetSampleDimensions(int dim[3]);
174 vtkGetVectorMacro(SampleDimensions, int, 3);
176
178
184 vtkSetVector6Macro(ModelBounds, double);
185 vtkGetVectorMacro(ModelBounds, double, 6);
187
189
194 vtkSetClampMacro(Radius, double, 0.0, 1.0);
195 vtkGetMacro(Radius, double);
197
199
204 vtkSetClampMacro(ScaleFactor, double, 0.0, VTK_DOUBLE_MAX);
205 vtkGetMacro(ScaleFactor, double);
207
209
214 vtkSetMacro(ExponentFactor, double);
215 vtkGetMacro(ExponentFactor, double);
217
219
224 vtkSetMacro(NormalWarping, vtkTypeBool);
225 vtkGetMacro(NormalWarping, vtkTypeBool);
226 vtkBooleanMacro(NormalWarping, vtkTypeBool);
228
230
237 vtkSetClampMacro(Eccentricity, double, 0.001, VTK_DOUBLE_MAX);
238 vtkGetMacro(Eccentricity, double);
240
242
245 vtkSetMacro(ScalarWarping, vtkTypeBool);
246 vtkGetMacro(ScalarWarping, vtkTypeBool);
247 vtkBooleanMacro(ScalarWarping, vtkTypeBool);
249
251
256 vtkSetMacro(Capping, vtkTypeBool);
257 vtkGetMacro(Capping, vtkTypeBool);
258 vtkBooleanMacro(Capping, vtkTypeBool);
260
262
266 vtkSetMacro(CapValue, double);
267 vtkGetMacro(CapValue, double);
269
271
277 vtkSetClampMacro(AccumulationMode, int, VTK_ACCUMULATION_MODE_MIN, VTK_ACCUMULATION_MODE_SUM);
278 vtkGetMacro(AccumulationMode, int);
279 void SetAccumulationModeToMin() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MIN); }
280 void SetAccumulationModeToMax() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_MAX); }
281 void SetAccumulationModeToSum() { this->SetAccumulationMode(VTK_ACCUMULATION_MODE_SUM); }
284
286
290 vtkSetMacro(NullValue, double);
291 vtkGetMacro(NullValue, double);
293
295
301 vtkCompositeDataSet* input, vtkImageData* output, vtkInformation* outInfo);
303
305
310 friend class vtkGaussianSplatterAlgorithm;
311 double SamplePoint(double x[3]) // for compilers who can't handle this
312 {
313 return (this->*Sample)(x);
314 }
315 void SetScalar(vtkIdType idx, double dist2, double* sPtr)
316 {
317 double v =
318 (this->*SampleFactor)(this->S) * std::exp(this->ExponentFactor * (dist2) / (this->Radius2));
319
320 if (!this->Visited[idx])
321 {
322 this->Visited[idx] = 1;
323 *sPtr = v;
324 }
325 else
326 {
327 switch (this->AccumulationMode)
328 {
330 *sPtr = std::min(*sPtr, v);
331 break;
333 *sPtr = std::max(*sPtr, v);
334 break;
336 *sPtr += v;
337 break;
338 }
339 } // not first visit
340 }
342
343protected:
345 ~vtkGaussianSplatter() override = default;
346
347 int FillInputPortInformation(int port, vtkInformation* info) override;
351
352 int SampleDimensions[3]; // dimensions of volume to splat into
353 double Radius; // maximum distance splat propagates (as fraction 0->1)
354 double ExponentFactor; // scale exponent of gaussian function
355 double ModelBounds[6]; // bounding box of splatting dimensions
356 vtkTypeBool NormalWarping; // on/off warping of splat via normal
357 double Eccentricity; // elliptic distortion due to normals
358 vtkTypeBool ScalarWarping; // on/off warping of splat via scalar
359 double ScaleFactor; // splat size influenced by scale factor
360 vtkTypeBool Capping; // Cap side of volume to close surfaces
361 double CapValue; // value to use for capping
362 int AccumulationMode; // how to combine scalar values
363
364 double Gaussian(double x[3]);
365 double EccentricGaussian(double x[3]);
366 double ScalarSampling(double s) { return this->ScaleFactor * s; }
367 double PositionSampling(double) { return this->ScaleFactor; }
368
369private:
370 double Radius2;
371 double (vtkGaussianSplatter::*Sample)(double x[3]);
372 double (vtkGaussianSplatter::*SampleFactor)(double s);
373 char* Visited;
374 double Eccentricity2;
375 double* P;
376 double* N;
377 double S;
378 double Origin[3];
379 double Spacing[3];
380 double SplatDistance[3];
381 double NullValue;
382
384 void operator=(const vtkGaussianSplatter&) = delete;
385};
386
387VTK_ABI_NAMESPACE_END
388#endif
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
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:108
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:333
#define VTK_DOUBLE_MAX
Definition vtkType.h:172