16 #ifndef vtkOpenGLVolumeGradientOpacityTable_h
17 #define vtkOpenGLVolumeGradientOpacityTable_h
23 #include <vtkTextureObject.h>
59 double sampleDistance,
61 double vtkNotUsed(unitDistance),
65 bool needUpdate=
false;
82 if(gradientOpacity->
GetMTime() > this->BuildTime ||
83 this->TextureObject->GetMTime() > this->BuildTime ||
84 this->LastSampleDistance != sampleDistance ||
85 needUpdate || !this->TextureObject->GetHandle())
94 delete [] this->
Table;
126 vtkErrorMacro(
"vtkTextureObject not initialized!");
135 vtkErrorMacro(
"Failed to query max texture size! using default 1024.");
139 if (maxWidth >= idealWidth)
145 vtkWarningMacro(
"This OpenGL implementation does not support the required "
146 "texture size of " << idealWidth <<
", falling back to maximum allowed, "
147 << maxWidth <<
"." <<
"This may cause an incorrect color table mapping.");
195 delete[] this->
Table;
224 this->Tables.reserve(
static_cast<size_t>(numberOfTables));
226 for (
unsigned int i = 0; i < numberOfTables; i++)
230 this->Tables.push_back(table);
237 size_t const size = this->Tables.size();
238 for (
size_t i = 0; i <
size; i++)
240 this->Tables[i]->Delete();
248 if (i >= this->Tables.size())
252 return this->Tables[i];
259 return this->Tables.size();
265 size_t const size = this->Tables.size();
266 for (
size_t i = 0; i <
size; ++i)
268 this->Tables[i]->ReleaseGraphicsResources(window);
272 std::vector<vtkOpenGLVolumeGradientOpacityTable*> Tables;
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
static T Max(const T &a, const T &b)
Returns the maximum of the two arugments provided.
static int NearestPowerOfTwo(int x)
Compute the nearest power of two that is not less than x.
virtual void Delete()
Delete a VTK object.
abstract base class for most VTK objects
~vtkOpenGLVolumeGradientOpacityTable()
double LastSampleDistance
void ReleaseGraphicsResources(vtkWindow *window)
void Update(vtkPiecewiseFunction *gradientOpacity, double sampleDistance, double range[2], double vtkNotUsed(unitDistance), int filterValue, vtkOpenGLRenderWindow *renWin)
vtkTextureObject * TextureObject
vtkOpenGLVolumeGradientOpacityTable(int width=1024)
int GetMaximumSupportedTextureWidth(vtkOpenGLRenderWindow *renWin, int idealWidth)
static vtkOpenGLVolumeGradientOpacityTable * New()
~vtkOpenGLVolumeGradientOpacityTables()
size_t GetNumberOfTables()
void ReleaseGraphicsResources(vtkWindow *window)
vtkOpenGLVolumeGradientOpacityTables(unsigned int numberOfTables)
vtkOpenGLVolumeGradientOpacityTable * GetTable(unsigned int i)
Defines a 1D piecewise function.
void GetTable(double x1, double x2, int size, float *table, int stride=1)
Fills in an array of function values evaluated at regular intervals.
int EstimateMinNumberOfSamples(double const &x1, double const &x2)
Estimates the minimum size of a table such that it would correctly sample this function.
abstracts an OpenGL texture object.
void Deactivate(unsigned int texUnit)
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 ReleaseGraphicsResources(vtkWindow *win)
Deactivate and UnBind the texture.
virtual void SetMagnificationFilter(int)
int GetTextureUnit()
Return the texture unit used for this texture.
static vtkTextureObject * New()
static int GetMaximumTextureSize(vtkOpenGLRenderWindow *context)
Query and return maximum texture size (dimension) supported by the OpenGL driver for a particular con...
void Activate(unsigned int texUnit)
Set the active tex unit and bind (using our bind).
virtual void SetMinificationFilter(int)
virtual void SetWrapS(int)
void SetContext(vtkRenderWindow *)
Get/Set the context.
record modification and/or execution time
void Modified()
Set this objects time to the current time.
window superclass for vtkRenderWindow
vtkStandardNewMacro(vtkOpenGLVolumeGradientOpacityTable)