Commit 091552c1 authored by Ken Martin's avatar Ken Martin

Add ability to adjust the table size

parent edc24bde
......@@ -30,6 +30,7 @@ vtkPointGaussianMapper::vtkPointGaussianMapper()
this->ScalarOpacityFunction = 0;
this->DefaultRadius = 1.0;
this->Emissive = 1;
this->OpacityTableSize = 1024;
}
//-----------------------------------------------------------------------------
......@@ -51,4 +52,5 @@ void vtkPointGaussianMapper::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "SplatShaderCode: " << (this->SplatShaderCode ? this->SplatShaderCode : "(none)") << "\n";
os << indent << "Default Radius: " << this->DefaultRadius << "\n";
os << indent << "Emissive: " << this->Emissive << "\n";
os << indent << "OpacityTableSize: " << this->OpacityTableSize << "\n";
}
......@@ -57,6 +57,12 @@ public:
void SetScalarOpacityFunction(vtkPiecewiseFunction *);
vtkGetObjectMacro(ScalarOpacityFunction,vtkPiecewiseFunction);
// Description:
// The size of the table used in computing opacities, used when
// converting a vtkPiecewiseFunction to a table
vtkSetMacro(OpacityTableSize, int);
vtkGetMacro(OpacityTableSize, int);
// Description:
// Method to set the optional opacity array. If specified this
// array will be used to generate the opacity values.
......@@ -86,6 +92,7 @@ protected:
double DefaultRadius;
int Emissive;
int OpacityTableSize;
private:
vtkPointGaussianMapper(const vtkPointGaussianMapper&); // Not implemented.
......
......@@ -92,6 +92,8 @@ int TestPointGaussianMapperOpacity(int argc, char *argv[])
mapper->EmissiveOff();
// show other shader examples
// the fragment that is rendered is that of a triangle
// large enough to encompass a circle of radius 3
mapper->SetSplatShaderCode(
// this first line keeps the default color opacity calcs
// which you can then modify with additional code below
......
......@@ -597,13 +597,14 @@ void vtkOpenGLPointGaussianMapperHelper::BuildOpacityArray(vtkPolyData *poly)
// if a piecewise function was provided, use it to map the opacities
vtkPiecewiseFunction *pwf = this->Owner->GetScalarOpacityFunction();
float table[1025];
int tableSize = this->Owner->GetOpacityTableSize();
float *table = new float[tableSize+1];
if (pwf)
{
// build the interpolation table
pwf->GetTable(range[0],range[1],1024,table);
pwf->GetTable(range[0],range[1],tableSize,table);
// duplicate the last value for bilinear interp edge case
table[1024] = table[1023];
table[tableSize] = table[tableSize-1];
}
vtkCellArray *verts = poly->GetVerts();
......@@ -619,7 +620,7 @@ void vtkOpenGLPointGaussianMapperHelper::BuildOpacityArray(vtkPolyData *poly)
float value = oda->GetComponent(indices[i],0);
if (pwf)
{
float index = 1023.0*(value - range[0])/(range[1] - range[0]);
float index = (tableSize - 1.0)*(value - range[0])/(range[1] - range[0]);
int iindex = static_cast<int>(index);
value = (1.0 - index + iindex)*table[iindex] + (index - iindex)*table[iindex+1];
}
......@@ -636,7 +637,7 @@ void vtkOpenGLPointGaussianMapperHelper::BuildOpacityArray(vtkPolyData *poly)
float value = oda->GetComponent(i,0);
if (pwf)
{
float index = 1023.0*(value - range[0])/(range[1] - range[0]);
float index = (tableSize-1.0)*(value - range[0])/(range[1] - range[0]);
int iindex = static_cast<int>(index);
value = (1.0 - index + iindex)*table[iindex] + (index - iindex)*table[iindex+1];
}
......@@ -644,6 +645,8 @@ void vtkOpenGLPointGaussianMapperHelper::BuildOpacityArray(vtkPolyData *poly)
count++;
}
}
delete [] table;
}
//-------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment