Commit f69081d4 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: New interface methods.

parent 6d569083
......@@ -62,7 +62,7 @@ public:
int GetLocation(int npts);
void ReverseCell(int loc);
void ReplaceCell(int loc, vlIdList& ptIds);
void ReplaceCell(int loc, int npts, int *pts);
protected:
int NumberOfCells;
......@@ -200,12 +200,12 @@ inline void vlCellArray::ReverseCell(int loc)
// Description:
// Replace the point ids of the cell with a different list of point ids.
inline void vlCellArray::ReplaceCell(int loc, vlIdList& ptIds)
inline void vlCellArray::ReplaceCell(int loc, int npts, int *pts)
{
int i;
int npts=this->Ia.GetValue(loc);
int *pts=this->Ia.GetPtr(loc+1);
for (i=0; i < npts; i++) pts[i] = ptIds.GetId(i);
int *oldPts=this->Ia.GetPtr(loc+1);
for (i=0; i < npts; i++) oldPts[i] = pts[i];
}
#endif
......@@ -24,6 +24,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#define __vlCellList_h
#include "RefCount.hh"
#include "CellType.hh"
struct vlCell_s {
unsigned char type; //from CellTypes.hh
......@@ -44,6 +45,8 @@ public:
void InsertCell(const int id, const unsigned char type, const int loc);
int InsertNextCell(const unsigned char type, const int loc);
void DeleteCell(int cellId);
void Squeeze();
void Reset();
......@@ -76,4 +79,11 @@ inline int vlCellList::GetCellLocation(const int cellId)
return this->Array[cellId].loc;
}
// Description:
// Delete cell by setting to NULL cell type.
inline void vlCellList::DeleteCell(int cellId)
{
this->Array[cellId].type = vlNULL_ELEMENT;
}
#endif
......@@ -46,8 +46,13 @@ public:
void IncrementLinkCount(int ptId);
void AllocateLinks(int n);
void InsertCellReference(int ptId, unsigned short pos, int cellId);
void InsertNextCellReference(int ptId, int cellId);
void BuildLinks(vlDataSet *data);
void DeletePoint(int ptId);
void RemoveCellReference(int cellId, int ptId);
void ResizeCellList(int ptId, int size);
void Squeeze();
void Reset();
......@@ -88,5 +93,58 @@ inline void vlLinkList::InsertCellReference(int ptId, unsigned short pos, int ce
this->Array[ptId].cells[pos] = cellId;
}
// Description:
// Delete point (and storage) by destroying links to using cells.
inline void vlLinkList::DeletePoint(int ptId)
{
this->Array[ptId].ncells = 0;
delete [] this->Array[ptId].cells;
this->Array[ptId].cells = NULL;
}
// Description:
// Insert a cell id into the list of cells (at the end) using the cell id
// provided. (Make sure to extend the link list (if necessary) using the
// method ResizeCellList()).
inline void vlLinkList::InsertNextCellReference(int ptId, int cellId)
{
this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
}
// Description:
// Delete the reference to the cell (cellId) from the point (ptId). This
// removes the reference to the cellId from the cell list, but does not resize
// the list (recover memory with ResizeCellList(), if necessary).
inline void vlLinkList::RemoveCellReference(int cellId, int ptId)
{
int *cells=this->Array[ptId].cells;
int ncells=this->Array[ptId].ncells;
for (int i=0; i < ncells; i++)
{
if (cells[i] == cellId)
{
for (int j=i; j < (ncells-1); j++) cells[j] = cells[j+1];
this->Array[ptId].ncells--;
break;
}
}
}
// Description:
// Increase the length of the list of cells using a point by the size
// specified.
inline void vlLinkList::ResizeCellList(int ptId, int size)
{
int *cells, newSize;
newSize = this->Array[ptId].ncells + size;
cells = new int[newSize];
memcpy(cells, this->Array[ptId].cells, this->Array[ptId].ncells*sizeof(int));
delete [] this->Array[ptId].cells;
this->Array[ptId].cells = cells;
this->Array[ptId].ncells = newSize;
}
#endif
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