00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00031
#ifndef __vtkCellLinks_h
00032
#define __vtkCellLinks_h
00033
00034
#include "vtkObject.h"
00035
class vtkDataSet;
00036
class vtkCellArray;
00037
00038 class VTK_COMMON_EXPORT vtkCellLinks :
public vtkObject
00039 {
00040
public:
00041
00042
00043 class Link {
00044
public:
00045 unsigned short ncells;
00046 vtkIdType *cells;
00047 };
00048
00049
00050
static vtkCellLinks *
New();
00051 vtkTypeRevisionMacro(vtkCellLinks,
vtkObject);
00052
00055
void Allocate(
vtkIdType numLinks,
vtkIdType ext=1000);
00056
00058 Link &GetLink(
vtkIdType ptId) {
return this->Array[ptId];};
00059
00061 unsigned short GetNcells(
vtkIdType ptId) {
return this->Array[ptId].ncells;};
00062
00064
void BuildLinks(
vtkDataSet *data);
00065
00067
void BuildLinks(
vtkDataSet *data,
vtkCellArray *Connectivity);
00068
00070 vtkIdType *GetCells(
vtkIdType ptId) {
return this->Array[ptId].cells;};
00071
00074
vtkIdType InsertNextPoint(
int numLinks);
00075
00079
void InsertNextCellReference(
vtkIdType ptId,
vtkIdType cellId);
00080
00082
void DeletePoint(
vtkIdType ptId);
00083
00087
void RemoveCellReference(
vtkIdType cellId,
vtkIdType ptId);
00088
00092
void AddCellReference(
vtkIdType cellId,
vtkIdType ptId);
00093
00096
void ResizeCellList(
vtkIdType ptId,
int size);
00097
00099
void Squeeze();
00100
00102
void Reset();
00103
00110
unsigned long GetActualMemorySize();
00111
00114
void DeepCopy(vtkCellLinks *src);
00115
00116
protected:
00117 vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
00118 ~vtkCellLinks();
00119
00121 void IncrementLinkCount(
vtkIdType ptId) { this->Array[ptId].ncells++;};
00122
00123
void AllocateLinks(
vtkIdType n);
00124
00126
00127
void InsertCellReference(
vtkIdType ptId,
unsigned short pos,
00128
vtkIdType cellId);
00130
00131 Link *Array;
00132 vtkIdType Size;
00133 vtkIdType MaxId;
00134 vtkIdType Extend;
00135
Link *Resize(
vtkIdType sz);
00136
private:
00137 vtkCellLinks(
const vtkCellLinks&);
00138
void operator=(
const vtkCellLinks&);
00139 };
00140
00141
00142 inline void vtkCellLinks::InsertCellReference(
vtkIdType ptId,
00143
unsigned short pos,
00144
vtkIdType cellId)
00145 {
00146 this->
Array[ptId].
cells[pos] = cellId;
00147 }
00148
00149 inline void vtkCellLinks::DeletePoint(
vtkIdType ptId)
00150 {
00151 this->
Array[ptId].
ncells = 0;
00152
delete [] this->
Array[ptId].
cells;
00153 this->
Array[ptId].
cells = NULL;
00154 }
00155
00156 inline void vtkCellLinks::InsertNextCellReference(
vtkIdType ptId,
00157
vtkIdType cellId)
00158 {
00159 this->
Array[ptId].
cells[this->
Array[ptId].
ncells++] = cellId;
00160 }
00161
00162 inline void vtkCellLinks::RemoveCellReference(
vtkIdType cellId,
vtkIdType ptId)
00163 {
00164
vtkIdType *cells=this->
Array[ptId].
cells;
00165
int ncells=this->Array[ptId].ncells;
00166
00167
for (
int i=0; i < ncells; i++)
00168 {
00169
if (cells[i] == cellId)
00170 {
00171
for (
int j=i; j < (ncells-1); j++)
00172 {
00173 cells[j] = cells[j+1];
00174 }
00175 this->Array[ptId].ncells--;
00176
break;
00177 }
00178 }
00179 }
00180
00181 inline void vtkCellLinks::AddCellReference(
vtkIdType cellId,
vtkIdType ptId)
00182 {
00183 this->
Array[ptId].
cells[this->
Array[ptId].
ncells++] = cellId;
00184 }
00185
00186 inline void vtkCellLinks::ResizeCellList(
vtkIdType ptId,
int size)
00187 {
00188
int newSize;
00189
vtkIdType *cells;
00190
00191 newSize = this->
Array[ptId].
ncells + size;
00192 cells =
new vtkIdType[newSize];
00193 memcpy(cells, this->Array[ptId].cells,
00194 this->Array[ptId].ncells*
sizeof(
vtkIdType));
00195
delete [] this->Array[ptId].cells;
00196 this->Array[ptId].cells = cells;
00197 }
00198
00199
#endif
00200