VTK  9.4.20241222
vtkEncodedGradientEstimator.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
3
22#ifndef vtkEncodedGradientEstimator_h
23#define vtkEncodedGradientEstimator_h
24
25#include "vtkObject.h"
26#include "vtkRenderingVolumeModule.h" // For export macro
27#include "vtkThreads.h" // for VTK_MAX_THREADS
28
29VTK_ABI_NAMESPACE_BEGIN
30class vtkImageData;
33
34class VTKRENDERINGVOLUME_EXPORT vtkEncodedGradientEstimator : public vtkObject
35{
36public:
38 void PrintSelf(ostream& os, vtkIndent indent) override;
39
41
49 virtual void SetInputData(vtkImageData*);
50 vtkGetObjectMacro(InputData, vtkImageData);
52
54
57 vtkSetMacro(GradientMagnitudeScale, float);
58 vtkGetMacro(GradientMagnitudeScale, float);
59 vtkSetMacro(GradientMagnitudeBias, float);
60 vtkGetMacro(GradientMagnitudeBias, float);
62
64
68 vtkSetClampMacro(BoundsClip, vtkTypeBool, 0, 1);
69 vtkGetMacro(BoundsClip, vtkTypeBool);
70 vtkBooleanMacro(BoundsClip, vtkTypeBool);
72
74
79 vtkSetVector6Macro(Bounds, int);
80 vtkGetVectorMacro(Bounds, int, 6);
82
86 void Update();
87
91 unsigned short* GetEncodedNormals();
92
94
98 int GetEncodedNormalIndex(int xIndex, int yIndex, int zIndex);
100
104 unsigned char* GetGradientMagnitudes();
105
107
111 vtkSetClampMacro(NumberOfThreads, int, 1, VTK_MAX_THREADS);
112 vtkGetMacro(NumberOfThreads, int);
114
116
121 vtkGetObjectMacro(DirectionEncoder, vtkDirectionEncoder);
123
125
131 vtkSetMacro(ComputeGradientMagnitudes, vtkTypeBool);
132 vtkGetMacro(ComputeGradientMagnitudes, vtkTypeBool);
133 vtkBooleanMacro(ComputeGradientMagnitudes, vtkTypeBool);
135
137
142 vtkSetMacro(CylinderClip, vtkTypeBool);
143 vtkGetMacro(CylinderClip, vtkTypeBool);
144 vtkBooleanMacro(CylinderClip, vtkTypeBool);
146
148
151 vtkGetMacro(LastUpdateTimeInSeconds, float);
152 vtkGetMacro(LastUpdateTimeInCPUSeconds, float);
154
155 vtkGetMacro(UseCylinderClip, int);
156 int* GetCircleLimits() { return this->CircleLimits; }
157
159
168 vtkGetMacro(ZeroNormalThreshold, float);
170
172
176 vtkSetClampMacro(ZeroPad, vtkTypeBool, 0, 1);
177 vtkGetMacro(ZeroPad, vtkTypeBool);
178 vtkBooleanMacro(ZeroPad, vtkTypeBool);
180
181 // These variables should be protected but are being
182 // made public to be accessible to the templated function.
183 // We used to have the templated function as a friend, but
184 // this does not work with all compilers
185
186 // The input scalar data on which the normals are computed
188
189 // The encoded normals (2 bytes) and the size of the encoded normals
190 unsigned short* EncodedNormals;
191 int EncodedNormalsSize[3];
192
193 // The magnitude of the gradient array and the size of this array
194 unsigned char* GradientMagnitudes;
195
196 // The time at which the normals were last built
198
199 vtkGetVectorMacro(InputSize, int, 3);
200 vtkGetVectorMacro(InputAspect, float, 3);
201
202protected:
205
207
208 // The number of threads to use when encoding normals
210
212
214
215 virtual void UpdateNormals() = 0;
216
219
222
224
229 void ComputeCircleLimits(int size);
230
232 int Bounds[6];
233
234 int InputSize[3];
235 float InputAspect[3];
236
238
240
241private:
243 void operator=(const vtkEncodedGradientEstimator&) = delete;
244};
245
246VTK_ABI_NAMESPACE_END
247#endif
encode a direction into a one or two byte value
Superclass for gradient estimation.
virtual void UpdateNormals()=0
void ComputeCircleLimits(int size)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
~vtkEncodedGradientEstimator() override
virtual void SetInputData(vtkImageData *)
Set/Get the scalar input for which the normals will be calculated.
unsigned short * GetEncodedNormals()
Get the encoded normals.
void ReportReferences(vtkGarbageCollector *) override
void SetDirectionEncoder(vtkDirectionEncoder *direnc)
Set / Get the direction encoder used to encode normal directions to fit within two bytes.
void SetZeroNormalThreshold(float v)
Set / Get the ZeroNormalThreshold - this defines the minimum magnitude of a gradient that is consider...
unsigned char * GetGradientMagnitudes()
Get the gradient magnitudes.
int GetEncodedNormalIndex(int xIndex, int yIndex, int zIndex)
Get the encoded normal at an x,y,z location in the volume.
int GetEncodedNormalIndex(vtkIdType xyzIndex)
Get the encoded normal at an x,y,z location in the volume.
void Update()
Recompute the encoded normals and gradient magnitudes.
Detect and break reference loops.
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
A class for performing multithreaded execution.
abstract base class for most VTK objects
Definition vtkObject.h:162
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:315