Commit 55912007 authored by Joachim Pouderoux's avatar Joachim Pouderoux Committed by Code Review

Merge topic 'clean_and_update_vtkPointsXX' into master

cb93b88d Clean and uniformize vtkPoints & vtkPoints2D.
parents 9a98d9cb cb93b88d
......@@ -39,9 +39,9 @@ vtkPoints* vtkPoints::New(int dataType)
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkPoints");
if(ret)
if (ret)
{
if(dataType != VTK_FLOAT)
if (dataType != VTK_FLOAT)
{
static_cast<vtkPoints*>(ret)->SetDataType(dataType);
}
......@@ -67,8 +67,8 @@ vtkPoints::vtkPoints(int dataType)
this->Data->SetNumberOfComponents(3);
this->Data->SetName("Points");
this->Bounds[0] = this->Bounds[2] = this->Bounds[4] = 0.0;
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = 1.0;
this->Bounds[0] = this->Bounds[2] = this->Bounds[4] = VTK_DOUBLE_MAX;
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = -VTK_DOUBLE_MAX;
}
vtkPoints::~vtkPoints()
......@@ -86,18 +86,17 @@ void vtkPoints::GetPoints(vtkIdList *ptIds, vtkPoints *outPoints)
namespace
{
template <class T>
void InternalComputeBounds(vtkDataArray* array,
double* bounds,
T*)
void InternalComputeBounds(vtkDataArray* array, double* bounds, T*)
{
bounds[0] = bounds[2] = bounds[4] = VTK_DOUBLE_MAX;
bounds[1] = bounds[3] = bounds[5] = -VTK_DOUBLE_MAX;
if (vtkTypedDataArray<T>* tarray = vtkTypedDataArray<T>::FastDownCast(array))
vtkTypedDataArray<T>* tarray = vtkTypedDataArray<T>::FastDownCast(array);
if (tarray)
{
T x[3];
vtkIdType numPts = tarray->GetNumberOfTuples();
for (vtkIdType i=0; i<numPts; i++)
for (vtkIdType i = 0; i < numPts; i++)
{
tarray->GetTupleValue(i, x);
bounds[0] = x[0] < bounds[0] ? x[0] : bounds[0];
......@@ -112,7 +111,7 @@ namespace
{
double x[3];
vtkIdType numPts = array->GetNumberOfTuples();
for (vtkIdType i=0; i<numPts; i++)
for (vtkIdType i = 0; i < numPts; i++)
{
array->GetTuple(i, x);
bounds[0] = x[0] < bounds[0] ? x[0] : bounds[0];
......@@ -129,14 +128,12 @@ namespace
// Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void vtkPoints::ComputeBounds()
{
if ( this->GetMTime() > this->ComputeTime )
if (this->GetMTime() > this->ComputeTime)
{
switch (this->Data->GetDataType())
{
vtkTemplateMacro(InternalComputeBounds(
this->Data,
this->Bounds,
(VTK_TT*)0));
vtkTemplateMacro(
InternalComputeBounds(this->Data, this->Bounds, (VTK_TT*)0));
}
this->ComputeTime.Modified();
......@@ -154,21 +151,19 @@ double *vtkPoints::GetBounds()
void vtkPoints::GetBounds(double bounds[6])
{
this->ComputeBounds();
for (int i=0; i<6; i++)
{
bounds[i] = this->Bounds[i];
}
memcpy(bounds, this->Bounds, 6 * sizeof(double));
}
int vtkPoints::Allocate(const vtkIdType sz, const vtkIdType ext)
{
int numComp=this->Data->GetNumberOfComponents();
return this->Data->Allocate(sz*numComp,ext*numComp);
int numComp = this->Data->GetNumberOfComponents();
return this->Data->Allocate(sz * numComp, ext * numComp);
}
void vtkPoints::Initialize()
{
this->Data->Initialize();
this->Modified();
}
int vtkPoints::GetDataType()
......@@ -179,26 +174,25 @@ int vtkPoints::GetDataType()
// Specify the underlying data type of the object.
void vtkPoints::SetDataType(int dataType)
{
if ( dataType == this->Data->GetDataType() )
if (dataType == this->Data->GetDataType())
{
return;
}
this->Modified();
this->Data->Delete();
this->Data = vtkDataArray::CreateDataArray(dataType);
this->Data->SetNumberOfComponents(3);
this->Data->SetName("Points");
this->Modified();
}
// Set the data for this object. The tuple dimension must be consistent with
// the object.
void vtkPoints::SetData(vtkDataArray *data)
{
if ( data != this->Data && data != NULL )
if (data != this->Data && data != NULL)
{
if (data->GetNumberOfComponents() != this->Data->GetNumberOfComponents() )
if (data->GetNumberOfComponents() != this->Data->GetNumberOfComponents())
{
vtkErrorMacro(<<"Number of components is different...can't set data");
return;
......@@ -222,9 +216,9 @@ void vtkPoints::DeepCopy(vtkPoints *da)
{
return;
}
if ( da->Data != this->Data && da->Data != NULL )
if (da->Data != this->Data && da->Data != NULL)
{
if (da->Data->GetNumberOfComponents() != this->Data->GetNumberOfComponents() )
if (da->Data->GetNumberOfComponents() != this->Data->GetNumberOfComponents())
{
vtkErrorMacro(<<"Number of components is different...can't copy");
return;
......@@ -248,16 +242,17 @@ unsigned long vtkPoints::GetActualMemorySize()
void vtkPoints::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
this->Superclass::PrintSelf(os, indent);
os << indent << "Data: " << this->Data << "\n";
if ( this->Data->GetName() )
os << indent << "Data Array Name: ";
if (this->Data->GetName())
{
os << indent << "Data Array Name: " << this->Data->GetName() << "\n";
os << this->Data->GetName() << "\n";
}
else
{
os << indent << "Data Array Name: (none)\n";
os << "(none)\n";
}
os << indent << "Number Of Points: " << this->GetNumberOfPoints() << "\n";
......
......@@ -26,7 +26,6 @@
#include "vtkDataArray.h" // Needed for inline methods
class vtkIdList;
class vtkPoints;
class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
{
......@@ -41,7 +40,7 @@ public:
// Description:
// Allocate initial memory size. ext is no longer used.
virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
virtual int Allocate(const vtkIdType sz, const vtkIdType ext = 1000);
// Description:
// Return object to instantiated state.
......@@ -55,7 +54,7 @@ public:
// tuple dimension of 9. Scalars, on the other hand, can have tuple dimension
// from 1-4, depending on the type of scalar.)
virtual void SetData(vtkDataArray *);
vtkDataArray *GetData() {return this->Data;};
vtkDataArray *GetData() { return this->Data; }
// Description:
// Return the underlying data type. An integer indicating data type is
......@@ -65,30 +64,30 @@ public:
// Description:
// Specify the underlying data type of the object.
virtual void SetDataType(int dataType);
void SetDataTypeToBit() {this->SetDataType(VTK_BIT);};
void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);};
void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);};
void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);};
void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);};
void SetDataTypeToInt() {this->SetDataType(VTK_INT);};
void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);};
void SetDataTypeToLong() {this->SetDataType(VTK_LONG);};
void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);};
void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);};
void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);};
void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
// Description:
// Return a void pointer. For image pipeline interface and other
// special pointer manipulation.
void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);};
void *GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
// Description:
// Reclaim any extra memory.
virtual void Squeeze() {this->Data->Squeeze();};
virtual void Squeeze() { this->Data->Squeeze(); }
// Description:
// Make object look empty but do not delete memory.
virtual void Reset() {this->Data->Reset();};
virtual void Reset();
// Description:
// Different ways to copy data. Shallow copy does reference count (i.e.,
......@@ -108,26 +107,26 @@ public:
// Description:
// Return number of points in array.
vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();};
vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
// Description:
// Return a pointer to a double point x[3] for a specific id.
// WARNING: Just don't use this error-prone method, the returned pointer
// and its values are only valid as long as another method invocation is not
// performed. Prefer GetPoint() with the return value in argument.
double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);};
double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id); }
// Description:
// Copy point components into user provided array v[3] for specified
// id.
void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x);};
void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x); }
// Description:
// Insert point into object. No range checking performed (fast!).
// Make sure you use SetNumberOfPoints() to allocate memory prior
// to using SetPoint().
void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x);};
void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x);};
void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x); }
void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x); }
void SetPoint(vtkIdType id, double x, double y, double z);
// Description:
......@@ -141,17 +140,17 @@ public:
// Description:
// Insert point into next available slot. Returns id of slot.
vtkIdType InsertNextPoint(const float x[3]) {
return this->Data->InsertNextTuple(x);};
vtkIdType InsertNextPoint(const double x[3]) {
return this->Data->InsertNextTuple(x);};
vtkIdType InsertNextPoint(const float x[3])
{ return this->Data->InsertNextTuple(x); }
vtkIdType InsertNextPoint(const double x[3])
{ return this->Data->InsertNextTuple(x); }
vtkIdType InsertNextPoint(double x, double y, double z);
// Description:
// Specify the number of points for this object to hold. Does an
// allocation as well as setting the MaxId ivar. Used in conjunction with
// SetPoint() method for fast insertion.
void SetNumberOfPoints(vtkIdType number);
void SetNumberOfPoints(vtkIdType numPoints);
// Description:
// Resize the internal array while conserving the data. Returns 1 if
......@@ -175,7 +174,7 @@ public:
void GetBounds(double bounds[6]);
protected:
vtkPoints(int dataType=VTK_FLOAT);
vtkPoints(int dataType = VTK_FLOAT);
~vtkPoints();
double Bounds[6];
......@@ -187,44 +186,41 @@ private:
void operator=(const vtkPoints&); // Not implemented.
};
inline void vtkPoints::SetNumberOfPoints(vtkIdType number)
inline void vtkPoints::Reset()
{
this->Data->Reset();
this->Modified();
}
inline void vtkPoints::SetNumberOfPoints(vtkIdType numPoints)
{
this->Data->SetNumberOfComponents(3);
this->Data->SetNumberOfTuples(number);
this->Data->SetNumberOfTuples(numPoints);
this->Modified();
}
inline int vtkPoints::Resize(vtkIdType numPoints)
{
this->Data->SetNumberOfComponents(3);
this->Modified();
return this->Data->Resize(numPoints);
}
inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
{
double p[3];
p[0] = x;
p[1] = y;
p[2] = z;
this->Data->SetTuple(id,p);
double p[3] = { x, y, z };
this->Data->SetTuple(id, p);
}
inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
{
double p[3];
p[0] = x;
p[1] = y;
p[2] = z;
this->Data->InsertTuple(id,p);
double p[3] = { x, y, z };
this->Data->InsertTuple(id, p);
}
inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
{
double p[3];
p[0] = x;
p[1] = y;
p[2] = z;
double p[3] = { x, y, z };
return this->Data->InsertNextTuple(p);
}
......
......@@ -39,9 +39,9 @@ vtkPoints2D* vtkPoints2D::New(int dataType)
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkPoints2D");
if(ret)
if (ret)
{
if(dataType != VTK_FLOAT)
if (dataType != VTK_FLOAT)
{
static_cast<vtkPoints2D*>(ret)->SetDataType(dataType);
}
......@@ -67,8 +67,8 @@ vtkPoints2D::vtkPoints2D(int dataType)
this->Data->SetNumberOfComponents(2);
this->Data->SetName("Points2D");
this->Bounds[0] = this->Bounds[2] = 0.0;
this->Bounds[1] = this->Bounds[3] = 1.0;
this->Bounds[0] = this->Bounds[2] = VTK_DOUBLE_MAX;
this->Bounds[1] = this->Bounds[3] = -VTK_DOUBLE_MAX;
}
vtkPoints2D::~vtkPoints2D()
......@@ -80,8 +80,7 @@ vtkPoints2D::~vtkPoints2D()
void vtkPoints2D::GetPoints(vtkIdList *ptIds, vtkPoints2D *fp)
{
vtkIdType num = ptIds->GetNumberOfIds();
for (vtkIdType i=0; i < num; i++)
for (vtkIdType i = 0; i < num; i++)
{
fp->InsertPoint(i, this->GetPoint(ptIds->GetId(i)));
}
......@@ -90,24 +89,21 @@ void vtkPoints2D::GetPoints(vtkIdList *ptIds, vtkPoints2D *fp)
// Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void vtkPoints2D::ComputeBounds()
{
vtkIdType i;
int j;
double *x;
if ( this->GetMTime() > this->ComputeTime )
if (this->GetMTime() > this->ComputeTime)
{
this->Bounds[0] = this->Bounds[2] = VTK_DOUBLE_MAX;
this->Bounds[1] = this->Bounds[3] = -VTK_DOUBLE_MAX;
for (i=0; i < this->GetNumberOfPoints(); ++i)
for (vtkIdType i = 0; i < this->GetNumberOfPoints(); ++i)
{
x = this->GetPoint(i);
for (j=0; j < 2; ++j)
double x[2];
this->GetPoint(i, x);
for (int j = 0; j < 2; ++j)
{
if ( x[j] < this->Bounds[2*j] )
if (x[j] < this->Bounds[2*j])
{
this->Bounds[2*j] = x[j];
}
if ( x[j] > this->Bounds[2*j+1] )
if (x[j] > this->Bounds[2*j+1])
{
this->Bounds[2*j+1] = x[j];
}
......@@ -129,21 +125,19 @@ double *vtkPoints2D::GetBounds()
void vtkPoints2D::GetBounds(double bounds[4])
{
this->ComputeBounds();
for (int i=0; i<4; i++)
{
bounds[i] = this->Bounds[i];
}
memcpy(bounds, this->Bounds, 4 * sizeof(double));
}
int vtkPoints2D::Allocate(const vtkIdType sz, const vtkIdType ext)
{
int numComp=this->Data->GetNumberOfComponents();
return this->Data->Allocate(sz*numComp,ext*numComp);
int numComp = this->Data->GetNumberOfComponents();
return this->Data->Allocate(sz * numComp, ext * numComp);
}
void vtkPoints2D::Initialize()
{
this->Data->Initialize();
this->Modified();
}
int vtkPoints2D::GetDataType()
......@@ -154,26 +148,25 @@ int vtkPoints2D::GetDataType()
// Specify the underlying data type of the object.
void vtkPoints2D::SetDataType(int dataType)
{
if ( dataType == this->Data->GetDataType() )
if (dataType == this->Data->GetDataType())
{
return;
}
this->Modified();
this->Data->Delete();
this->Data = vtkDataArray::CreateDataArray(dataType);
this->Data->SetNumberOfComponents(2);
this->Data->SetName("Points2D");
this->Modified();
}
// Set the data for this object. The tuple dimension must be consistent with
// the object.
void vtkPoints2D::SetData(vtkDataArray *data)
{
if ( data != this->Data && data != NULL )
if (data != this->Data && data != NULL)
{
if (data->GetNumberOfComponents() != this->Data->GetNumberOfComponents() )
if (data->GetNumberOfComponents() != this->Data->GetNumberOfComponents())
{
vtkErrorMacro(<<"Number of components is different...can't set data");
return;
......@@ -197,9 +190,9 @@ void vtkPoints2D::DeepCopy(vtkPoints2D *da)
{
return;
}
if ( da->Data != this->Data && da->Data != NULL )
if (da->Data != this->Data && da->Data != NULL)
{
if (da->Data->GetNumberOfComponents() != this->Data->GetNumberOfComponents() )
if (da->Data->GetNumberOfComponents() != this->Data->GetNumberOfComponents())
{
vtkErrorMacro(<<"Number of components is different...can't copy");
return;
......@@ -223,16 +216,17 @@ unsigned long vtkPoints2D::GetActualMemorySize()
void vtkPoints2D::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
this->Superclass::PrintSelf(os, indent);
os << indent << "Data: " << this->Data << "\n";
os << indent << "Data Array Name: ";
if ( this->Data->GetName() )
{
os << indent << "Data Array Name: " << this->Data->GetName() << "\n";
os << this->Data->GetName() << "\n";
}
else
{
os << indent << "Data Array Name: (none)\n";
os << "(none)\n";
}
os << indent << "Number Of Points: " << this->GetNumberOfPoints() << "\n";
......
......@@ -39,8 +39,8 @@ public:
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Allocate initial memory size.
virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
// Allocate initial memory size. ext is no longer used.
virtual int Allocate(const vtkIdType sz, const vtkIdType ext = 1000);
// Description:
// Return object to instantiated state.
......@@ -54,7 +54,7 @@ public:
// tuple dimension of 9. Scalars, on the other hand, can have tuple dimension
// from 1-4, depending on the type of scalar.)
virtual void SetData(vtkDataArray *);
vtkDataArray *GetData() {return this->Data;}
vtkDataArray *GetData() { return this->Data; }
// Description:
// Return the underlying data type. An integer indicating data type is
......@@ -64,30 +64,30 @@ public:
// Description:
// Specify the underlying data type of the object.
virtual void SetDataType(int dataType);
void SetDataTypeToBit() {this->SetDataType(VTK_BIT);}
void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);}
void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);}
void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);}
void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);}
void SetDataTypeToInt() {this->SetDataType(VTK_INT);}
void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);}
void SetDataTypeToLong() {this->SetDataType(VTK_LONG);}
void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);}
void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);}
void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);}
void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
// Description:
// Return a void pointer. For image pipeline interface and other
// special pointer manipulation.
void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);};
void *GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
// Description:
// Reclaim any extra memory.
virtual void Squeeze() {this->Data->Squeeze();};
virtual void Squeeze() { this->Data->Squeeze(); }
// Description:
// Make object look empty but do not delete memory.
virtual void Reset() {this->Data->Reset();};
virtual void Reset();
// Description:
// Different ways to copy data. Shallow copy does reference count (i.e.,
......@@ -107,7 +107,7 @@ public:
// Description:
// Return number of points in array.
vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();}
vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
// Description:
// Return a pointer to a double point x[2] for a specific id.
......@@ -118,42 +118,47 @@ public:
// Description:
// Copy point components into user provided array v[2] for specified id.
void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x);}
void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x); }
// Description:
// Insert point into object. No range checking performed (fast!).
// Make sure you use SetNumberOfPoints() to allocate memory prior
// to using SetPoint().
void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x);}
void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id,x);}
void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x); }
void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id,x); }
void SetPoint(vtkIdType id, double x, double y);
// Description:
// Insert point into object. Range checking performed and memory
// allocated as necessary.
void InsertPoint(vtkIdType id, const float x[2])
{ this->Data->InsertTuple(id,x);}
{ this->Data->InsertTuple(id,x); }
void InsertPoint(vtkIdType id, const double x[2])
{this->Data->InsertTuple(id,x);}
{ this->Data->InsertTuple(id,x); }
void InsertPoint(vtkIdType id, double x, double y);
// Description:
// Insert point into next available slot. Returns id of slot.
vtkIdType InsertNextPoint(const float x[2]) {
return this->Data->InsertNextTuple(x);}
vtkIdType InsertNextPoint(const double x[2]) {
return this->Data->InsertNextTuple(x);}
vtkIdType InsertNextPoint(const float x[2])
{ return this->Data->InsertNextTuple(x); }
vtkIdType InsertNextPoint(const double x[2])
{ return this->Data->InsertNextTuple(x); }
vtkIdType InsertNextPoint(double x, double y);
// Description:
// Remove point described by its id
void RemovePoint(vtkIdType id) {this->Data->RemoveTuple(id);}
void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
// Description:
// Specify the number of points for this object to hold. Does an
// allocation as well as setting the MaxId ivar. Used in conjunction with
// SetPoint() method for fast insertion.
void SetNumberOfPoints(vtkIdType number);
void SetNumberOfPoints(vtkIdType numPoints);
// Description:
// Resize the internal array while conserving the data. Returns 1 if
// resizing succeeded and 0 otherwise.
int Resize(vtkIdType numPoints);
// Description:
// Given a list of pt ids, return an array of points.
......@@ -172,7 +177,7 @@ public:
void GetBounds(double bounds[4]);
protected:
vtkPoints2D(int dataType=VTK_FLOAT);
vtkPoints2D(int dataType = VTK_FLOAT);
~vtkPoints2D();
double Bounds[4];
......@@ -184,22 +189,36 @@ private:
void operator=(const vtkPoints2D&); // Not implemented.
};
inline void vtkPoints2D::SetNumberOfPoints(vtkIdType number)
inline void vtkPoints2D::Reset()
{
this->Data->Reset();
this->Modified();
}
inline void vtkPoints2D::SetNumberOfPoints(vtkIdType numPoints)
{
this->Data->SetNumberOfComponents(2);
this->Data->SetNumberOfTuples(numPoints);
this->Modified();
}
inline int vtkPoints2D::Resize(vtkIdType numPoints)
{
this->Data->SetNumberOfComponents(2);
this->Data->SetNumberOfTuples(number);
this->Modified();
return this->Data->Resize(numPoints);
}
inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
{
double p[2] = { x, y };
this->Data->SetTuple(id,p);
this->Data->SetTuple(id, p);
}
inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
{
double p[2] = { x, y };
this->Data->InsertTuple(id,p);
this->Data->InsertTuple(id, p);
}
inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please