Commit 38e36868 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: More efficient gathering of multiple data values.

parent fdf8afa2
......@@ -47,6 +47,7 @@ public:
void InsertScalar(int i, int s) {S.InsertValue(i,s);};
int InsertNextScalar(int s) {return S.InsertNextValue(s);};
int InsertNextScalar(float s) {return S.InsertNextValue((int)s);};
void GetScalars(vlIdList& ptIds, vlFloatScalars& fs);
// miscellaneous
vlBitScalars &operator=(const vlBitScalars& cs);
......
......@@ -46,8 +46,11 @@ public:
void InsertScalar(int i, char s) {S.InsertValue(i,s);};
int InsertNextScalar(char s) {return S.InsertNextValue(s);};
int InsertNextScalar(float s) {return S.InsertNextValue((char)s);};
void GetScalars(vlIdList& ptIds, vlFloatScalars& fs);
// miscellaneous
unsigned char *GetPtr(const int id);
unsigned char *WritePtr(const int id, const int number);
vlCharScalars &operator=(const vlCharScalars& cs);
void operator+=(const vlCharScalars& cs) {this->S += cs.S;};
void Reset() {this->S.Reset();};
......@@ -56,4 +59,21 @@ protected:
vlCharArray S;
};
// Description:
// Get pointer to scalar data at location "id" in the array. Meant for reading
// data.
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.
inline unsigned char *vlCharScalars::WritePtr(const int id, const int number)
{
return this->S.WritePtr(id,number);
}
#endif
......@@ -44,6 +44,7 @@ public:
void SetPoint(int id, float x[3]);
void InsertPoint(int id, float *x);
int InsertNextPoint(float *x);
void GetPoints(vlIdList& ptId, vlFloatPoints& fp);
// miscellaneous
vlFloatPoints &operator=(const vlFloatPoints& fp);
......
......@@ -39,10 +39,11 @@ public:
vlScalars *MakeObject(int sze, int ext=1000);
int GetNumberOfScalars() {return (this->S.GetMaxId()+1);};
void Squeeze() {this->S.Squeeze();};
float GetScalar(int i) {return this->S[i];};
float GetScalar(int i) {return this->S.GetValue(i);};
void SetScalar(int i, float s) {this->S[i] = s;};
void InsertScalar(int i, float s) {S.InsertValue(i,s);};
int InsertNextScalar(float s) {return S.InsertNextValue(s);};
void GetScalars(vlIdList& ptIds, vlFloatScalars& fs);
// miscellaneous
vlFloatScalars &operator=(const vlFloatScalars& fs);
......
......@@ -45,6 +45,7 @@ public:
void InsertPoint(int i, float *x);
int InsertNextPoint(int *x);
int InsertNextPoint(float *x);
void GetPoints(vlIdList& ptId, vlFloatPoints& fp);
// miscellaneous
vlIntPoints &operator=(const vlIntPoints& fp);
......
......@@ -70,7 +70,10 @@ public:
// Reclaim any extra memory.
virtual void Squeeze() = 0; // reclaim memory
void GetPoints(vlIdList& ptId, vlFloatPoints& fp);
// Description:
// Get the point coordinates for the point ids specified.
virtual void GetPoints(vlIdList& ptId, vlFloatPoints& fp);
virtual void ComputeBounds();
float *GetBounds();
......
......@@ -46,6 +46,7 @@ public:
void InsertScalar(int i, short s) {S.InsertValue(i,s);};
int InsertNextScalar(short s) {return S.InsertNextValue(s);};
int InsertNextScalar(float s) {return S.InsertNextValue((short)s);};
void GetScalars(vlIdList& ptIds, vlFloatScalars& fs);
// miscellaneous
vlShortScalars &operator=(const vlShortScalars& ss);
......
......@@ -86,7 +86,10 @@ public:
// all scalar types: check for NULL return value.
virtual unsigned char *GetPtr(const int id) {return NULL;};
void GetScalars(vlIdList& ptId, vlFloatScalars& fs);
// Description:
// Get the scalar values for the point ids specified.
virtual void GetScalars(vlIdList& ptIds, vlFloatScalars& fs);
virtual void ComputeRange();
float *GetRange();
void GetRange(float range[8]);
......
......@@ -27,3 +27,11 @@ vlBitScalars& vlBitScalars::operator=(const vlBitScalars& cs)
this->S = cs.S;
return *this;
}
void vlBitScalars::GetScalars(vlIdList& ptId, vlFloatScalars& fs)
{
for (int i=0; i<ptId.GetNumberOfIds(); i++)
{
fs.InsertScalar(i,(float)this->S.GetValue(ptId.GetId(i)));
}
}
......@@ -27,3 +27,11 @@ vlCharScalars& vlCharScalars::operator=(const vlCharScalars& cs)
this->S = cs.S;
return *this;
}
void vlCharScalars::GetScalars(vlIdList& ptId, vlFloatScalars& fs)
{
for (int i=0; i<ptId.GetNumberOfIds(); i++)
{
fs.InsertScalar(i,(float)this->S.GetValue(ptId.GetId(i)));
}
}
......@@ -28,3 +28,10 @@ vlFloatPoints& vlFloatPoints::operator=(const vlFloatPoints& fp)
return *this;
}
void vlFloatPoints::GetPoints(vlIdList& ptId, vlFloatPoints& fp)
{
for (int i=0; i<ptId.GetNumberOfIds(); i++)
{
fp.InsertPoint(i,this->P.GetPtr(3*ptId.GetId(i)));
}
}
......@@ -27,3 +27,11 @@ vlFloatScalars& vlFloatScalars::operator=(const vlFloatScalars& fs)
this->S = fs.S;
return *this;
}
void vlFloatScalars::GetScalars(vlIdList& ptId, vlFloatScalars& fs)
{
for (int i=0; i<ptId.GetNumberOfIds(); i++)
{
fs.InsertScalar(i,this->S.GetValue(ptId.GetId(i)));
}
}
......@@ -35,3 +35,11 @@ float *vlIntPoints::GetPoint(int i)
x[0] = (float)iptr[0]; x[1] = (float)iptr[1]; x[2] = (float)iptr[2];
return x;
};
void vlIntPoints::GetPoints(vlIdList& ptId, vlFloatPoints& fp)
{
for (int i=0; i<ptId.GetNumberOfIds(); i++)
{
fp.InsertPoint(i,this->GetPoint(ptId.GetId(i)));
}
}
......@@ -30,3 +30,11 @@ vlShortScalars& vlShortScalars::operator=(const vlShortScalars& ss)
this->S = ss.S;
return *this;
}
void vlShortScalars::GetScalars(vlIdList& ptId, vlFloatScalars& fs)
{
for (int i=0; i<ptId.GetNumberOfIds(); i++)
{
fs.InsertScalar(i,(float)this->S.GetValue(ptId.GetId(i)));
}
}
Supports Markdown
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