00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00055 #ifndef __vtkCellLinks_h
00056 #define __vtkCellLinks_h
00057
00058 #include "vtkObject.h"
00059 class vtkDataSet;
00060 class vtkCellArray;
00061
00062 struct _vtkLink_s {
00063 unsigned short ncells;
00064 vtkIdType *cells;
00065 };
00066
00067 class VTK_COMMON_EXPORT vtkCellLinks : public vtkObject
00068 {
00069 public:
00070 static vtkCellLinks *New();
00071 vtkTypeMacro(vtkCellLinks,vtkObject);
00072
00075 void Allocate(vtkIdType numLinks, vtkIdType ext=1000);
00076
00078 _vtkLink_s &GetLink(vtkIdType ptId) {return this->Array[ptId];};
00079
00081 unsigned short GetNcells(vtkIdType ptId) { return this->Array[ptId].ncells;};
00082
00084 void BuildLinks(vtkDataSet *data);
00085
00087 void BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity);
00088
00090 vtkIdType *GetCells(vtkIdType ptId) {return this->Array[ptId].cells;};
00091
00094 vtkIdType InsertNextPoint(int numLinks);
00095
00099 void InsertNextCellReference(vtkIdType ptId, vtkIdType cellId);
00100
00102 void DeletePoint(vtkIdType ptId);
00103
00107 void RemoveCellReference(vtkIdType cellId, vtkIdType ptId);
00108
00112 void AddCellReference(vtkIdType cellId, vtkIdType ptId);
00113
00116 void ResizeCellList(vtkIdType ptId, int size);
00117
00119 void Squeeze();
00120
00122 void Reset();
00123
00130 unsigned long GetActualMemorySize();
00131
00134 void DeepCopy(vtkCellLinks *src);
00135
00136 protected:
00137 vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
00138 ~vtkCellLinks();
00139
00141 void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++;};
00142
00143 void AllocateLinks(vtkIdType n);
00144
00146
00147 void InsertCellReference(vtkIdType ptId, unsigned short pos,
00148 vtkIdType cellId);
00150
00151 _vtkLink_s *Array;
00152 vtkIdType Size;
00153 vtkIdType MaxId;
00154 vtkIdType Extend;
00155 _vtkLink_s *Resize(vtkIdType sz);
00156 private:
00157 vtkCellLinks(const vtkCellLinks&);
00158 void operator=(const vtkCellLinks&);
00159 };
00160
00161
00162 inline void vtkCellLinks::InsertCellReference(vtkIdType ptId,
00163 unsigned short pos,
00164 vtkIdType cellId)
00165 {
00166 this->Array[ptId].cells[pos] = cellId;
00167 }
00168
00169 inline void vtkCellLinks::DeletePoint(vtkIdType ptId)
00170 {
00171 this->Array[ptId].ncells = 0;
00172 delete [] this->Array[ptId].cells;
00173 this->Array[ptId].cells = NULL;
00174 }
00175
00176 inline void vtkCellLinks::InsertNextCellReference(vtkIdType ptId,
00177 vtkIdType cellId)
00178 {
00179 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
00180 }
00181
00182 inline void vtkCellLinks::RemoveCellReference(vtkIdType cellId, vtkIdType ptId)
00183 {
00184 vtkIdType *cells=this->Array[ptId].cells;
00185 int ncells=this->Array[ptId].ncells;
00186
00187 for (int i=0; i < ncells; i++)
00188 {
00189 if (cells[i] == cellId)
00190 {
00191 for (int j=i; j < (ncells-1); j++)
00192 {
00193 cells[j] = cells[j+1];
00194 }
00195 this->Array[ptId].ncells--;
00196 break;
00197 }
00198 }
00199 }
00200
00201 inline void vtkCellLinks::AddCellReference(vtkIdType cellId, vtkIdType ptId)
00202 {
00203 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
00204 }
00205
00206 inline void vtkCellLinks::ResizeCellList(vtkIdType ptId, int size)
00207 {
00208 int newSize;
00209 vtkIdType *cells;
00210
00211 newSize = this->Array[ptId].ncells + size;
00212 cells = new vtkIdType[newSize];
00213 memcpy(cells, this->Array[ptId].cells,
00214 this->Array[ptId].ncells*sizeof(vtkIdType));
00215 delete [] this->Array[ptId].cells;
00216 this->Array[ptId].cells = cells;
00217 }
00218
00219 #endif
00220