Commit 1ffb27e9 authored by Will Schroeder's avatar Will Schroeder
Browse files

Initial revision

parent 343c2297
/*=========================================================================
Program: Visualization Library
Module: AGraymap.hh
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlAGraymap - scalar data in intensity + alpha (grayscale + texture) form
// .SECTION Description
// vlAGraymap is a concrete implementation of vlScalars. vlAGraymap
// represents scalars using using one value for intensity (grayscale) and
// one value for alpha (transparency). The intensity and alpha values range
// between (0,255) (i.e., an unsigned char value).
#ifndef __vlAGraymap_h
#define __vlAGraymap_h
#include "CoScalar.hh"
#include "CArray.hh"
class vlAGraymap : public vlColorScalars
{
public:
vlAGraymap() {};
~vlAGraymap() {};
vlAGraymap(const vlAGraymap& fs) {this->S = fs.S;};
vlAGraymap(const int sz, const int ext=1000):S(2*sz,2*ext){};
int Allocate(const int sz, const int ext=1000) {return this->S.Allocate(2*sz,2*ext);};
void Initialize() {this->S.Initialize();};
char *GetClassName() {return "vlAGraymap";};
// vlScalar interface
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfScalars() {return (this->S.GetMaxId()+1)/2;};
void Squeeze() {this->S.Squeeze();};
int GetNumberOfValuesPerPoint() {return 2;};
// miscellaneous
vlAGraymap &operator=(const vlAGraymap& fs);
void operator+=(const vlAGraymap& fs) {this->S += fs.S;};
void Reset() {this->S.Reset();};
unsigned char *WriteInto(int id, int number);
// vlColorScalar interface.
unsigned char *GetColor(int id);
void GetColor(int id, unsigned char rgb[3]);
void SetColor(int id, unsigned char rgb[3]);
void InsertColor(int id, unsigned char rgb[3]);
int InsertNextColor(unsigned char rgb[3]);
protected:
vlCharArray S;
};
// Description:
// Return a rgb triplet at array location i.
inline unsigned char *vlAGraymap::GetColor(int i) {return this->S.GetPtr(2*i);};
// Description:
// Set a rgb value at a particular array location. Does not do range
// checking.
inline void vlAGraymap::SetColor(int i, unsigned char rgb[3])
{
i *= 2;
this->S[i] = rgb[0];
this->S[i+1] = rgb[1];
this->S[i+2] = rgb[2];
}
// Description:
// Insert a rgb value at a particular array location. Does range checking
// and will allocate additional memory if necessary.
inline void vlAGraymap::InsertColor(int i, unsigned char *rgb)
{
this->S.InsertValue(2*i+2, rgb[2]);
this->S[2*i] = rgb[0];
this->S[2*i+1] = rgb[1];
}
// Description:
// Insert a rgb value at the next available slot in the array. Will allocate
// memory if necessary.
inline int vlAGraymap::InsertNextColor(unsigned char *rgb)
{
int id = this->S.GetMaxId() + 2;
this->S.InsertValue(id,rgb[2]);
this->S[id-2] = rgb[0];
this->S[id-1] = rgb[1];
return id/2;
}
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary).
unsigned char *vlAGraymap::WriteInto(int id, int number)
{
return this->S.WriteInto(id, number);
}
#endif
/*=========================================================================
Program: Visualization Library
Module: APixmap.hh
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlAPixmap - scalar data in rgba (color + transparency) form
// .SECTION Description
// vlAPixmap is a concrete implementation of vlScalars. Scalars are
// represented using three values for color (red, green, blue) plus alpha
// transparency value. Each of r,g,b,a components ranges from (0,255) (i.e.,
// an unsigned char value).
#ifndef __vlAPixmap_h
#define __vlAPixmap_h
#include "CoScalar.hh"
#include "CArray.hh"
class vlAPixmap : public vlColorScalars
{
public:
vlAPixmap() {};
~vlAPixmap() {};
vlAPixmap(const vlAPixmap& fs) {this->S = fs.S;};
vlAPixmap(const int sz, const int ext=1000):S(4*sz,4*ext){};
int Allocate(const int sz, const int ext=1000) {return this->S.Allocate(4*sz,4*ext);};
void Initialize() {this->S.Initialize();};
char *GetClassName() {return "vlAPixmap";};
// vlScalar interface
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfScalars() {return (this->S.GetMaxId()+1)/4;};
void Squeeze() {this->S.Squeeze();};
int GetNumberOfValuesPerPoint() {return 4;};
// miscellaneous
vlAPixmap &operator=(const vlAPixmap& fs);
void operator+=(const vlAPixmap& fs) {this->S += fs.S;};
void Reset() {this->S.Reset();};
// vlColorScalar interface.
unsigned char *GetColor(int id);
void GetColor(int id, unsigned char rgba[4]);
void SetColor(int id, unsigned char rgba[4]);
void InsertColor(int id, unsigned char rgba[4]);
int InsertNextColor(unsigned char rgba[4]);
protected:
vlCharArray S;
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Bitmap.hh
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlBitmap - scalar data in bitmap form
// .SECTION Description
// vlBitmap is a concrete implementation of vlScalars. Scalars are
// represented using a packed character array of (0,1) values.
#ifndef __vlBitmap_h
#define __vlBitmap_h
#include "CoScalar.hh"
#include "BArray.hh"
class vlBitmap : public vlColorScalars
{
public:
vlBitmap() {};
~vlBitmap() {};
vlBitmap(const vlBitmap& fs) {this->S = fs.S;};
vlBitmap(const int sz, const int ext=1000):S(sz,ext){};
int Allocate(const int sz, const int ext=1000) {return this->S.Allocate(sz,ext);};
void Initialize() {this->S.Initialize();};
char *GetClassName() {return "vlBitmap";};
// vlScalar interface
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfValuesPerPoint() {return 1;};
int GetNumberOfScalars() {return (this->S.GetMaxId()+1);};
void Squeeze() {this->S.Squeeze();};
// miscellaneous
vlBitmap &operator=(const vlBitmap& fs);
void operator+=(const vlBitmap& fs) {this->S += fs.S;};
void Reset() {this->S.Reset();};
// vlColorScalar interface.
unsigned char *GetColor(int id);
void GetColor(int id, unsigned char rgb[3]);
void SetColor(int id, unsigned char b[1]);
void InsertColor(int id, unsigned char b[1]);
int InsertNextColor(unsigned char b[1]);
protected:
vlBitArray S;
};
#endif
/*=========================================================================
Program: Visualization Library
Module: CoScalar.hh
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlColorScalars - abstract class represents scalar data in color specification
// .SECTION Description
// vlColorScalars is an abstract class whose subclasses represent scalar
// data using a color specification such as rgb, grayscale, rgba, hsv, etc.
// In order to be a vlScalar subclass, vlColorScalars must be able to
// return a single value given a point id. By default, this operation is
// performed by computing intensity as the single value. Concrete subclasses
// of vlColorScalars may have additional methods to convert multi-dimensional
// color information into a single scalar value.
// .SECTION Caveats
// Derived classes of vlColorScalars loosely interpret the meaning of "rgb".
// For example, when inserting a grayscale value, the "r" value is interpreted
// as the gray value. However, when getting the color, each of "r", "g", and
// "b" is set to the gray value. Thus when getting color, assume that the rgb
// value is correct.
// The derived class vlAPixmap must be used with caution. It operates on
// rgba[4] data. If you might be using this class, make sure that the array
// rgb is dimensioned to [4] to avoid memory corruption.
#ifndef __vlColorScalars_h
#define __vlColorScalars_h
#include "Scalars.hh"
class vlPixmap;
class vlColorScalars : public vlScalars
{
public:
vlColorScalars() {};
~vlColorScalars() {};
char *GetClassName() {return "vlColorScalars";};
// vlScalars interface
float GetScalar(int i);
void SetScalar(int i, float s);
void InsertScalar(int i, float s);
int InsertNextScalar(float s);
// abstract interface for vlColorScalars
// Description:
// Return number of colors (same as number of scalars).
int GetNumberOfColors() {return this->GetNumberOfScalars();};
// Description:
// Return a unsigned char rgb for a particular point id.
virtual unsigned char *GetColor(int id) = 0;
// Description:
// Copy rgb components into user provided array rgb[3] for specified
// point id.
virtual void GetColor(int id, unsigned char rgb[3]) = 0;
// Description:
// Insert color into object. No range checking performed (fast!).
virtual void SetColor(int id, unsigned char rgb[3]) = 0;
// Description:
// Insert color into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertColor(int id, unsigned char rgb[3]) = 0;
// Description:
// Insert color into next available slot. Returns point id of slot.
virtual int InsertNextColor(unsigned char rgb[3]) = 0;
void GetColors(vlIdList& ptId, vlPixmap& p);
};
// These include files are placed here so that if CoScalar.hh is included
// all other classes necessary for compilation are also included.
#include "IdList.hh"
#include "Pixmap.hh"
#endif
/*=========================================================================
Program: Visualization Library
Module: Graymap.hh
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlGraymap - scalar data in grayscale form
// .SECTION Description
// vlGraymap is a concrete implementation of vlScalars. Scalars are
// represented using a single unsigned char for components of gray.
// Gray values range from (0,255) with 0 being black.
#ifndef __vlGraymap_h
#define __vlGraymap_h
#include "CoScalar.hh"
#include "CArray.hh"
class vlGraymap : public vlColorScalars
{
public:
vlGraymap() {};
~vlGraymap() {};
vlGraymap(const vlGraymap& fs) {this->S = fs.S;};
vlGraymap(const int sz, const int ext=1000):S(sz,ext){};
int Allocate(const int sz, const int ext=1000) {return this->S.Allocate(sz,ext);};
void Initialize() {this->S.Initialize();};
char *GetClassName() {return "vlGraymap";};
// vlScalar interface
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfValuesPerPoint() {return 1;};
int GetNumberOfScalars() {return (this->S.GetMaxId()+1);};
void Squeeze() {this->S.Squeeze();};
// miscellaneous
vlGraymap &operator=(const vlGraymap& fs);
void operator+=(const vlGraymap& fs) {this->S += fs.S;};
void Reset() {this->S.Reset();};
unsigned char *WriteInto(int id, int number);
// vlColorScalar interface.
unsigned char *GetColor(int id);
void GetColor(int id, unsigned char rgb[3]);
void SetColor(int id, unsigned char g[1]);
void InsertColor(int id, unsigned char g[1]);
int InsertNextColor(unsigned char g[1]);
protected:
vlCharArray S;
};
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary).
inline unsigned char *vlGraymap::WriteInto(int id, int number)
{
return this->S.WriteInto(id, number);
}
#endif
/*=========================================================================
Program: Visualization Library
Module: Pixmap.hh
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlPixmap - scalar data in RGB (color) form
// .SECTION Description
// vlPixmap is a concrete implementation of vlScalars. Scalars are
// represented using three values for color (red, green, blue). Each of
// r,g,b ranges from (0,255) (i.e., an unsigned char value).
#ifndef __vlPixmap_h
#define __vlPixmap_h
#include "CoScalar.hh"
#include "CArray.hh"
class vlPixmap : public vlColorScalars
{
public:
vlPixmap() {};
~vlPixmap() {};
vlPixmap(const vlPixmap& fs) {this->S = fs.S;};
vlPixmap(const int sz, const int ext=1000):S(3*sz,3*ext){};
int Allocate(const int sz, const int ext=1000) {return this->S.Allocate(3*sz,3*ext);};
void Initialize() {this->S.Initialize();};
char *GetClassName() {return "vlPixmap";};
// vlScalar interface
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfScalars() {return (this->S.GetMaxId()+1)/3;};
void Squeeze() {this->S.Squeeze();};
int GetNumberOfValuesPerPoint() {return 3;};
// miscellaneous
vlPixmap &operator=(const vlPixmap& fs);
void operator+=(const vlPixmap& fs) {this->S += fs.S;};
void Reset() {this->S.Reset();};
unsigned char *WriteInto(int id, int number);
// vlColorScalar interface.
unsigned char *GetColor(int id);
void GetColor(int id, unsigned char rgb[3]);
void SetColor(int id, unsigned char rgb[3]);
void InsertColor(int id, unsigned char rgb[3]);
int InsertNextColor(unsigned char rgb[3]);
protected:
vlCharArray S;
};
// Description:
// Return a rgb triplet at array location i.
inline unsigned char *vlPixmap::GetColor(int i) {return this->S.GetPtr(3*i);};
// Description:
// Set a rgb value at a particular array location. Does not do range
// checking.
inline void vlPixmap::SetColor(int i, unsigned char rgb[3])
{
i *= 3;
this->S[i] = rgb[0];
this->S[i+1] = rgb[1];
this->S[i+2] = rgb[2];
}
// Description:
// Insert a rgb value at a particular array location. Does range checking
// and will allocate additional memory if necessary.
inline void vlPixmap::InsertColor(int i, unsigned char *rgb)
{
this->S.InsertValue(3*i+2, rgb[2]);
this->S[3*i] = rgb[0];
this->S[3*i+1] = rgb[1];
}
// Description:
// Insert a rgb value at the next available slot in the array. Will allocate
// memory if necessary.
inline int vlPixmap::InsertNextColor(unsigned char *rgb)
{
int id = this->S.GetMaxId() + 3;
this->S.InsertValue(id,rgb[2]);
this->S[id-2] = rgb[0];
this->S[id-1] = rgb[1];
return id/3;
}
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary).
inline unsigned char *vlPixmap::WriteInto(int id, int number)
{
return this->S.WriteInto(id, number);
}
#endif
/*=========================================================================
Program: Visualization Library
Module: AGraymap.cc
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "AGraymap.hh"
vlScalars *vlAGraymap::MakeObject(int sze, int ext)
{
return new vlAGraymap(sze,ext);
}
// Description:
// Deep copy of scalars.
vlAGraymap& vlAGraymap::operator=(const vlAGraymap& fs)
{
this->S = fs.S;
return *this;
}
/*=========================================================================
Program: Visualization Library
Module: APixmap.cc
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "APixmap.hh"
vlScalars *vlAPixmap::MakeObject(int sze, int ext)
{
return new vlAPixmap(sze,ext);
}
// Description:
// Deep copy of scalars.
vlAPixmap& vlAPixmap::operator=(const vlAPixmap& fs)
{
this->S = fs.S;
return *this;
}
// Description:
// Return a unsigned char rgba for a particular point id.
// (Note: this interface varies from superclass vlColorScalars.
// A pointer to four values are returned: rgba.)
unsigned char *vlAPixmap::GetColor(int id)
{
return this->S.GetPtr(4*id);
}
// Description:
// Copy rgba components into user provided array rgba[4] for specified
// point id. (Note: this interface varies from superclass vlColorScalars.
// Four values are returned: rgba.)
void vlAPixmap::GetColor(int id, unsigned char rgba[4])
{
unsigned char *_rgba;
_rgba = this->S.GetPtr(4*id);
rgba[0] = _rgba[0];
rgba[1] = _rgba[1];
rgba[2] = _rgba[2];
rgba[3] = _rgba[3];
}
// Description:
// Insert color into object. No range checking performed (fast!).
// (Note: this interface varies from superclass vlColorScalars.
// Four values are inserted: rgba.)
void vlAPixmap::SetColor(int id, unsigned char rgba[4])
{
id *= 4;
for(int j=0; j<4; j++) this->S[id+j] = rgba[j];
}
// Description:
// Insert color into object. Range checking performed and memory
// allocated as necessary.
// (Note: this interface varies from superclass vlColorScalars.
// Four values are inserted: rgba.)
void vlAPixmap::InsertColor(int id, unsigned char rgba[4])
{
id *= 4;
for(int j=0; j<4; j++) this->S.InsertValue(id+j,rgba[j]);
}
// Description:
// Insert color into next available slot. Returns point id of slot.
// (Note: this interface varies from superclass vlColorScalars.
// Four values are inserted: rgba.)
int vlAPixmap::InsertNextColor(unsigned char rgba[4])
{
int id = this->S.InsertNextValue(rgba[0]);
for(int j=1; j<4; j++) this->S.InsertNextValue(rgba[j]);
return id/4;
}
/*=========================================================================