16 #ifndef vtkOpenGLVolumeOpacityTable_h
17 #define vtkOpenGLVolumeOpacityTable_h
23 #include <vtkTextureObject.h>
62 double sampleDistance,
68 bool needUpdate =
false;
98 delete [] this->
Table;
113 float* ptr = this->
Table;
114 double factor = sampleDistance/unitDistance;
120 *ptr =
static_cast<float>(1.0-pow(1.0-static_cast<double>(*ptr),
130 float* ptr = this->
Table;
131 double factor = sampleDistance/unitDistance;
137 *ptr =
static_cast<float>(
static_cast<double>(*ptr)*factor);
169 vtkErrorMacro(
"vtkTextureObject not initialized!");
178 vtkErrorMacro(
"Failed to query max texture size! using default 1024.");
182 if (maxWidth >= idealWidth)
188 vtkWarningMacro(
"This OpenGL implementation does not support the required "
189 "texture size of " << idealWidth <<
". Falling back to maximum allowed, "
190 << maxWidth <<
"." <<
"This may cause an incorrect color table mapping.");
240 delete[] this->
Table;
271 this->Tables.reserve(static_cast<size_t>(numberOfTables));
273 for (
unsigned int i = 0; i < numberOfTables; i++)
276 this->Tables.push_back(table);
283 size_t const size = this->Tables.size();
284 for (
size_t i = 0; i <
size; i++)
286 this->Tables[i]->Delete();
292 vtkOpenGLVolumeOpacityTable*
GetTable(
unsigned int i)
294 if (i >= this->Tables.size())
298 return this->Tables[i];
305 return this->Tables.size();
311 size_t const size = this->Tables.size();
312 for (
size_t i = 0; i <
size; ++i)
314 this->Tables[i]->ReleaseGraphicsResources(window);
319 std::vector<vtkOpenGLVolumeOpacityTable*> Tables;
321 vtkOpenGLVolumeOpacityTables() VTK_DELETE_FUNCTION;
323 vtkOpenGLVolumeOpacityTables(const vtkOpenGLVolumeOpacityTables &other) VTK_DELETE_FUNCTION;
325 vtkOpenGLVolumeOpacityTables &operator=(const vtkOpenGLVolumeOpacityTables &other) VTK_DELETE_FUNCTION;
328 #endif // vtkOpenGLVolumeOpacityTable_h
~vtkOpenGLVolumeOpacityTables()
vtkOpenGLVolumeOpacityTables(unsigned int numberOfTables)
abstract base class for most VTK objects
void ReleaseGraphicsResources(vtkWindow *window)
void SetContext(vtkRenderWindow *)
Get/Set the context.
Defines a 1D piecewise function.
record modification and/or execution time
vtkTextureObject * TextureObject
void Modified()
Set this objects time to the current time.
void Deactivate(unsigned int texUnit)
Set the active tex unit and bind (using our bind).
vtkOpenGLVolumeOpacityTable * GetTable(unsigned int i)
void ReleaseGraphicsResources(vtkWindow *window)
bool Create2DFromRaw(unsigned int width, unsigned int height, int numComps, int dataType, void *data)
Create a 2D texture from client memory numComps must be in [1-4].
void GetTable(double x1, double x2, int size, float *table, int stride=1)
Fills in an array of function values evaluated at regular intervals.
window superclass for vtkRenderWindow
static int NearestPowerOfTwo(int x)
Compute the nearest power of two that is not less than x.
vtkStandardNewMacro(vtkOpenGLVolumeOpacityTable)
~vtkOpenGLVolumeOpacityTable()
virtual void SetMinificationFilter(int)
Minification filter mode.
size_t GetNumberOfTables()
virtual vtkMTimeType GetMTime()
Return this object's modified time.
void Update(vtkPiecewiseFunction *scalarOpacity, int blendMode, double sampleDistance, double range[2], double unitDistance, int filterValue, vtkOpenGLRenderWindow *renWin)
virtual unsigned int GetHandle()
Returns the OpenGL handle.
void Activate(unsigned int texUnit)
Set the active tex unit and bind (using our bind).
int GetMaximumSupportedTextureWidth(vtkOpenGLRenderWindow *renWin, int idealWidth)
abstracts an OpenGL texture object.
int EstimateMinNumberOfSamples(double const &x1, double const &x2)
Estimates the minimum size of a table such that it would correctly sample this function.
static int GetMaximumTextureSize(vtkOpenGLRenderWindow *context)
Query and return maximum texture size (dimension) supported by the OpenGL driver for a particular con...
void ReleaseGraphicsResources(vtkWindow *win)
Deactivate and UnBind the texture.
static vtkTextureObject * New()
virtual void SetWrapS(int)
Wrap mode for the first texture coordinate "s" Valid values are:
vtkOpenGLVolumeOpacityTable(int width=1024)
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
double LastSampleDistance
int GetTextureUnit()
Return the texture unit used for this texture.
static vtkOpenGLVolumeOpacityTable * New()
static T Max(const T &a, const T &b)
Returns the maximum of the two arugments provided.
virtual void Delete()
Delete a VTK object.
virtual void SetMagnificationFilter(int)
Magnification filter mode.