Commit 9dc2ebea authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Removed multiple inheritance.

parent 51d097f1
......@@ -48,9 +48,9 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#ifndef __vtkStructuredData_h
#define __vtkStructuredData_h
#include "vtkLWObject.hh"
#include "vtkBitArray.hh"
#include "vtkObject.hh"
#include "vtkIdList.hh"
#include "vtkDataSet.hh"
#define VTK_SINGLE_POINT 0
#define VTK_X_LINE 1
......@@ -61,49 +61,16 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#define VTK_XZ_PLANE 6
#define VTK_XYZ_GRID 7
class vtkStructuredData : public vtkLWObject
class vtkStructuredData : public vtkObject
{
public:
vtkStructuredData();
vtkStructuredData(const vtkStructuredData& sds);
virtual ~vtkStructuredData();
void _PrintSelf(ostream& os, vtkIndent indent);
// setting object dimensions
void SetDimensions(int i, int j, int k);
void SetDimensions(int dim[3]);
int *GetDimensions();
void GetDimensions(int dim[3]);
int GetDataDimension();
void BlankingOn();
void BlankingOff();
int GetBlanking() {return this->Blanking;};
void BlankPoint(int ptId);
void UnBlankPoint(int ptId);
int IsPointVisible(int ptId);
protected:
// methods to support datasets (done because of MI problems)
int _GetNumberOfCells();
int _GetNumberOfPoints();
void _Initialize();
void _GetCellPoints(int cellId, vtkIdList& ptIds);
void _GetPointCells(int ptId, vtkIdList& cellIds);
int Dimensions[3];
int DataDescription;
int Blanking;
vtkBitArray *PointVisibility;
int GetDataDimension(int dataDescription);
int SetDimensions(int inDim[3], int dim[3]);
void GetCellPoints(int cellId, vtkIdList& ptIds,
int dataDescription, int dim[3]);
void GetPointCells(int ptId, vtkIdList& cellIds, int dim[3]);
};
// Description:
// Return non-zero value if specified point is visible.
inline int vtkStructuredData::IsPointVisible(int ptId)
{
if (!this->Blanking) return 1;
else return this->PointVisibility->GetValue(ptId);
}
#endif
......@@ -52,8 +52,9 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkPointSet.hh"
#include "vtkStructuredData.hh"
#include "vtkBitScalars.hh"
class vtkStructuredGrid : public vtkPointSet, public vtkStructuredData {
class vtkStructuredGrid : public vtkPointSet {
public:
vtkStructuredGrid();
vtkStructuredGrid(const vtkStructuredGrid& sg);
......@@ -62,8 +63,6 @@ public:
char *GetDataType() {return "vtkStructuredGrid";};
void PrintSelf(ostream& os, vtkIndent indent);
unsigned long GetMtime();
// dataset interface
vtkDataSet *MakeObject() {return new vtkStructuredGrid(*this);};
void CopyStructure(vtkDataSet *ds);
......@@ -80,10 +79,29 @@ public:
void Initialize();
int GetMaxCellSize() {return 8;}; //hexahedron is the largest
// methods specific to structured grid
void SetDimensions(int i, int j, int k);
void SetDimensions(int dim[3]);
// Description:
// Get dimensions of this structured points dataset.
vtkGetVectorMacro(Dimensions,int,3);
int GetDataDimension();
void BlankingOn();
void BlankingOff();
int GetBlanking() {return this->Blanking;};
void BlankPoint(int ptId);
void UnBlankPoint(int ptId);
int IsPointVisible(int ptId);
protected:
// points inherited
// point data (i.e., scalars, vectors, normals, tcoords) inherited
// blanking information inherited
int Dimensions[3];
int DataDescription;
int Blanking;
vtkBitScalars *PointVisibility;
vtkStructuredData StructuredData; //helper class
};
inline float *vtkStructuredGrid::GetPoint(int ptId)
......@@ -98,17 +116,30 @@ inline void vtkStructuredGrid::GetPoint(int ptId, float p[3])
inline int vtkStructuredGrid::GetNumberOfCells()
{
return this->vtkStructuredData::_GetNumberOfCells();
int nCells=1;
int i;
for (i=0; i<3; i++)
if (this->Dimensions[i] > 1)
nCells *= (this->Dimensions[i]-1);
return nCells;
}
inline int vtkStructuredGrid::GetDataDimension()
{
return this->StructuredData.GetDataDimension(this->DataDescription);
}
inline void vtkStructuredGrid::GetCellPoints(int cellId, vtkIdList& ptIds)
{
this->vtkStructuredData::_GetCellPoints(cellId,ptIds);
this->StructuredData.GetCellPoints(cellId,ptIds,this->DataDescription,
this->Dimensions);
}
inline void vtkStructuredGrid::GetPointCells(int ptId, vtkIdList& cellIds)
{
this->vtkStructuredData::_GetPointCells(ptId,cellIds);
this->StructuredData.GetPointCells(ptId,cellIds,this->Dimensions);
}
inline int vtkStructuredGrid::FindCell(float x[3], vtkCell *cell, float tol2,
......@@ -118,6 +149,14 @@ inline int vtkStructuredGrid::FindCell(float x[3], vtkCell *cell, float tol2,
return this->vtkPointSet::FindCell(x,cell,tol2,subId,pcoords,weights);
}
// Description:
// Return non-zero value if specified point is visible.
inline int vtkStructuredGrid::IsPointVisible(int ptId)
{
if (!this->Blanking) return 1;
else return (int) this->PointVisibility->GetScalar(ptId);
}
#endif
......
......@@ -51,7 +51,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkDataSet.hh"
#include "vtkStructuredData.hh"
class vtkStructuredPoints : public vtkDataSet, public vtkStructuredData
class vtkStructuredPoints : public vtkDataSet
{
public:
vtkStructuredPoints();
......@@ -61,8 +61,6 @@ public:
char *GetDataType() {return "vtkStructuredPoints";};
void PrintSelf(ostream& os, vtkIndent indent);
unsigned long GetMtime();
// dataset interface
vtkDataSet *MakeObject() {return new vtkStructuredPoints(*this);};
void CopyStructure(vtkDataSet *ds);
......@@ -78,11 +76,18 @@ public:
void GetCellPoints(int cellId, vtkIdList& ptIds);
void GetPointCells(int ptId, vtkIdList& cellIds);
void ComputeBounds();
void Initialize();
int GetMaxCellSize() {return 8;}; //voxel is the largest
void GetVoxelGradient(int i, int j, int k, vtkScalars *s, vtkFloatVectors& g);
// specific to structured data
void GetVoxelGradient(int i,int j,int k, vtkScalars *s, vtkFloatVectors& g);
void GetPointGradient(int i, int j, int k, vtkScalars *s, float g[3]);
void SetDimensions(int i, int j, int k);
void SetDimensions(int dim[3]);
int GetDataDimension();
// Description:
// Get dimensions of this structured points dataset.
vtkGetVectorMacro(Dimensions,int,3);
// Description:
// Set the aspect ratio of the cubical cells that compose the structured
......@@ -97,8 +102,12 @@ public:
vtkGetVectorMacro(Origin,float,3);
protected:
int Dimensions[3];
int DataDescription;
float Origin[3];
float AspectRatio[3];
vtkStructuredData StructuredData; //helper class for structured data
};
inline void vtkStructuredPoints::GetPoint(int id, float x[3])
......@@ -109,22 +118,35 @@ inline void vtkStructuredPoints::GetPoint(int id, float x[3])
inline int vtkStructuredPoints::GetNumberOfCells()
{
return this->vtkStructuredData::_GetNumberOfCells();
int nCells=1;
int i;
for (i=0; i<3; i++)
if (this->Dimensions[i] > 1)
nCells *= (this->Dimensions[i]-1);
return nCells;
}
inline int vtkStructuredPoints::GetNumberOfPoints()
{
return this->vtkStructuredData::_GetNumberOfPoints();
return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
}
inline int vtkStructuredPoints::GetDataDimension()
{
return this->StructuredData.GetDataDimension(this->DataDescription);
}
inline void vtkStructuredPoints::GetCellPoints(int cellId, vtkIdList& ptIds)
{
this->vtkStructuredData::_GetCellPoints(cellId, ptIds);
this->StructuredData.GetCellPoints(cellId,ptIds,this->DataDescription,
this->Dimensions);
}
inline void vtkStructuredPoints::GetPointCells(int ptId, vtkIdList& cellIds)
{
this->vtkStructuredData::_GetPointCells(ptId, cellIds);
this->StructuredData.GetPointCells(ptId,cellIds,this->Dimensions);
}
#endif
......@@ -248,11 +248,7 @@ void vtkDelaunay3D::Execute()
return;
}
if ( (numPoints=inPoints->GetNumberOfPoints()) <= 0 )
{
vtkErrorMacro("<<Cannot triangulate; need at least 4 input points");
return;
}
numPoints = inPoints->GetNumberOfPoints();
NumberOfDuplicatePoints = 0;
//
// Create initial bounding triangulation. Have to create bounding points.
......@@ -304,15 +300,15 @@ void vtkDelaunay3D::Execute()
//create bounding tetras (there are six)
pts[0] = numPoints + 4; pts[1] = numPoints + 5;
pts[2] = numPoints ; pts[3] = numPoints + 1;
pts[2] = numPoints ; pts[3] = numPoints + 2;
Mesh->InsertNextCell(VTK_TETRA,4,pts);
pts[0] = numPoints + 4; pts[1] = numPoints + 5;
pts[2] = numPoints + 1; pts[3] = numPoints + 2;
pts[2] = numPoints + 2; pts[3] = numPoints + 1;
Mesh->InsertNextCell(VTK_TETRA,4,pts);
pts[0] = numPoints + 4; pts[1] = numPoints + 5;
pts[2] = numPoints + 2; pts[3] = numPoints + 3;
pts[2] = numPoints + 1; pts[3] = numPoints + 3;
Mesh->InsertNextCell(VTK_TETRA,4,pts);
pts[0] = numPoints + 4; pts[1] = numPoints + 5;
......
......@@ -40,40 +40,11 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
#include "vtkStructuredData.hh"
vtkStructuredData::vtkStructuredData()
{
this->Dimensions[0] = 1;
this->Dimensions[1] = 1;
this->Dimensions[2] = 1;
this->DataDescription = VTK_SINGLE_POINT;
this->Blanking = 0;
this->PointVisibility = NULL;
}
vtkStructuredData::vtkStructuredData(const vtkStructuredData& sds)
{
this->Dimensions[0] = sds.Dimensions[0];
this->Dimensions[1] = sds.Dimensions[1];
this->Dimensions[2] = sds.Dimensions[2];
this->DataDescription = sds.DataDescription;
this->Blanking = sds.Blanking;
if ( sds.PointVisibility != NULL )
this->PointVisibility = new vtkBitArray(*sds.PointVisibility);
else
this->PointVisibility = NULL;
}
vtkStructuredData::~vtkStructuredData()
{
}
// Description:
// Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
int vtkStructuredData::GetDataDimension()
int vtkStructuredData::GetDataDimension(int dataDescription)
{
switch (this->DataDescription)
switch (dataDescription)
{
case VTK_SINGLE_POINT: return 0;
......@@ -89,157 +60,68 @@ int vtkStructuredData::GetDataDimension()
}
// Description:
// Set the i-j-k dimensions of the data.
void vtkStructuredData::SetDimensions(int i, int j, int k)
{
int dim[3];
dim[0] = i;
dim[1] = j;
dim[2] = k;
this->SetDimensions(dim);
}
void vtkStructuredData::SetDimensions(int dim[3])
// Specify the dimensions of a regular, rectangular dataset. The input is
// the new dimensions (inDim) and the current dimensions (dim). The function
// returns the dimension of the dataset (0-3D). If the dimensions are
// improperly specified or are unchanged, a -1 is returned.
int vtkStructuredData::SetDimensions(int inDim[3], int dim[3])
{
int dataDim, i;
int dataDescription=(-1);
vtk_DebugMacro(<< " setting Dimensions to (" << dim[0] << "," << dim[1] << "," << dim[2] << ")");
vtkDebugMacro(<< " setting Dimensions to (" << inDim[0] << "," << inDim[1] << "," << inDim[2] << ")");
if ( dim[0] != this->Dimensions[0] || dim[1] != this->Dimensions[1] ||
dim[2] != this->Dimensions[2] )
if ( inDim[0] != dim[0] || inDim[1] != dim[1] || inDim[2] != dim[2] )
{
if ( dim[0]<1 || dim[1]<1 || dim[2]<1 )
if ( inDim[0]<1 || inDim[1]<1 || inDim[2]<1 )
{
vtk_ErrorMacro (<< "Bad Dimensions, retaining previous values");
return;
vtkErrorMacro (<< "Bad Dimensions, retaining previous values");
return -1;
}
for (dataDim=0, i=0; i<3 ; i++)
{
this->Dimensions[i] = dim[i];
if (dim[i] > 1) dataDim++;
dim[i] = inDim[i];
if (inDim[i] > 1) dataDim++;
}
if ( dataDim == 3 )
{
this->DataDescription = VTK_XYZ_GRID;
dataDescription = VTK_XYZ_GRID;
}
else if ( dataDim == 2)
{
if ( dim[0] == 1 ) this->DataDescription = VTK_YZ_PLANE;
else if ( dim[1] == 1 ) this->DataDescription = VTK_XZ_PLANE;
else this->DataDescription = VTK_XY_PLANE;
if ( inDim[0] == 1 ) dataDescription = VTK_YZ_PLANE;
else if ( inDim[1] == 1 ) dataDescription = VTK_XZ_PLANE;
else dataDescription = VTK_XY_PLANE;
}
else if ( dataDim == 1 )
{
if ( dim[0] != 1 ) this->DataDescription = VTK_X_LINE;
else if ( dim[1] != 1 ) this->DataDescription = VTK_Y_LINE;
else this->DataDescription = VTK_Z_LINE;
if ( inDim[0] != 1 ) dataDescription = VTK_X_LINE;
else if ( inDim[1] != 1 ) dataDescription = VTK_Y_LINE;
else dataDescription = VTK_Z_LINE;
}
else
{
this->DataDescription = VTK_SINGLE_POINT;
dataDescription = VTK_SINGLE_POINT;
}
this->_Modified();
}
}
int *vtkStructuredData::GetDimensions()
{
return this->Dimensions;
}
void vtkStructuredData::GetDimensions(int dim[3])
{
for (int i=0; i<3; i++) dim[i] = this->Dimensions[i];
}
// Description:
// Turn on data blanking. Data blanking is the ability to turn off
// portions of the grid when displaying or operating on it. Some data
// (like finite difference data) routinely turns off data to simulate
// solid obstacles.
void vtkStructuredData::BlankingOn()
{
this->Blanking = 1;
this->_Modified();
if ( !this->PointVisibility )
{
this->PointVisibility = new vtkBitArray(this->_GetNumberOfPoints(),1000);
for (int i=0; i<this->_GetNumberOfPoints(); i++)
{
this->PointVisibility->InsertValue(i,1);
}
}
return dataDescription;
}
// Description:
// Turn off data blanking.
void vtkStructuredData::BlankingOff()
{
this->Blanking = 0;
this->_Modified();
}
// Description:
// Turn off a particular data point.
void vtkStructuredData::BlankPoint(int ptId)
{
if ( !this->PointVisibility ) this->BlankingOn();
this->PointVisibility->InsertValue(ptId,0);
}
// Description:
// Turn on a particular data point.
void vtkStructuredData::UnBlankPoint(int ptId)
{
if ( !this->PointVisibility ) this->BlankingOn();
this->PointVisibility->InsertValue(ptId,1);
}
int vtkStructuredData::_GetNumberOfCells()
{
int nCells=1;
int i;
for (i=0; i<3; i++)
if (this->Dimensions[i] > 1)
nCells *= (this->Dimensions[i]-1);
return nCells;
}
int vtkStructuredData::_GetNumberOfPoints()
{
return Dimensions[0]*Dimensions[1]*Dimensions[2];
}
void vtkStructuredData::_Initialize()
{
this->SetDimensions(1,1,1);
this->Blanking = 0;
if ( this->PointVisibility )
{
this->PointVisibility->Delete();
this->PointVisibility = NULL;
}
}
void vtkStructuredData::_GetCellPoints(int cellId, vtkIdList& ptIds)
// Get the points defining a cell. (See vtkDataSet for more info.)
void vtkStructuredData::GetCellPoints(int cellId, vtkIdList& ptIds,
int dataDescription, int dim[3])
{
int idx, loc[3], npts;
int iMin, iMax, jMin, jMax, kMin, kMax;
int d01 = this->Dimensions[0]*this->Dimensions[1];
int d01 = dim[0]*dim[1];
ptIds.Reset();
switch (this->DataDescription)
switch (dataDescription)
{
case VTK_SINGLE_POINT: // cellId can only be = 0
iMin = iMax = jMin = jMax = kMin = kMax = 0;
......@@ -265,34 +147,34 @@ void vtkStructuredData::_GetCellPoints(int cellId, vtkIdList& ptIds)
case VTK_XY_PLANE:
kMin = kMax = 0;
iMin = cellId % (this->Dimensions[0]-1);
iMin = cellId % (dim[0]-1);
iMax = iMin + 1;
jMin = cellId / (this->Dimensions[0]-1);
jMin = cellId / (dim[0]-1);
jMax = jMin + 1;
break;
case VTK_YZ_PLANE:
iMin = iMax = 0;
jMin = cellId % (this->Dimensions[1]-1);
jMin = cellId % (dim[1]-1);
jMax = jMin + 1;
kMin = cellId / (this->Dimensions[1]-1);
kMin = cellId / (dim[1]-1);
kMax = kMin + 1;
break;
case VTK_XZ_PLANE:
jMin = jMax = 0;
iMin = cellId % (this->Dimensions[0]-1);
iMin = cellId % (dim[0]-1);
iMax = iMin + 1;
kMin = cellId / (this->Dimensions[0]-1);
kMin = cellId / (dim[0]-1);
kMax = kMin + 1;
break;
case VTK_XYZ_GRID:
iMin = cellId % (this->Dimensions[0] - 1);
iMin = cellId % (dim[0] - 1);
iMax = iMin + 1;
jMin = (cellId / (this->Dimensions[0] - 1)) % (this->Dimensions[1] - 1);
jMin = (cellId / (dim[0] - 1)) % (dim[1] - 1);
jMax = jMin + 1;
kMin = cellId / ((this->Dimensions[0] - 1) * (this->Dimensions[1] - 1));
kMin = cellId / ((dim[0] - 1) * (dim[1] - 1));
kMax = kMin + 1;
break;
}
......@@ -304,14 +186,16 @@ void vtkStructuredData::_GetCellPoints(int cellId, vtkIdList& ptIds)
{
for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
{
idx = loc[0] + loc[1]*this->Dimensions[0] + loc[2]*d01;
idx = loc[0] + loc[1]*dim[0] + loc[2]*d01;
ptIds.InsertId(npts++,idx);
}
}
}
}
void vtkStructuredData::_GetPointCells(int ptId, vtkIdList& cellIds)
// Description:
// Get the cells using a point. (See vtkDataSet for more info.)
void vtkStructuredData::GetPointCells(int ptId, vtkIdList& cellIds, int dim[3])
{
int ptDim[3], cellDim[3];
int ptLoc[3], cellLoc[3];
......@@ -321,7 +205,7 @@ void vtkStructuredData::_GetPointCells(int ptId, vtkIdList& cellIds)
for (i=0; i<3; i++)
{
ptDim[i] = this->Dimensions[i];
ptDim[i] = dim[i];
cellDim[i] = ptDim[i] - 1;
}
//
......@@ -355,11 +239,3 @@ void vtkStructuredData::_GetPointCells(int ptId, vtkIdList& cellIds)
return;
}
void vtkStructuredData::_PrintSelf(ostream& os, vtkIndent indent)
{
vtkLWObject::_PrintSelf(os,indent);
os << indent << "Dimensions: (" << this->Dimensions[0] << ", "
<< this->Dimensions[1] << ", "
<< this->Dimensions[2] << ")\n";
}
......@@ -46,11 +46,34 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
vtkStructuredGrid::vtkStructuredGrid()
{