16 #ifndef vtkVolumeMask_h_
17 #define vtkVolumeMask_h_
21 #include <vtkOpenGLRenderWindow.h>
24 #include <vtkTextureObject.h>
81 const char* arrayName,
84 bool needUpdate =
false;
85 bool modified =
false;
101 int obsolete = needUpdate || !this->
Loaded ||
107 while(!obsolete && i<6)
109 obsolete = obsolete || this->
LoadedExtent[i]>textureExtent[i];
111 obsolete = obsolete || this->
LoadedExtent[i]<textureExtent[i];
132 cout <<
"Mask should be VTK_UNSIGNED_CHAR." << endl;
136 cout <<
"Mask should be a one-component scalar field." << endl;
139 GLint internalFormat = GL_R8;
140 GLenum format = GL_RED;
141 GLenum
type = GL_UNSIGNED_BYTE;
148 textureSize[i] = textureExtent[2*i+1] - textureExtent[2*i] + 1;
153 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &width);
154 this->
Loaded = textureSize[0] <= width && textureSize[1] <= width &&
155 textureSize[2] <= width;
159 this->
Loaded = textureSize[0] * textureSize[1]*
166 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
168 if(!(textureExtent[1]-textureExtent[0]+cellFlag==dim[0]))
170 glPixelStorei(GL_UNPACK_ROW_LENGTH,dim[0]-cellFlag);
172 if(!(textureExtent[3]-textureExtent[2]+cellFlag==dim[1]))
174 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT_EXT,
178 ((textureExtent[4]*(dim[1]-cellFlag)+textureExtent[2]) *
179 (dim[0]-cellFlag)+textureExtent[0]) *
186 textureSize[0], textureSize[1], textureSize[2],
187 1, scalarType, dataPtr);
196 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
197 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT_EXT, 0);
212 swapBounds[0] = (spacing[0] < 0);
213 swapBounds[1] = (spacing[1] < 0);
214 swapBounds[2] = (spacing[2] < 0);
230 static_cast<double>(this->
LoadedExtent[0+swapBounds[0]])*spacing[0];
232 static_cast<double>(this->
LoadedExtent[2+swapBounds[1]])*spacing[1];
233 this->LoadedBounds[4]=origin[2]+
234 static_cast<double>(this->
LoadedExtent[4+swapBounds[2]])*spacing[2];
235 this->LoadedBounds[1]=origin[0]+
236 static_cast<double>(this->
LoadedExtent[1-swapBounds[0]])*spacing[0];
237 this->LoadedBounds[3]=origin[1]+
238 static_cast<double>(this->
LoadedExtent[3-swapBounds[1]])*spacing[1];
239 this->LoadedBounds[5]=origin[2]+
240 static_cast<double>(this->
LoadedExtent[5-swapBounds[2]])*spacing[2];
245 int wholeTextureExtent[6];
250 wholeTextureExtent[i]--;
264 (
static_cast<double>(this->
LoadedExtent[2*i])+0.5)*spacing[i];
267 if(this->
LoadedExtent[2*i+1]==wholeTextureExtent[2*i+1])
270 (
static_cast<double>(this->
LoadedExtent[2*i+1])+1.0)*spacing[i];
275 (
static_cast<double>(this->
LoadedExtent[2*i+1])+0.5)*spacing[i];
353 std::map<vtkImageData *,vtkVolumeMask*>
Map;
362 #endif // vtkVolumeMask_h_
vtkIdType * GetLoadedExtent()
void SetContext(vtkRenderWindow *)
vtkTimeStamp GetBuildTime()
virtual int GetDataTypeSize()=0
static vtkOpenGLRenderWindow * SafeDownCast(vtkObjectBase *o)
vtkIdType LoadedExtent[6]
record modification and/or execution time
static vtkDataArray * GetScalars(vtkDataSet *input, int scalarMode, int arrayAccessMode, int arrayId, const char *arrayName, int &cellFlag)
abstract specification for renderers
void Deactivate(unsigned int texUnit)
virtual int GetDataType()=0
virtual void SetWrapR(int)
void SetDataType(unsigned int glType)
virtual void SetBorderColor(float, float, float, float)
double * GetLoadedBounds()
int GetNumberOfComponents()
vtkTextureObject * Texture
void ReleaseGraphicsResources(vtkWindow *window)
window superclass for vtkRenderWindow
unsigned long int GetMTime()
virtual int * GetDimensions()
virtual double * GetOrigin()
bool Create3DFromRaw(unsigned int width, unsigned int height, unsigned int depth, int numComps, int dataType, void *data)
topologically and geometrically regular array of data
virtual void SetMinificationFilter(int)
abstract superclass for arrays of numeric data
virtual double * GetSpacing()
virtual unsigned int GetHandle()
void Activate(unsigned int texUnit)
void SetInternalFormat(unsigned int glInternalFormat)
virtual int * GetExtent()
void Update(vtkRenderer *ren, vtkImageData *input, int cellFlag, int textureExtent[6], int scalarMode, int arrayAccessMode, int arrayId, const char *arrayName, vtkIdType maxMemoryInBytes)
virtual void * GetVoidPointer(vtkIdType id)=0
abstracts an OpenGL texture object.
#define VTK_UNSIGNED_CHAR
std::map< vtkImageData *, vtkVolumeMask * > Map
void ReleaseGraphicsResources(vtkWindow *win)
static vtkTextureObject * New()
virtual void SetWrapS(int)
vtkRenderWindow * GetRenderWindow()
virtual void SetWrapT(int)
void SetFormat(unsigned int glFormat)
virtual void SetMagnificationFilter(int)