Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages
Common/vtkCellLinks.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00045 #ifndef __vtkCellLinks_h
00046 #define __vtkCellLinks_h
00047
00048 #include "vtkObject.h"
00049 class vtkDataSet;
00050 class vtkCellArray;
00051
00052 class VTK_COMMON_EXPORT vtkCellLinks : public vtkObject
00053 {
00054 public:
00055
00056
00057 class Link {
00058 public:
00059 unsigned short ncells;
00060 vtkIdType *cells;
00061 };
00062
00063
00064 static vtkCellLinks *New();
00065 vtkTypeRevisionMacro(vtkCellLinks,vtkObject);
00066
00069 void Allocate(vtkIdType numLinks, vtkIdType ext=1000);
00070
00072 Link &GetLink(vtkIdType ptId) {return this->Array[ptId];};
00073
00075 unsigned short GetNcells(vtkIdType ptId) { return this->Array[ptId].ncells;};
00076
00078 void BuildLinks(vtkDataSet *data);
00079
00081 void BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity);
00082
00084 vtkIdType *GetCells(vtkIdType ptId) {return this->Array[ptId].cells;};
00085
00088 vtkIdType InsertNextPoint(int numLinks);
00089
00093 void InsertNextCellReference(vtkIdType ptId, vtkIdType cellId);
00094
00096 void DeletePoint(vtkIdType ptId);
00097
00101 void RemoveCellReference(vtkIdType cellId, vtkIdType ptId);
00102
00106 void AddCellReference(vtkIdType cellId, vtkIdType ptId);
00107
00110 void ResizeCellList(vtkIdType ptId, int size);
00111
00113 void Squeeze();
00114
00116 void Reset();
00117
00124 unsigned long GetActualMemorySize();
00125
00128 void DeepCopy(vtkCellLinks *src);
00129
00130 protected:
00131 vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
00132 ~vtkCellLinks();
00133
00135 void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++;};
00136
00137 void AllocateLinks(vtkIdType n);
00138
00140
00141 void InsertCellReference(vtkIdType ptId, unsigned short pos,
00142 vtkIdType cellId);
00144
00145 Link *Array;
00146 vtkIdType Size;
00147 vtkIdType MaxId;
00148 vtkIdType Extend;
00149 Link *Resize(vtkIdType sz);
00150 private:
00151 vtkCellLinks(const vtkCellLinks&);
00152 void operator=(const vtkCellLinks&);
00153 };
00154
00155
00156 inline void vtkCellLinks::InsertCellReference(vtkIdType ptId,
00157 unsigned short pos,
00158 vtkIdType cellId)
00159 {
00160 this->Array[ptId].cells[pos] = cellId;
00161 }
00162
00163 inline void vtkCellLinks::DeletePoint(vtkIdType ptId)
00164 {
00165 this->Array[ptId].ncells = 0;
00166 delete [] this->Array[ptId].cells;
00167 this->Array[ptId].cells = NULL;
00168 }
00169
00170 inline void vtkCellLinks::InsertNextCellReference(vtkIdType ptId,
00171 vtkIdType cellId)
00172 {
00173 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
00174 }
00175
00176 inline void vtkCellLinks::RemoveCellReference(vtkIdType cellId, vtkIdType ptId)
00177 {
00178 vtkIdType *cells=this->Array[ptId].cells;
00179 int ncells=this->Array[ptId].ncells;
00180
00181 for (int i=0; i < ncells; i++)
00182 {
00183 if (cells[i] == cellId)
00184 {
00185 for (int j=i; j < (ncells-1); j++)
00186 {
00187 cells[j] = cells[j+1];
00188 }
00189 this->Array[ptId].ncells--;
00190 break;
00191 }
00192 }
00193 }
00194
00195 inline void vtkCellLinks::AddCellReference(vtkIdType cellId, vtkIdType ptId)
00196 {
00197 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
00198 }
00199
00200 inline void vtkCellLinks::ResizeCellList(vtkIdType ptId, int size)
00201 {
00202 int newSize;
00203 vtkIdType *cells;
00204
00205 newSize = this->Array[ptId].ncells + size;
00206 cells = new vtkIdType[newSize];
00207 memcpy(cells, this->Array[ptId].cells,
00208 this->Array[ptId].ncells*sizeof(vtkIdType));
00209 delete [] this->Array[ptId].cells;
00210 this->Array[ptId].cells = cells;
00211 }
00212
00213 #endif
00214