Commit 3e366c92 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Changed name of CScalars to UCScalar; CArray to UCArray.

parent e8bfe291
......@@ -24,7 +24,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#define __vtkAGraymap_h
#include "CoScalar.hh"
#include "CArray.hh"
#include "UCArray.hh"
class vtkAGraymap : public vtkColorScalars
{
......@@ -60,7 +60,7 @@ public:
int InsertNextColor(unsigned char rgba[4]);
protected:
vtkCharArray S;
vtkUnsignedCharArray S;
};
// Description:
......
......@@ -24,7 +24,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#define __vtkAPixmap_h
#include "CoScalar.hh"
#include "CArray.hh"
#include "UCArray.hh"
class vtkAPixmap : public vtkColorScalars
{
......@@ -59,7 +59,7 @@ public:
int InsertNextColor(unsigned char rgba[4]);
protected:
vtkCharArray S;
vtkUnsignedCharArray S;
};
// Description:
......
......@@ -45,7 +45,7 @@ public:
// vtkScalars interface
char *GetScalarType() {return "ColorScalar";};
char *GetDataType() {return "char";};
char *GetDataType() {return "unsigned char";};
float GetScalar(int i);
void SetScalar(int i, float s);
void InsertScalar(int i, float s);
......
......@@ -23,7 +23,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#define __vtkGraymap_h
#include "CoScalar.hh"
#include "CArray.hh"
#include "UCArray.hh"
class vtkGraymap : public vtkColorScalars
{
......@@ -57,7 +57,7 @@ public:
int InsertNextColor(unsigned char rgba[4]);
protected:
vtkCharArray S;
vtkUnsignedCharArray S;
};
// Description:
......
......@@ -13,7 +13,6 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vtkImplicitTextureCoords - generate 1D, 2D, or 3D texture coordinates based on implicit function(s)
// .SECTION Description
// vtkImplicitTextureCoords is a filter to generate 1D, 2D, or 3D texture
......@@ -22,15 +21,24 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// can be used to highlight (via color or intensity) or cut (via
// transparency) dataset geometry without any complex geometric processing.
// (Note: the texture coordinates are refered to as r-s-t coordinates).
// Note: use the transformation capabilities of vtkImplicitFunction to
// orient, translate, and scale the implicit functions.
// The texture coordinates are automatically normalized to lie between (0,1).
// Thus, no matter what the implicit functions evaluate to, the resulting texture
// coordinates lie between (0,1), with the zero implicit function value mapped
// to the 0.5 texture coordinates value. Depending upon the maximum
// negative/positive implicit function values, the full (0,1) range may not be
// occupied (i.e., the positive/negative ranges are mapped using the same scale
// factor).
// .SECTION Caveats
// You can use the transformation capabilities of vtkImplicitFunction to
// orient, translate, and scale the implicit functions. Also, the dimension of
// the texture coordinates is implicitly defined by the number of implicit
// functions defined.
#ifndef __vtkImplicitTextureCoords_h
#define __vtkImplicitTextureCoords_h
#include "DS2DSF.hh"
#include "ImpFunc.hh"
#include "Trans.hh"
class vtkImplicitTextureCoords : public vtkDataSetToDataSetFilter
{
......@@ -40,68 +48,26 @@ public:
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Specify the dimension of the texture coordinates. Note: if the number of
// implicit functions is less than the specified dimension, then the extra
// coordinate values are set to zero.
vtkSetClampMacro(Dimension,int,1,3);
vtkGetMacro(Dimension,int);
// Description:
// Specify a quadric function to compute the r texture coordinate.
// Specify an implicit function to compute the r texture coordinate.
vtkSetObjectMacro(RFunction,vtkImplicitFunction);
vtkGetObjectMacro(RFunction,vtkImplicitFunction);
// Description:
// Specify a quadric function to compute the s texture coordinate.
// Specify a implicit function to compute the s texture coordinate.
vtkSetObjectMacro(SFunction,vtkImplicitFunction);
vtkGetObjectMacro(SFunction,vtkImplicitFunction);
// Description:
// Specify a quadric function to compute the t texture coordinate.
// Specify a implicit function to compute the t texture coordinate.
vtkSetObjectMacro(TFunction,vtkImplicitFunction);
vtkGetObjectMacro(TFunction,vtkImplicitFunction);
// Description:
// Specify a number to scale the implicit function.
vtkSetMacro(ScaleFactor,float);
vtkGetMacro(ScaleFactor,float);
// Description:
// Turn on/off texture coordinate clamping to range specified.
vtkSetMacro(Clamp,int);
vtkGetMacro(Clamp,int);
vtkBooleanMacro(Clamp,int);
// Description:
// Set r texture coordinate range,
vtkSetVector2Macro(RRange,float);
vtkGetVectorMacro(RRange,float,2);
// Description:
// Set s texture coordinate range,
vtkSetVector2Macro(SRange,float);
vtkGetVectorMacro(SRange,float,2);
// Description:
// Set t texture coordinate range,
vtkSetVector2Macro(TRange,float);
vtkGetVectorMacro(TRange,float,2);
protected:
void Execute();
int Dimension;
vtkImplicitFunction *RFunction;
vtkImplicitFunction *SFunction;
vtkImplicitFunction *TFunction;
float ScaleFactor;
int Clamp;
float RRange[2];
float SRange[2];
float TRange[2];
};
#endif
......
......@@ -42,7 +42,7 @@ public:
virtual vtkNormals *MakeObject(int sze, int ext=1000) = 0;
// Description:
// Return data type. One of "bit", "char", "short", "int", "float", or
// Return data type. One of "bit", "unsigned char", "short", "int", "float", or
// "double".
virtual char *GetDataType() = 0;
......
......@@ -23,7 +23,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#define __vtkPixmap_h
#include "CoScalar.hh"
#include "CArray.hh"
#include "UCArray.hh"
class vtkPixmap : public vtkColorScalars
{
......@@ -58,7 +58,7 @@ public:
int InsertNextColor(unsigned char rgba[4]);
protected:
vtkCharArray S;
vtkUnsignedCharArray S;
};
// Description:
......
......@@ -51,7 +51,7 @@ public:
virtual vtkScalars *MakeObject(int sze, int ext=1000) = 0;
// Description:
// Return data type. One of "bit", "char", "short", "int", "float", or
// Return data type. One of "bit", "unsigned char", "short", "int", "float", or
// "double".
virtual char *GetDataType() = 0;
......
......@@ -43,7 +43,7 @@ public:
virtual vtkTCoords *MakeObject(int sze, int d=2, int ext=1000) = 0;
// Description:
// Return data type. One of "bit", "char", "short", "int", "float", or
// Return data type. One of "bit", "unsigned char", "short", "int", "float", or
// "double".
virtual char *GetDataType() = 0;
......
......@@ -42,7 +42,7 @@ public:
virtual vtkTensors *MakeObject(int sze, int d=3, int ext=1000) = 0;
// Description:
// Return data type. One of "bit", "char", "short", "int", "float", or
// Return data type. One of "bit", "unsigned char", "short", "int", "float", or
// "double".
virtual char *GetDataType() = 0;
......
/*=========================================================================
Program: Visualization Toolkit
Module: CArray.hh
Module: UCArray.hh
Language: C++
Date: $Date$
Version: $Revision$
......@@ -13,39 +13,39 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vtkCharArray - dynamic, self adjusting unssigned character array
// .NAME vtkUnsignedCharArray - dynamic, self adjusting unsigned character array
// .SECTION Description
// vtkCharArray is an array of unsigned character values. It provides methods
// for insertion and retrieval of characters, and will automatically
// vtkUnsignedCharArray is an array of unsigned character values. It provides
// methods for insertion and retrieval of characters, and will automatically
// resize itself to hold new data.
#ifndef __vtkCharArray_h
#define __vtkCharArray_h
#ifndef __vtkUnsignedCharArray_h
#define __vtkUnsignedCharArray_h
#include "Object.hh"
class vtkCharArray : public vtkObject
class vtkUnsignedCharArray : public vtkObject
{
public:
vtkCharArray():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
vtkUnsignedCharArray():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
int Allocate(const int sz, const int ext=1000);
void Initialize();
vtkCharArray(const int sz, const int ext=1000);
vtkCharArray(const vtkCharArray& ia);
~vtkCharArray();
virtual char *GetClassName() {return "vtkCharArray";};
vtkUnsignedCharArray(const int sz, const int ext=1000);
vtkUnsignedCharArray(const vtkUnsignedCharArray& ia);
~vtkUnsignedCharArray();
virtual char *GetClassName() {return "vtkUnsignedCharArray";};
void PrintSelf(ostream& os, vtkIndent indent);
// access/insertion methods
unsigned char GetValue(const int id);
vtkCharArray &InsertValue(const int id, const unsigned char c);
vtkUnsignedCharArray &InsertValue(const int id, const unsigned char c);
int InsertNextValue(const unsigned char c);
unsigned char *GetPtr(const int id);
unsigned char *WritePtr(const int id, const int number);
// special operators
vtkCharArray &operator=(const vtkCharArray& ia);
void operator+=(const vtkCharArray& ia);
vtkUnsignedCharArray &operator=(const vtkUnsignedCharArray& ia);
void operator+=(const vtkUnsignedCharArray& ia);
void operator+=(const unsigned char c);
unsigned char& operator[](const int i);
......@@ -65,17 +65,17 @@ private:
// Description:
// Get the data at a particular index.
inline unsigned char vtkCharArray::GetValue(const int id) {return this->Array[id];};
inline unsigned char vtkUnsignedCharArray::GetValue(const int id) {return this->Array[id];};
// Description:
// Get the address of a particular data index.
inline unsigned char *vtkCharArray::GetPtr(const int id) {return this->Array + id;};
inline unsigned char *vtkUnsignedCharArray::GetPtr(const int id) {return this->Array + id;};
// Description:
// Get the address of a particular data index. Make sure data is allocated
// for the number of items requested. Set MaxId according to the number of
// data values requested.
inline unsigned char *vtkCharArray::WritePtr(const int id, const int number)
inline unsigned char *vtkUnsignedCharArray::WritePtr(const int id, const int number)
{
if ( (id + number) > this->Size ) this->Resize(id+number);
this->MaxId = id + number - 1;
......@@ -84,7 +84,7 @@ inline unsigned char *vtkCharArray::WritePtr(const int id, const int number)
// Description:
// Insert data at a specified position in the array.
inline vtkCharArray& vtkCharArray::InsertValue(const int id, const unsigned char c)
inline vtkUnsignedCharArray& vtkUnsignedCharArray::InsertValue(const int id, const unsigned char c)
{
if ( id >= this->Size ) this->Resize(id);
this->Array[id] = c;
......@@ -94,12 +94,12 @@ inline vtkCharArray& vtkCharArray::InsertValue(const int id, const unsigned char
// Description:
// Insert data at the end of the array. Return its location in the array.
inline int vtkCharArray::InsertNextValue(const unsigned char c)
inline int vtkUnsignedCharArray::InsertNextValue(const unsigned char c)
{
this->InsertValue (++this->MaxId,c);
return this->MaxId;
}
inline void vtkCharArray::operator+=(const unsigned char c)
inline void vtkUnsignedCharArray::operator+=(const unsigned char c)
{
this->InsertNextValue(c);
}
......@@ -107,7 +107,7 @@ inline void vtkCharArray::operator+=(const unsigned char c)
// Description:
// Does insert or get (depending on location on lhs or rhs of statement). Does
// not do automatic resizing - user's responsibility to range check.
inline unsigned char& vtkCharArray::operator[](const int i)
inline unsigned char& vtkUnsignedCharArray::operator[](const int i)
{
if (i > this->MaxId) this->MaxId = i;
return this->Array[i];
......@@ -115,19 +115,19 @@ inline unsigned char& vtkCharArray::operator[](const int i)
// Description:
// Resize object to just fit data requirement. Reclaims extra memory.
inline void vtkCharArray::Squeeze() {this->Resize (this->MaxId+1);};
inline void vtkUnsignedCharArray::Squeeze() {this->Resize (this->MaxId+1);};
// Description:
// Get the allocated size of the object in terms of number of data items.
inline int vtkCharArray::GetSize() {return this->Size;};
inline int vtkUnsignedCharArray::GetSize() {return this->Size;};
// Description:
// Returning the maximum index of data inserted so far.
inline int vtkCharArray::GetMaxId() {return this->MaxId;};
inline int vtkUnsignedCharArray::GetMaxId() {return this->MaxId;};
// Description:
// Reuse the memory allocated by this object. Objects appears like
// no data has been previously inserted.
inline void vtkCharArray::Reset() {this->MaxId = -1;};
inline void vtkUnsignedCharArray::Reset() {this->MaxId = -1;};
#endif
/*=========================================================================
Program: Visualization Toolkit
Module: CScalars.hh
Module: UCScalar.hh
Language: C++
Date: $Date$
Version: $Revision$
......@@ -13,31 +13,31 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vtkCharScalars - unsigned char representation of scalar data
// .NAME vtkUnsignedCharScalars - unsigned char representation of scalar data
// .SECTION Description
// vtkCharScalars is a concrete implementation of vtkScalars. Scalars are
// vtkUnsignedCharScalars is a concrete implementation of vtkScalars. Scalars are
// represented using char values.
#ifndef __vtkCharScalars_h
#define __vtkCharScalars_h
#ifndef __vtkUnsignedCharScalars_h
#define __vtkUnsignedCharScalars_h
#include "Scalars.hh"
#include "CArray.hh"
#include "UCArray.hh"
class vtkCharScalars : public vtkScalars
class vtkUnsignedCharScalars : public vtkScalars
{
public:
vtkCharScalars() {};
vtkCharScalars(const vtkCharScalars& cs) {this->S = cs.S;};
vtkCharScalars(const int sz, const int ext=1000):S(sz,ext){};
~vtkCharScalars() {};
vtkUnsignedCharScalars() {};
vtkUnsignedCharScalars(const vtkUnsignedCharScalars& cs) {this->S = cs.S;};
vtkUnsignedCharScalars(const int sz, const int ext=1000):S(sz,ext){};
~vtkUnsignedCharScalars() {};
int Allocate(const int sz, const int ext=1000) {return this->S.Allocate(sz,ext);};
void Initialize() {this->S.Initialize();};
char *GetClassName() {return "vtkCharScalars";};
char *GetClassName() {return "vtkUnsignedCharScalars";};
// vtkScalar interface
vtkScalars *MakeObject(int sze, int ext=1000);
char *GetDataType() {return "char";};
char *GetDataType() {return "unsigned char";};
int GetNumberOfScalars() {return (this->S.GetMaxId()+1);};
void Squeeze() {this->S.Squeeze();};
float GetScalar(int i) {return (float)this->S[i];};
......@@ -53,17 +53,17 @@ public:
unsigned char *GetPtr(const int id);
unsigned char *WritePtr(const int id, const int number);
void WrotePtr();
vtkCharScalars &operator=(const vtkCharScalars& cs);
void operator+=(const vtkCharScalars& cs) {this->S += cs.S;};
vtkUnsignedCharScalars &operator=(const vtkUnsignedCharScalars& cs);
void operator+=(const vtkUnsignedCharScalars& cs) {this->S += cs.S;};
void Reset() {this->S.Reset();};
protected:
vtkCharArray S;
vtkUnsignedCharArray S;
};
// Description:
// Get pointer to array of data starting at data position "id".
inline unsigned char *vtkCharScalars::GetPtr(const int id)
inline unsigned char *vtkUnsignedCharScalars::GetPtr(const int id)
{
return this->S.GetPtr(id);
}
......@@ -73,7 +73,7 @@ inline unsigned char *vtkCharScalars::GetPtr(const int id)
// bumped by number (and memory allocated if necessary). Id is the
// location you wish to write into; number is the number of scalars to
// write. Use the method WrotePtr() to mark completion of write.
inline unsigned char *vtkCharScalars::WritePtr(const int id, const int number)
inline unsigned char *vtkUnsignedCharScalars::WritePtr(const int id, const int number)
{
return this->S.WritePtr(id,number);
}
......@@ -81,6 +81,6 @@ inline unsigned char *vtkCharScalars::WritePtr(const int id, const int number)
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vtkCharScalars::WrotePtr() {}
inline void vtkUnsignedCharScalars::WrotePtr() {}
#endif
......@@ -41,7 +41,7 @@ public:
virtual vtkVectors *MakeObject(int sze, int ext=1000) = 0;
// Description:
// Return data type. One of "bit", "char", "short", "int", "float", or
// Return data type. One of "bit", "unsigned char", "short", "int", "float", or
// "double".
virtual char *GetDataType() = 0;
......
......@@ -79,10 +79,10 @@ void vtkGlrTexture::Load(vtkTexture *txt, vtkGlrRenderer *ren)
bytesPerPixel = scalars->GetNumberOfValuesPerScalar();
// make sure using unsigned char data of color scalars type
if ( strcmp(scalars->GetDataType(),"char") ||
if ( strcmp(scalars->GetDataType(),"unsigned char") ||
strcmp(scalars->GetScalarType(),"ColorScalar") )
{
vtkDebugMacro(<< "Cannot do quick coversion to unsigned char.\n");
vtkErrorMacro(<< "Cannot do quick coversion to unsigned char.\n");
return;
}
......
......@@ -16,46 +16,37 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "ImpTC.hh"
// Description:
// Create object with texture dimension=2; no r-s-t implicit functions defined;
// clamping off; and the r-s-t range set to (-100,100).
// Create object with texture dimension=2 and no r-s-t implicit functions defined.
vtkImplicitTextureCoords::vtkImplicitTextureCoords()
{
this->Dimension = 2;
this->RFunction = NULL;
this->SFunction = NULL;
this->TFunction = NULL;
this->ScaleFactor = 1.0;
this->Clamp = 0;
this->RRange[0] = -100.0;
this->RRange[1] = 100.0;
this->SRange[0] = -100.0;
this->SRange[1] = 100.0;
this->TRange[0] = -100.0;
this->TRange[1] = 100.0;
}
void vtkImplicitTextureCoords::Execute()
{
int ptId, numPts, tcoordDim;
vtkFloatTCoords *newTCoords;
float min[3], max[3], scale[3];
float tCoord[3], *tc, *x;
int i;
vtkDataSet *input=this->Input;
//
// Initialize
//
vtkDebugMacro(<<"Generating texture coordinates!");
vtkDebugMacro(<<"Generating texture coordinates from implicit functions...");
this->Initialize();
if ( ((numPts=this->Input->GetNumberOfPoints()) < 1) )
if ( ((numPts=input->GetNumberOfPoints()) < 1) )
{
vtkErrorMacro(<< "No input!");
vtkErrorMacro(<< "No input points!");
return;
}
if ( this->RFunction == NULL )
{
vtkErrorMacro(<< "No input!");
vtkErrorMacro(<< "No implicit functions defined!");
return;
}
......@@ -71,18 +62,68 @@ void vtkImplicitTextureCoords::Execute()
//
// Allocate
//
newTCoords = new vtkFloatTCoords(numPts,tcoordDim);
tCoord[0] = tCoord[1] = tCoord[2] = 0.0;
if ( tcoordDim == 1 ) //force 2D map to be created
newTCoords = new vtkFloatTCoords(numPts,2);
else
newTCoords = new vtkFloatTCoords(numPts,tcoordDim);
//
// Compute texture coordinate and map into appropriate range
// Compute implicit function values -> insert as initial texture coordinate
//
for (i=0; i<3; i++) //initialize min/max values array
{
min[i] = LARGE_FLOAT;
max[i] = -LARGE_FLOAT;
}
for (ptId=0; ptId<numPts; ptId++) //compute texture coordinates
{
x = input->GetPoint(ptId);
tCoord[0] = this->RFunction->EvaluateFunction(x);
if ( this->SFunction ) tCoord[1] = this->SFunction->EvaluateFunction(x);
if ( this->TFunction ) tCoord[2] = this->TFunction->EvaluateFunction(x);
for (i=0; i<tcoordDim; i++)
{
if (tCoord[i] < min[i]) min[i] = tCoord[i];
if (tCoord[i] > max[i]) max[i] = tCoord[i];
}
newTCoords->InsertTCoord(ptId,tCoord);
}
//
// Scale and shift texture coordinates into (0,1) range, with 0.0 implicit
// function value equal to texture coordinate value of 0.5
//
for (i=0; i<tcoordDim; i++)
{
scale[i] = 1.0;
if ( max[i] > 0.0 && min[i] < 0.0 ) //have positive & negative numbers
{
if ( max[i] > (-min[i]) ) scale[i] = 0.5 / max[i]; //scale into 0.5->1
else scale[i] = -0.5 / min[i]; //scale into 0->0.5
}
else if ( max[i] > 0.0 ) //have positive numbers only
{
scale[i] = 0.5 / max[i]; //scale into 0.5->1.0
}
else if ( min[i] < 0.0 ) //have negative numbers only
{
scale[i] = -0.5 / min[i]; //scale into 0.0->0.5
}
}
for (ptId=0; ptId<numPts; ptId++)
{
tc = newTCoords->GetTCoord(ptId);
for (i=0; i<tcoordDim; i++) tCoord[i] = 0.5 + scale[i] * tc[i];
newTCoords->InsertTCoord(ptId,tCoord);
}
//
// Update self
//
this->PointData.CopyTCoordsOff();
this->PointData.PassData(this->Input->GetPointData());
this->PointData.PassData(input->GetPointData());
this->PointData.SetTCoords(newTCoords);
}
......@@ -91,12 +132,22 @@ void vtkImplicitTextureCoords::PrintSelf(ostream& os, vtkIndent indent)
{
vtkDataSetToDataSetFilter::PrintSelf(os,indent);
os << indent << "Texture Dimension: " << this->Dimension << "\n";
os << indent << "Clamp: " << (this->Clamp ? "On\n" : "Off\n");
os << indent << "Scale Factor: " << this->ScaleFactor << "\n";
os << indent << "RRange: (" << this->RRange[0] << ", " << this->RRange[1] << ")\n";
os << indent << "SRange: (" << this->SRange[0] << ", " << this->SRange[1] << ")\n";
os << indent << "TRange: (" << this->TRange[0] << ", " << this->TRange[1] << ")\n";
if ( this->RFunction != NULL )
{
if ( this->SFunction != NULL )
{
if ( this->TFunction != NULL )