}
VISU_LookupTable::VISU_LookupTable(int sze, int ext)
- : vtkLookupTable(sze, ext), myScale(1.0) {}
+ : vtkLookupTable(sze, ext), myScale(1.0), myBicolor(false) {}
+
+void VISU_LookupTable::SetMapScale(float theScale)
+{
+ if( myScale != theScale )
+ {
+ myScale = theScale;
+ Modified();
+ }
+}
+
+void VISU_LookupTable::SetBicolor( bool theBicolor )
+{
+ if( myBicolor != theBicolor )
+ {
+ myBicolor = theBicolor;
+ Modified();
+ }
+}
+
int VISU_LookupTable::ComputeLogRange(float inRange[2], float outRange[2]){
if(inRange[0] >= inRange[1])
float aLowBound = log10(this->TableRange[0]);
v = pow(10.0f,aLowBound + (v - aLowBound)*myScale);
return vtkLookupTable::MapValue(v);
- }else{
+ } else if (!myBicolor) {
v = this->TableRange[0] + (v - this->TableRange[0])*myScale;
return vtkLookupTable::MapValue(v);
+ } else {
+ unsigned char* table = this->Table->GetPointer(0);
+ int index = v > 0 ? 4*static_cast<int>(this->GetNumberOfColors()-1) : 0;
+ return &table[index];
}
}
inline unsigned char *VISU_LinearLookup(float v,
unsigned char *table,
float maxIndex,
- float shift, float scale)
+ float shift, float scale,
+ bool bicolor)
{
- float findx = (v + shift)*scale;
- if (findx < 0)
- {
- findx = 0;
- }
- if (findx > maxIndex)
- {
- findx = maxIndex;
- }
- return &table[4*static_cast<int>(findx)];
- /* round
- return &table[4*(int)(findx + 0.5f)];
- */
+ if( !bicolor )
+ {
+ float findx = (v + shift)*scale;
+ if (findx < 0)
+ findx = 0;
+ if (findx > maxIndex)
+ findx = maxIndex;
+
+ return &table[4*static_cast<int>(findx)];
+ // round
+ //return &table[4*(int)(findx + 0.5f)];
+ }
+ else
+ {
+ int index = v > 0 ? 4*static_cast<int>(maxIndex) : 0;
+ return &table[index];
+ }
}
// accelerate the mapping by copying the data in 32-bit chunks instead
// of 8-bit chunks
template<class T>
void VISU_LookupTableMapData(vtkLookupTable *self, T *input,
- unsigned char *output, int length,
- int inIncr, int outFormat, float theMapScale)
+ unsigned char *output, int length,
+ int inIncr, int outFormat,
+ float theMapScale, bool bicolor)
{
int i = length;
float *range = self->GetTableRange();
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = cptr[3];
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = cptr[3];
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = static_cast<unsigned char>(alpha*cptr[3]);
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = static_cast<unsigned char>(cptr[3]*alpha);
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
template<class T>
void VISU_LookupTableMapMag(vtkLookupTable *self, T *input,
unsigned char *output, int length,
- int inIncr, int outFormat, float theMapScale)
+ int inIncr, int outFormat,
+ float theMapScale, bool bicolor)
{
double tmp, sum;
double *mag;
mag[i] = sqrt(sum);
}
- VISU_LookupTableMapData(self, mag, output, length, 1, outFormat, theMapScale);
+ VISU_LookupTableMapData(self, mag, output, length, 1, outFormat, theMapScale, bicolor);
delete [] mag;
}
break;
case VTK_CHAR:
VISU_LookupTableMapMag(this,static_cast<char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_CHAR:
VISU_LookupTableMapMag(this,static_cast<unsigned char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_SHORT:
VISU_LookupTableMapMag(this,static_cast<short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_SHORT:
VISU_LookupTableMapMag(this,static_cast<unsigned short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_INT:
VISU_LookupTableMapMag(this,static_cast<int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_INT:
VISU_LookupTableMapMag(this,static_cast<unsigned int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_LONG:
VISU_LookupTableMapMag(this,static_cast<long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_LONG:
VISU_LookupTableMapMag(this,static_cast<unsigned long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_FLOAT:
VISU_LookupTableMapMag(this,static_cast<float *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_DOUBLE:
VISU_LookupTableMapMag(this,static_cast<double *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
default:
vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType");
VISU_LookupTableMapData(this,
static_cast<unsigned char*>(newInput->GetPointer(0)),
output,numberOfValues,
- inputIncrement,outputFormat,myScale);
+ inputIncrement,outputFormat,myScale,myBicolor);
newInput->Delete();
bitArray->Delete();
}
case VTK_CHAR:
VISU_LookupTableMapData(this,static_cast<char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_CHAR:
VISU_LookupTableMapData(this,static_cast<unsigned char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_SHORT:
VISU_LookupTableMapData(this,static_cast<short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_SHORT:
VISU_LookupTableMapData(this,static_cast<unsigned short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_INT:
VISU_LookupTableMapData(this,static_cast<int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_INT:
VISU_LookupTableMapData(this,static_cast<unsigned int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_LONG:
VISU_LookupTableMapData(this,static_cast<long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_LONG:
VISU_LookupTableMapData(this,static_cast<unsigned long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_FLOAT:
VISU_LookupTableMapData(this,static_cast<float *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_DOUBLE:
VISU_LookupTableMapData(this,static_cast<double *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
default: