Commit 2fe94cf1 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Added Get*(id,data[]) method for safe data getting.

parent fc141196
......@@ -39,9 +39,10 @@ public:
vlPoints *MakeObject(int sze, int ext=1000);
int GetNumberOfPoints() {return (P.GetMaxId()+1)/3;};
void Squeeze() {this->P.Squeeze();};
float *GetPoint(int i) {return this->P.GetPtr(3*i);};
void SetPoint(int i, float x[3]);
void InsertPoint(int i, float *x);
float *GetPoint(int id) {return this->P.GetPtr(3*id);};
void GetPoint(int id, float x[3]);
void SetPoint(int id, float x[3]);
void InsertPoint(int id, float *x);
int InsertNextPoint(float *x);
// miscellaneous
......@@ -54,19 +55,25 @@ protected:
};
inline void vlFloatPoints::SetPoint(int i, float x[3])
inline void vlFloatPoints::GetPoint(int id, float x[3])
{
i*=3;
this->P[i]=x[0];
this->P[i+1]=x[1];
this->P[i+2]=x[2];
float *p=this->P.GetPtr(3*id);
x[0] = p[0]; x[1] = p[1]; x[2] = p[2];
}
inline void vlFloatPoints::InsertPoint(int i, float *x)
inline void vlFloatPoints::SetPoint(int id, float x[3])
{
this->P.InsertValue(3*i+2, x[2]); // only do range checking once
this->P[3*i] = x[0];
this->P[3*i+1] = x[1];
id*=3;
this->P[id]=x[0];
this->P[id+1]=x[1];
this->P[id+2]=x[2];
}
inline void vlFloatPoints::InsertPoint(int id, float *x)
{
this->P.InsertValue(3*id+2, x[2]); // only do range checking once
this->P[3*id] = x[0];
this->P[3*id+1] = x[1];
}
inline int vlFloatPoints::InsertNextPoint(float *x)
......
......@@ -47,16 +47,21 @@ public:
// Description:
// Return a float normal n[3] for a particular point id.
virtual float *GetNormal(int i) = 0;
virtual float *GetNormal(int id) = 0;
// Description:
// Copy normal components into user provided array n[3] for specified
// point id.
virtual void GetNormal(int id, float n[3]);
// Description:
// Insert normal into object. No range checking performed (fast!).
virtual void SetNormal(int i,float n[3]) = 0;
virtual void SetNormal(int id, float n[3]) = 0;
// Description:
// Insert normal into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertNormal(int i, float n[3]) = 0;
virtual void InsertNormal(int id, float n[3]) = 0;
// Description:
// Insert normal into next available slot. Returns point id of slot.
......
......@@ -45,17 +45,22 @@ public:
virtual int GetNumberOfPoints() = 0;
// Description:
// Return a float point x[3] for a particular point id.
virtual float *GetPoint(int i) = 0;
// Return a pointer to a float array x[3] for a specified point id.
virtual float *GetPoint(int id) = 0;
// Description:
// Copy point coordinates into user provided array x[3] for specified
// point id.
virtual void GetPoint(int id, float x[3]);
// Description:
// Insert point into object. No range checking performed (fast!).
virtual void SetPoint(int i,float x[3]) = 0;
virtual void SetPoint(int id, float x[3]) = 0;
// Description:
// Insert point into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertPoint(int i, float x[3]) = 0;
virtual void InsertPoint(int id, float x[3]) = 0;
// Description:
// Insert point into next available slot. Returns point id of slot.
......
......@@ -46,16 +46,16 @@ public:
// Description:
// Return a float scalar value for a particular point id.
virtual float GetScalar(int i) = 0;
virtual float GetScalar(int id) = 0;
// Description:
// Insert scalar into array. No range checking performed (fast!).
virtual void SetScalar(int i, float s) = 0;
virtual void SetScalar(int id, float s) = 0;
// Description:
// Insert scalar into array. Range checking performed and memory
// allocated as necessary.
virtual void InsertScalar(int i, float s) = 0;
virtual void InsertScalar(int id, float s) = 0;
// Description:
// Insert scalar into next available slot. Returns point id of slot.
......
......@@ -48,16 +48,21 @@ public:
// Description:
// Return a float texture coordinate tc[2/3] for a particular point id.
virtual float *GetTCoord(int i) = 0;
virtual float *GetTCoord(int id) = 0;
// Description:
// Copy float texture coordinates into user provided array tc[2/3]
// for specified point id.
virtual void GetTCoord(int id, float tc[3]);
// Description:
// Insert texture coordinate into object. No range checking performed (fast!).
virtual void SetTCoord(int i,float *tc) = 0;
virtual void SetTCoord(int id, float *tc) = 0;
// Description:
// Insert texture coordinate into object. Range checking performed and
// memory allocated as necessary.
virtual void InsertTCoord(int i, float *tc) = 0;
virtual void InsertTCoord(int id, float *tc) = 0;
// Description:
// Insert texture coordinate into next available slot. Returns point
......
......@@ -45,17 +45,22 @@ public:
virtual int GetNumberOfVectors() = 0;
// Description:
// Return a float vector v[3] for a particular point id.
virtual float *GetVector(int i) = 0;
// Return a pointer to a float vector v[3] for a specific point id.
virtual float *GetVector(int id) = 0;
// Description:
// Copy vector componenets into user provided array v[3] for specified
// point id.
virtual void GetVector(int id, float v[3]);
// Description:
// Insert vector into object. No range checking performed (fast!).
virtual void SetVector(int i,float v[3]) = 0;
virtual void SetVector(int id, float v[3]) = 0;
// Description:
// Insert vector into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertVector(int i, float v[3]) = 0;
virtual void InsertVector(int id, float v[3]) = 0;
// Description:
// Insert vector into next available slot. Returns point id of slot.
......
......@@ -17,6 +17,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "IdList.hh"
#include "FNormals.hh"
void vlNormals::GetNormal(int id, float n[3])
{
float *np = this->GetNormal(id);
for (int i=0; i<3; i++) n[i] = np[i];
}
// Description:
// Given a list of pt ids, return an array of corresponding normals.
void vlNormals::GetNormals(vlIdList& ptId, vlFloatNormals& fp)
......
......@@ -23,6 +23,12 @@ vlPoints::vlPoints()
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = 1.0;
}
void vlPoints::GetPoint(int id, float x[3])
{
float *xp = this->GetPoint(id);
for (int i=0; i<3; i++) x[i] = xp[i];
}
// Description:
// Given a list of pt ids, return an array of point coordinates.
void vlPoints::GetPoints(vlIdList& ptId, vlFloatPoints& fp)
......
......@@ -17,6 +17,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "IdList.hh"
#include "FTCoords.hh"
void vlTCoords::GetTCoord(int id, float tc[3])
{
float *tcp = this->GetTCoord(id);
for (int i=0; i<this->Dimension; i++) tc[i] = tcp[i];
}
// Description:
// Construct object whose texture coordinates are of specified dimension.
vlTCoords::vlTCoords(int dim)
......
......@@ -23,6 +23,12 @@ vlVectors::vlVectors()
this->MaxNorm = 0.0;
}
void vlVectors::GetVector(int id, float v[3])
{
float *vp = this->GetVector(id);
for (int i=0; i<3; i++) v[i] = vp[i];
}
// Description:
// Given a list of pt ids, return an array of vectors.
void vlVectors::GetVectors(vlIdList& ptId, vlFloatVectors& fp)
......
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