Commit ef781a47 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: created uniform pointer interface.

parent 184304d3
......@@ -41,7 +41,7 @@ public:
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfScalars() {return (this->S.GetMaxId()+1)/2;};
void Squeeze() {this->S.Squeeze();};
int GetNumberOfValuesPerPoint() {return 2;};
int GetNumberOfValuesPerScalar() {return 2;};
// miscellaneous
vlAGraymap &operator=(const vlAGraymap& fs);
......@@ -49,6 +49,7 @@ public:
void Reset() {this->S.Reset();};
unsigned char *GetPtr(const int id);
unsigned char *WritePtr(const int id, const int number);
void WrotePtr();
// vlColorScalar interface.
......@@ -97,21 +98,26 @@ inline int vlAGraymap::InsertNextColor(unsigned char rgba[4])
}
// Description:
// Get pointer to ga data at location "id" in the array. Meant for reading
// data.
// Get pointer to array of data starting at data position "id".
inline unsigned char *vlAGraymap::GetPtr(const int id)
{
return this->S.GetPtr(2*id);
}
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the locaation you
// wish to write into; number is the number of ga colors to write.
// Get pointer to data array. Useful for direct writes of data. MaxId is
// 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 *vlAGraymap::WritePtr(const int id, const int number)
{
return this->S.WritePtr(2*id,2*number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlAGraymap::WrotePtr() {}
#endif
......@@ -41,7 +41,7 @@ public:
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfScalars() {return (this->S.GetMaxId()+1)/4;};
void Squeeze() {this->S.Squeeze();};
int GetNumberOfValuesPerPoint() {return 4;};
int GetNumberOfValuesPerScalar() {return 4;};
// miscellaneous
vlAPixmap &operator=(const vlAPixmap& fs);
......@@ -49,6 +49,7 @@ public:
void Reset() {this->S.Reset();};
unsigned char *GetPtr(const int id);
unsigned char *WritePtr(const int id, const int number);
void WrotePtr();
// vlColorScalar interface.
unsigned char *GetColor(int id);
......@@ -69,20 +70,25 @@ inline unsigned char *vlAPixmap::GetColor(int i)
}
// Description:
// Get pointer to rgba data at location "id" in the array. Meant for reading
// data.
// Get pointer to array of data starting at data position "id".
inline unsigned char *vlAPixmap::GetPtr(const int id)
{
return this->S.GetPtr(4*id);
}
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the locaation you
// wish to write into; number is the number of rgba colors to write.
// Get pointer to data array. Useful for direct writes of data. MaxId is
// 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 *vlAPixmap::WritePtr(const int id, const int number)
{
return this->S.WritePtr(4*id,4*number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlAPixmap::WrotePtr() {}
#endif
......@@ -51,7 +51,9 @@ public:
void GetScalars(vlIdList& ptIds, vlFloatScalars& fs);
// miscellaneous
unsigned char *GetPtr(const int id);
unsigned char *WritePtr(const int id, const int number);
void WrotePtr();
vlBitScalars &operator=(const vlBitScalars& cs);
void operator+=(const vlBitScalars& cs) {this->S += cs.S;};
void Reset() {this->S.Reset();};
......@@ -61,11 +63,25 @@ protected:
};
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the locaation you
// wish to write into; number is the number of scalars to write.
// Get pointer to array of data starting at data position "id".
inline unsigned char *vlBitScalars::GetPtr(const int id)
{
return this->S.GetPtr(id);
}
// Description:
// Get pointer to data array. Useful for direct writes of data. MaxId is
// 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 *vlBitScalars::WritePtr(const int id, const int number)
{
return this->S.WritePtr(id,number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlBitScalars::WrotePtr() {}
#endif
......@@ -37,7 +37,6 @@ public:
// 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();};
......
......@@ -52,6 +52,7 @@ public:
// miscellaneous
unsigned char *GetPtr(const int id);
unsigned char *WritePtr(const int id, const int number);
void WrotePtr();
vlCharScalars &operator=(const vlCharScalars& cs);
void operator+=(const vlCharScalars& cs) {this->S += cs.S;};
void Reset() {this->S.Reset();};
......@@ -61,20 +62,25 @@ protected:
};
// Description:
// Get pointer to scalar data at location "id" in the array. Meant for reading
// data.
// Get pointer to array of data starting at data position "id".
inline unsigned char *vlCharScalars::GetPtr(const int id)
{
return this->S.GetPtr(id);
}
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the locaation you
// wish to write into; number is the number of scalars to write.
// Get pointer to data array. Useful for direct writes of data. MaxId is
// 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 *vlCharScalars::WritePtr(const int id, const int number)
{
return this->S.WritePtr(id,number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlCharScalars::WrotePtr() {}
#endif
......@@ -44,25 +44,32 @@ public:
char *GetClassName() {return "vlColorScalars";};
// vlScalars interface
char *GetScalarType() {return "ColorScalar";};
char *GetDataType() {return "char";};
float GetScalar(int i);
void SetScalar(int i, float s);
void InsertScalar(int i, float s);
int InsertNextScalar(float s);
// Description:
// Get pointer to array of data starting at data position "id".
virtual unsigned char *GetPtr(const int id) = 0;
// abstract interface for vlColorScalars
// Description:
// Return number of colors (same as number of scalars).
int GetNumberOfColors() {return this->GetNumberOfScalars();};
// Description:
// Return a unsigned char rgba for a particular point id.
// Return a unsigned char rgba for a particular point id. No matter
// what internal representation of color, derived class must convert it
// to rgba.
virtual unsigned char *GetColor(int id) = 0;
// Description:
// Copy color components into user provided array rgba[4] for specified
// point id. The number of components returned is the number of values
// per point.
// point id. No matter what internal representation of color, derived
// class must convert it to rgba form.
virtual void GetColor(int id, unsigned char rgba[4]) = 0;
// Description:
......@@ -80,6 +87,8 @@ public:
void GetColors(vlIdList& ptId, vlAPixmap& ap);
void GetComponentRange(unsigned char range[8]);
unsigned char *GetComponentRange();
};
// These include files are placed here so that if CoScalar.hh is included
......
......@@ -47,7 +47,9 @@ public:
int InsertNextNormal(float *n);
// miscellaneous
float *GetPtr(const int id);
float *WritePtr(const int id, const int number);
void WrotePtr();
vlFloatNormals &operator=(const vlFloatNormals& fn);
void operator+=(const vlFloatNormals& fn);
void Reset() {this->N.Reset();};
......@@ -57,14 +59,28 @@ protected:
};
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the location you
// wish to write into; number is the number of normals to write.
// Get pointer to array of data starting at data position "id".
inline float *vlFloatNormals::GetPtr(const int id)
{
return this->N.GetPtr(id);
}
// Description:
// Get pointer to data array. Useful for direct writes of data. MaxId is
// bumped by number (and memory allocated if necessary). Id is the
// location you wish to write into; number is the number of normals to
// write. Use the method WrotePtr() to mark completion of write.
inline float *vlFloatNormals::WritePtr(const int id, const int number)
{
return this->N.WritePtr(id,3*number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlFloatNormals::WrotePtr() {}
inline void vlFloatNormals::SetNormal(int i, float n[3])
{
i*=3;
......
......@@ -48,7 +48,9 @@ public:
void GetPoints(vlIdList& ptId, vlFloatPoints& fp);
// miscellaneous
float *GetPtr(const int id);
float *WritePtr(const int id, const int number);
void WrotePtr();
vlFloatPoints &operator=(const vlFloatPoints& fp);
void operator+=(const vlFloatPoints& fp) {this->P += fp.P;};
void Reset() {this->P.Reset();};
......@@ -58,14 +60,27 @@ protected:
};
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the location you
// wish to write into; number is the number of points to write.
// Get pointer to array of data starting at data position "id".
inline float *vlFloatPoints::GetPtr(const int id)
{
return this->P.GetPtr(id);
}
// Description:
// Get pointer to data array. Useful for direct writes of data. MaxId is
// 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 float *vlFloatPoints::WritePtr(const int id, const int number)
{
return this->P.WritePtr(id,3*number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlFloatPoints::WrotePtr() {}
inline void vlFloatPoints::GetPoint(int id, float x[3])
{
float *p=this->P.GetPtr(3*id);
......
......@@ -47,7 +47,9 @@ public:
void GetScalars(vlIdList& ptIds, vlFloatScalars& fs);
// miscellaneous
float *GetPtr(const int id);
float *WritePtr(const int id, const int number);
void WrotePtr();
vlFloatScalars &operator=(const vlFloatScalars& fs);
void operator+=(const vlFloatScalars& fs) {this->S += fs.S;};
void Reset() {this->S.Reset();};
......@@ -57,12 +59,25 @@ protected:
};
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the locaation you
// wish to write into; number is the number of scalars to write.
// Get pointer to array of data starting at data position "id".
inline float *vlFloatScalars::GetPtr(const int id)
{
return this->S.GetPtr(id);
}
// Description:
// Get pointer to data array. Useful for direct writes of data. MaxId is
// 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 float *vlFloatScalars::WritePtr(const int id, const int number)
{
return this->S.WritePtr(id,number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlFloatScalars::WrotePtr() {}
#endif
......@@ -47,7 +47,9 @@ public:
int InsertNextTCoord(float *tc);
// miscellaneous
float *GetPtr(const int id);
float *WritePtr(const int id, const int number);
void WrotePtr();
vlFloatTCoords &operator=(const vlFloatTCoords& ftc);
void operator+=(const vlFloatTCoords& ftc) {this->TC += ftc.TC;};
void Reset() {this->TC.Reset();};
......@@ -58,9 +60,17 @@ protected:
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the location you
// wish to write into; number is the number of texture coordinates to write.
// Get pointer to array of data starting at data position "id".
inline float *vlFloatTCoords::GetPtr(const int id)
{
return this->TC.GetPtr(id);
}
// Description:
// Get pointer to data array. Useful for direct writes of data. MaxId is
// bumped by number (and memory allocated if necessary). Id is the
// location you wish to write into; number is the number of texture coordinates to
// write. Use the method WrotePtr() to mark completion of write.
// Make sure the dimension of the texture coordinate is set prior to issuing
// this call.
inline float *vlFloatTCoords::WritePtr(const int id, const int number)
......@@ -68,6 +78,12 @@ inline float *vlFloatTCoords::WritePtr(const int id, const int number)
return this->TC.WritePtr(id,this->Dimension*number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlFloatTCoords::WrotePtr() {}
inline void vlFloatTCoords::SetTCoord(int i, float *tc)
{
i*=this->Dimension;
......
......@@ -47,7 +47,9 @@ public:
int InsertNextTensor(vlTensor &t);
// miscellaneous
float *GetPtr(const int id);
float *WritePtr(const int id, const int number);
void WrotePtr();
vlFloatTensors &operator=(const vlFloatTensors& ft);
void operator+=(const vlFloatTensors& ft) {this->T += ft.T;};
void Reset() {this->T.Reset();};
......@@ -57,15 +59,29 @@ protected:
};
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the location you
// wish to write into; number is the number of tensors to write.
// Get pointer to array of data starting at data position "id".
inline float *vlFloatTensors::GetPtr(const int id)
{
return this->T.GetPtr(id);
}
// Description:
// Get pointer to data array. Useful for direct writes of data. MaxId is
// bumped by number (and memory allocated if necessary). Id is the
// location you wish to write into; number is the number of tensors to
// write. Use the method WrotePtr() to mark completion of write.
// Make sure the dimension of the tensor is set prior to issuing this call.
inline float *vlFloatTensors::WritePtr(const int id, const int number)
{
return this->T.WritePtr(id,this->Dimension*number);
return this->T.WritePtr(id,this->Dimension*this->Dimension*number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlFloatTensors::WrotePtr() {}
inline vlFloatTensors::vlFloatTensors(const vlFloatTensors& ft)
{
this->T = ft.T;this->Dimension = ft.Dimension;
......
......@@ -47,7 +47,9 @@ public:
int InsertNextVector(float *v);
// miscellaneous
float *GetPtr(const int id);
float *WritePtr(const int id, const int number);
void WrotePtr();
vlFloatVectors &operator=(const vlFloatVectors& fv);
void operator+=(const vlFloatVectors& fv){this->V += fv.V;};
void Reset() {this->V.Reset();};
......@@ -57,14 +59,28 @@ protected:
};
// Description:
// Get pointer to data. Useful for direct writes into object. MaxId is bumped
// by number (and memory allocated if necessary). Id is the location you
// wish to write into; number is the number of vectors to write.
// Get pointer to array of data starting at data position "id".
inline float *vlFloatVectors::GetPtr(const int id)
{
return this->V.GetPtr(id);
}
// Description:
// Get pointer to data array. Useful for direct writes of data. MaxId is
// bumped by number (and memory allocated if necessary). Id is the
// location you wish to write into; number is the number of vectors to
// write. Use the method WrotePtr() to mark completion of write.
inline float *vlFloatVectors::WritePtr(const int id, const int number)
{
return this->V.WritePtr(id,3*number);
}
// Description:
// Terminate direct write of data. Although dummy routine now, reserved for
// future use.
inline void vlFloatVectors::WrotePtr() {}
inline void vlFloatVectors::SetVector(int i, float v[3])
{
i*=3;
......
......@@ -50,7 +50,7 @@ int vlColorScalars::InsertNextScalar(float s)
{
if ( this->LookupTable == NULL ) this->CreateDefaultLookupTable();
this->InsertNextColor(this->LookupTable->MapValue(s));
return this->InsertNextColor(this->LookupTable->MapValue(s));
}
// Description:
......@@ -63,3 +63,36 @@ void vlColorScalars::GetColors(vlIdList& ptId, vlAPixmap& p)
}
}
// Description:
// Compute range of color rgba data (rmin,rmax, gmin,gmax, bmin,bmax,
// amin,amax). Return pointer to array of length 8.
unsigned char *vlColorScalars::GetComponentRange ()
{
unsigned char *rgba;
int i, j;
static unsigned char range[8];
range[0] = range[2] = range[4] = range[6] = 255;
range[1] = range[3] = range[5] = range[7] = 0;
for (i=0; i<this->GetNumberOfColors(); i++)
{
rgba = this->GetColor(i);
for (j=0; j<4; j++)
{
if ( rgba[j] < range[2*j] ) range[2*j] = rgba[j];
if ( rgba[j] > range[2*j+1] ) range[2*j+1] = rgba[j];
}
}
return range;
}
// Description:
// Compute range of color rgba data (rmin,rmax, gmin,gmax, bmin,bmax,
// amin,amax). Copy result into user provided array.
void vlColorScalars::GetComponentRange(unsigned char range[8])
{
unsigned char *r=this->GetComponentRange();
for (int i=0; i < 8; i++) range[i] = r[i];
}
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