VTK
vtkCellLinks.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCellLinks.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
34 #ifndef vtkCellLinks_h
35 #define vtkCellLinks_h
36 
37 #include "vtkCommonDataModelModule.h" // For export macro
38 #include "vtkAbstractCellLinks.h"
39 
40 class vtkDataSet;
41 class vtkCellArray;
42 
44 {
45 public:
46 
47  //BTX
48  class Link {
49  public:
50  unsigned short ncells;
52  };
53  //ETX
54 
56 
57  static vtkCellLinks *New();
59  void PrintSelf(ostream& os, vtkIndent indent);
61 
64  virtual void BuildLinks(vtkDataSet *data);
65 
67  void BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity);
68 
71  void Allocate(vtkIdType numLinks, vtkIdType ext=1000);
72 
74  void Initialize();
75 
77  Link &GetLink(vtkIdType ptId) {return this->Array[ptId];};
78 
80  unsigned short GetNcells(vtkIdType ptId) { return this->Array[ptId].ncells;};
81 
83  vtkIdType *GetCells(vtkIdType ptId) {return this->Array[ptId].cells;};
84 
87  vtkIdType InsertNextPoint(int numLinks);
88 
92  void InsertNextCellReference(vtkIdType ptId, vtkIdType cellId);
93 
95  void DeletePoint(vtkIdType ptId);
96 
100  void RemoveCellReference(vtkIdType cellId, vtkIdType ptId);
101 
105  void AddCellReference(vtkIdType cellId, vtkIdType ptId);
106 
109  void ResizeCellList(vtkIdType ptId, int size);
110 
112  void Squeeze();
113 
115  void Reset();
116 
123  unsigned long GetActualMemorySize();
124 
127  void DeepCopy(vtkCellLinks *src);
128 
129 protected:
130  vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {}
131  virtual ~vtkCellLinks();
132 
134  void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++;};
135 
136  void AllocateLinks(vtkIdType n);
137 
139 
140  void InsertCellReference(vtkIdType ptId, unsigned short pos,
141  vtkIdType cellId);
143 
144  Link *Array; // pointer to data
145  vtkIdType Size; // allocated size of data
146  vtkIdType MaxId; // maximum index inserted thus far
147  vtkIdType Extend; // grow array by this point
148  Link *Resize(vtkIdType sz); // function to resize data
149 
150 private:
151  vtkCellLinks(const vtkCellLinks&); // Not implemented.
152  void operator=(const vtkCellLinks&); // Not implemented.
153 };
154 
155 //----------------------------------------------------------------------------
157  unsigned short pos,
158  vtkIdType cellId)
159 {
160  this->Array[ptId].cells[pos] = cellId;
161 }
162 
163 //----------------------------------------------------------------------------
165 {
166  this->Array[ptId].ncells = 0;
167  delete [] this->Array[ptId].cells;
168  this->Array[ptId].cells = NULL;
169 }
170 
171 //----------------------------------------------------------------------------
173  vtkIdType cellId)
174 {
175  this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
176 }
177 
178 //----------------------------------------------------------------------------
180 {
181  vtkIdType *cells=this->Array[ptId].cells;
182  int ncells=this->Array[ptId].ncells;
183 
184  for (int i=0; i < ncells; i++)
185  {
186  if (cells[i] == cellId)
187  {
188  for (int j=i; j < (ncells-1); j++)
189  {
190  cells[j] = cells[j+1];
191  }
192  this->Array[ptId].ncells--;
193  break;
194  }
195  }
196 }
197 
198 //----------------------------------------------------------------------------
200 {
201  this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
202 }
203 
204 //----------------------------------------------------------------------------
206 {
207  int newSize;
208  vtkIdType *cells;
209 
210  newSize = this->Array[ptId].ncells + size;
211  cells = new vtkIdType[newSize];
212  memcpy(cells, this->Array[ptId].cells,
213  this->Array[ptId].ncells*sizeof(vtkIdType));
214  delete [] this->Array[ptId].cells;
215  this->Array[ptId].cells = cells;
216 }
217 
218 #endif
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int vtkIdType
Definition: vtkType.h:247
a simple class to control print indentation
Definition: vtkIndent.h:38
object to represent cell connectivity
Definition: vtkCellArray.h:49
static vtkObject * New()
#define VTKCOMMONDATAMODEL_EXPORT