Commit cdc2bf12 authored by Will Schroeder's avatar Will Schroeder

ENH: Constructor/destructor are protected

parent f57b82b8
......@@ -60,8 +60,6 @@ class vtkMapper2D;
class VTK_EXPORT vtkActor2D : public vtkProp
{
public:
vtkActor2D();
~vtkActor2D();
void PrintSelf(ostream& os, vtkIndent indent);
const char *GetClassName() {return "vtkActor2D";};
......@@ -122,6 +120,9 @@ public:
virtual void GetActors2D(vtkPropCollection *pc);
protected:
vtkActor2D();
~vtkActor2D();
vtkMapper2D *Mapper;
int LayerNumber;
vtkProperty2D *Property;
......
......@@ -61,8 +61,6 @@ class VTK_EXPORT vtkActor2DCollection : public vtkPropCollection
// Description:
// Desctructor for the vtkActor2DCollection class. This removes all
// objects from the collection.
~vtkActor2DCollection();
static vtkActor2DCollection *New() {return new vtkActor2DCollection;};
const char *GetClassName() {return "vtkActor2DCollection";};
......@@ -96,6 +94,7 @@ class VTK_EXPORT vtkActor2DCollection : public vtkPropCollection
protected:
~vtkActor2DCollection();
virtual void DeleteElement(vtkCollectionElement *);
};
......
......@@ -57,15 +57,15 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
class VTK_EXPORT vtkAttributeData : public vtkObject
{
public:
// Description:
// Construct object with an initial data array of type dataType (by default
// dataType is VTK_FLOAT.
vtkAttributeData(int dataType=VTK_FLOAT);
~vtkAttributeData();
const char *GetClassName() {return "vtkAttributeData";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Allocate initial memory size.
virtual int Allocate(const int sz, const int ext=1000);
// Description:
// Return object to instantiated state.
virtual void Initialize();
// Description:
......@@ -128,6 +128,11 @@ public:
void ShallowCopy(vtkAttributeData &ad) {this->ShallowCopy(&ad);}
protected:
// Construct object with an initial data array of type dataType (by default
// dataType is VTK_FLOAT.
vtkAttributeData(int dataType=VTK_FLOAT);
~vtkAttributeData();
vtkDataArray *Data; // Array which represents data
};
......
......@@ -53,8 +53,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
class VTK_EXPORT vtkBitArray : public vtkDataArray
{
public:
vtkBitArray(int numComp=1);
~vtkBitArray();
static vtkBitArray *New() {return new vtkBitArray;};
virtual const char *GetClassName() {return "vtkBitArray";};
void PrintSelf(ostream& os, vtkIndent indent);
......@@ -108,9 +106,6 @@ public:
// Description:
// Fast method based setting of values without memory checks. First
// use SetNumberOfValues then use SetValue to actually set them.
// Description:
// Specify the number of values for this object to hold. Does an
// allocation as well as setting the MaxId ivar. Used in conjunction with
// SetValue() method for fast insertion.
......@@ -157,6 +152,9 @@ public:
void DeepCopy(vtkBitArray &da) {this->DeepCopy(&da);}
private:
vtkBitArray(int numComp=1);
~vtkBitArray();
unsigned char *Array; // pointer to data
unsigned char *Resize(const int sz); // function to resize data
......
......@@ -158,6 +158,10 @@ public:
// assumes the word size is divisible by two.
static void SwapVoidRange(void *buffer, int numWords, int wordSize);
protected:
vtkByteSwap() {};
~vtkByteSwap() {};
};
#endif
......@@ -79,12 +79,14 @@ class vtkCellData;
class VTK_EXPORT vtkCell : public vtkObject
{
public:
vtkCell();
~vtkCell();
void Initialize(int npts, int *pts, vtkPoints *p);
const char *GetClassName() {return "vtkCell";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Initialize cell from outside with point ids and point
// coordinates specified.
void Initialize(int npts, int *pts, vtkPoints *p);
// Description:
// Create concrete copy of this cell. Initially, the copy is made by
// performing a ShallowCopy() operation.
......@@ -292,6 +294,9 @@ public:
void ShallowCopy(vtkCell &c) {this->ShallowCopy(&c);}
protected:
vtkCell();
~vtkCell();
float Bounds[6];
};
......
......@@ -57,13 +57,12 @@ vtkCellArray::vtkCellArray(const int sz, const int ext)
this->TraversalLocation = 0;
}
vtkCellArray::vtkCellArray (const vtkCellArray& ca)
void vtkCellArray::DeepCopy (vtkCellArray *ca)
{
this->Ia = vtkIntArray::New();
this->NumberOfCells = ca.NumberOfCells;
this->Ia->DeepCopy(ca->Ia);
this->NumberOfCells = ca->NumberOfCells;
this->InsertLocation = 0;
this->TraversalLocation = 0;
this->Ia->DeepCopy(ca.Ia);
}
vtkCellArray::~vtkCellArray()
......
......@@ -64,13 +64,12 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
class VTK_EXPORT vtkCellArray : public vtkObject
{
public:
vtkCellArray();
vtkCellArray (const int sz, const int ext=1000);
vtkCellArray(const vtkCellArray& ca);
~vtkCellArray();
static vtkCellArray *New() {return new vtkCellArray;};
const char *GetClassName() {return "vtkCellArray";};
// Description:
// Instantiate cell array (connectivity list).
static vtkCellArray *New() {return new vtkCellArray;};
// Description:
// Allocate memory and set the size to extend by.
int Allocate(const int sz, const int ext=1000)
......@@ -186,14 +185,19 @@ public:
int *WritePointer(const int ncells, const int size);
// Description:
// Define multiple cells by providing a connectivity list. The list is in the
// form (npts,p0,p1,...p(npts-1), repeated for each cell). Be careful using this
// method because it discards the old cells, and anything refering these cells
// becomes invalid (for example, if BuildCells() has been called see vtkPolyData).
// The traversal location is reset to the beginning of the list; the insertion
// location is set to the end of the list.
// Define multiple cells by providing a connectivity list. The list is in
// the form (npts,p0,p1,...p(npts-1), repeated for each cell). Be careful
// using this method because it discards the old cells, and anything
// refering these cells becomes invalid (for example, if BuildCells() has
// been called see vtkPolyData). The traversal location is reset to the
// beginning of the list; the insertion location is set to the end of the
// list.
void SetCells(int ncells, vtkIntArray *cells);
// Description:
// Perform a deep copy (no reference countsing) of the given cell array.
void DeepCopy(vtkCellArray *ca);
// Description:
// Return the underlying data as a data array.
vtkDataArray *GetData() {return this->Ia;};
......@@ -211,6 +215,10 @@ public:
int InsertNextCell(vtkIdList &pts);
protected:
vtkCellArray();
vtkCellArray (const int sz, const int ext=1000);
~vtkCellArray();
int NumberOfCells;
int InsertLocation; //keep track of current insertion point
int TraversalLocation; //keep track of traversal position
......
......@@ -55,12 +55,18 @@ class VTK_EXPORT vtkCellData : public vtkDataSetAttributes
{
public:
static vtkCellData *New() {return new vtkCellData;};
const char *GetClassName() {return "vtkCellData";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set cell data to null values
void NullCell(int cellId);
protected:
vtkCellData() {}; //make sure constructor and desctructor are protected
~vtkCellData() {};
};
#endif
......
......@@ -41,11 +41,15 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkCellLinks.h"
#include "vtkDataSet.h"
vtkCellLinks::vtkCellLinks(int sz, int ext)
void vtkCellLinks::Allocate(int sz, int ext)
{
static _vtkLink_s linkInit = {0,NULL};
this->Size = sz;
if ( this->Array != NULL )
{
delete [] this->Array;
}
this->Array = new _vtkLink_s[sz];
this->Extend = ext;
this->MaxId = -1;
......
......@@ -62,12 +62,14 @@ struct _vtkLink_s {
class VTK_EXPORT vtkCellLinks : public vtkObject
{
public:
vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
vtkCellLinks(int sz, int ext=1000);
~vtkCellLinks();
static vtkCellLinks *New() {return new vtkCellLinks;};
const char *GetClassName() {return "vtkCellLinks";};
// Description:
// Allocate the specified number of links (i.e., number of points) that
// will be built.
void Allocate(int numLinks, int ext=1000);
// Description:
// Get a link structure given a point id.
_vtkLink_s &GetLink(int ptId) {return this->Array[ptId];};
......@@ -125,6 +127,9 @@ public:
void Reset();
private:
vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
~vtkCellLinks();
// Description:
// Increment the count of the number of cells using the point.
void IncrementLinkCount(int ptId) { this->Array[ptId].ncells++;};
......
......@@ -40,14 +40,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
#include "vtkCellTypes.h"
vtkCellTypes::vtkCellTypes(int sz, int ext)
{
this->Size = sz;
this->Array = new _vtkCell_s[sz];
this->Extend = ext;
this->MaxId = -1;
}
vtkCellTypes::~vtkCellTypes()
{
delete [] this->Array;
......@@ -58,7 +50,10 @@ int vtkCellTypes::Allocate(int sz, int ext)
{
if ( sz > this->Size || this->Array == NULL )
{
delete [] this->Array;
if ( this->Array != NULL )
{
delete [] this->Array;
}
this->Size = ( sz > 0 ? sz : 1);
if ( (this->Array = new _vtkCell_s[this->Size]) == NULL )
......
......@@ -70,9 +70,6 @@ struct _vtkCell_s {
class VTK_EXPORT vtkCellTypes : public vtkObject
{
public:
vtkCellTypes() : Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
vtkCellTypes(int sz, int ext);
~vtkCellTypes();
static vtkCellTypes *New() {return new vtkCellTypes;};
const char *GetClassName() {return "vtkCellTypes";};
......@@ -125,10 +122,13 @@ public:
void Reset();
private:
vtkCellTypes() : Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
~vtkCellTypes();
_vtkCell_s *Array; // pointer to data
int Size; // allocated size of data
int MaxId; // maximum index inserted thus far
int Extend; // grow array by this point
int Size; // allocated size of data
int MaxId; // maximum index inserted thus far
int Extend; // grow array by this point
_vtkCell_s *Resize(int sz); // function to resize data
};
......
......@@ -52,9 +52,8 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
class VTK_EXPORT vtkCharArray : public vtkDataArray
{
public:
vtkCharArray(int numComp=1);
~vtkCharArray();
static vtkCharArray *New() {return new vtkCharArray;};
const char *GetClassName() {return "vtkCharArray";};
void PrintSelf(ostream& os, vtkIndent indent);
......@@ -178,6 +177,9 @@ public:
void DeepCopy(vtkDataArray &ia) {this->DeepCopy(&ia);}
private:
vtkCharArray(int numComp=1);
~vtkCharArray();
char *Array; // pointer to data
char *Resize(const int sz); // function to resize data
......
......@@ -69,18 +69,12 @@ class vtkCollectionElement //;prevents pick-up by man page generator
class VTK_EXPORT vtkCollection : public vtkObject
{
public:
void PrintSelf(ostream& os, vtkIndent indent);
static vtkCollection *New() {return new vtkCollection;};
const char *GetClassName() {return "vtkCollection";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct with empty list.
vtkCollection();
// Description:
// Desctructor for the vtkCollection class. This removes all
// objects from the collection.
virtual ~vtkCollection();
static vtkCollection *New() {return new vtkCollection;};
// Description:
// Add an object to the list. Does not prevent duplicate entries.
......@@ -133,6 +127,9 @@ public:
vtkObject *GetItemAsObject(int i);
protected:
vtkCollection();
virtual ~vtkCollection();
virtual void DeleteElement(vtkCollectionElement *);
int NumberOfItems;
vtkCollectionElement *Top;
......
......@@ -60,10 +60,8 @@ class VTK_EXPORT vtkContourValues : public vtkObject
public:
// Description:
// Construct object with a single contour value at 0.0.
vtkContourValues();
~vtkContourValues();
static vtkContourValues *New() {return new vtkContourValues;};
const char *GetClassName() {return "vtkContourValues";};
void PrintSelf(ostream& os, vtkIndent indent);
......@@ -108,6 +106,9 @@ public:
protected:
vtkContourValues();
~vtkContourValues();
vtkFloatArray *Contours;
};
......
......@@ -84,10 +84,8 @@ class vtkViewport;
class VTK_EXPORT vtkCoordinate : public vtkObject
{
public:
vtkCoordinate();
~vtkCoordinate();
void PrintSelf(ostream& os, vtkIndent indent);
const char *GetClassName() {return "vtkCoordinate";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Creates an instance of this class with the following defaults:
......@@ -146,6 +144,9 @@ public:
float *GetComputedValue(vtkViewport *);
protected:
vtkCoordinate();
~vtkCoordinate();
float Value[3];
int CoordinateSystem;
vtkCoordinate *ReferenceCoordinate;
......
......@@ -70,14 +70,11 @@ class vtkFloatArray;
class VTK_EXPORT vtkDataArray : public vtkObject
{
public:
// Description:
// Construct object with default tuple dimension (number of components) of 1.
vtkDataArray(int numComp=1);
const char *GetClassName() {return "vtkDataArray";};
void PrintSelf(ostream& os, vtkIndent indent);
virtual int Allocate(const int sz, const int ext=1000) = 0;
virtual void Initialize() = 0;
const char *GetClassName() {return "vtkDataArray";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Virtual constructor creates an object of the same type as this one.
......@@ -211,6 +208,10 @@ public:
virtual void SetVoidArray(void *array,int size, int save) {};
protected:
// Construct object with default tuple dimension (number of components) of 1.
vtkDataArray(int numComp=1);
~vtkDataArray() {};
int Size; // allocated size of data
int MaxId; // maximum index inserted thus far
int Extend; // grow array by this amount
......
......@@ -67,9 +67,8 @@ class vtkExtent;
class VTK_EXPORT vtkDataObject : public vtkObject
{
public:
vtkDataObject();
~vtkDataObject();
static vtkDataObject *New() {return new vtkDataObject;};
const char *GetClassName() {return "vtkDataObject";};
void PrintSelf(ostream& os, vtkIndent indent);
......@@ -244,6 +243,9 @@ public:
unsigned long GetUpdateTime();
protected:
vtkDataObject();
~vtkDataObject();
vtkSource *Source;
vtkFieldData *FieldData; //General field data associated with data object
......
......@@ -102,13 +102,13 @@ void vtkDataSet::ComputeBounds()
for (j=0; j<3; j++)
{
if ( x[j] < this->Bounds[2*j] )
{