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=========================================================================*/
35#ifndef vtkCellLinks_h
36#define vtkCellLinks_h
37
38#include "vtkCommonDataModelModule.h" // For export macro
40
41class vtkDataSet;
42class vtkCellArray;
43
44class VTKCOMMONDATAMODEL_EXPORT vtkCellLinks : public vtkAbstractCellLinks
45{
46public:
47
48 class Link {
49 public:
50 unsigned short ncells;
52 };
53
55
58 static vtkCellLinks *New();
60 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
62
67 void BuildLinks(vtkDataSet *data) VTK_OVERRIDE;
68
72 void BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity);
73
78 void Allocate(vtkIdType numLinks, vtkIdType ext=1000);
79
83 void Initialize();
84
88 Link &GetLink(vtkIdType ptId) {return this->Array[ptId];};
89
93 unsigned short GetNcells(vtkIdType ptId) { return this->Array[ptId].ncells;};
94
98 vtkIdType *GetCells(vtkIdType ptId) {return this->Array[ptId].cells;};
99
105
111 void InsertNextCellReference(vtkIdType ptId, vtkIdType cellId);
112
116 void DeletePoint(vtkIdType ptId);
117
123 void RemoveCellReference(vtkIdType cellId, vtkIdType ptId);
124
130 void AddCellReference(vtkIdType cellId, vtkIdType ptId);
131
136 void ResizeCellList(vtkIdType ptId, int size);
137
141 void Squeeze();
142
146 void Reset();
147
156 unsigned long GetActualMemorySize();
157
163
164protected:
165 vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {}
166 ~vtkCellLinks() VTK_OVERRIDE;
167
171 void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++;};
172
174
178 void InsertCellReference(vtkIdType ptId, unsigned short pos,
179 vtkIdType cellId);
180
181 Link *Array; // pointer to data
182 vtkIdType Size; // allocated size of data
183 vtkIdType MaxId; // maximum index inserted thus far
184 vtkIdType Extend; // grow array by this point
185 Link *Resize(vtkIdType sz); // function to resize data
186
187private:
188 vtkCellLinks(const vtkCellLinks&) VTK_DELETE_FUNCTION;
189 void operator=(const vtkCellLinks&) VTK_DELETE_FUNCTION;
190};
191
192//----------------------------------------------------------------------------
194 unsigned short pos,
195 vtkIdType cellId)
196{
197 this->Array[ptId].cells[pos] = cellId;
198}
199
200//----------------------------------------------------------------------------
202{
203 this->Array[ptId].ncells = 0;
204 delete [] this->Array[ptId].cells;
205 this->Array[ptId].cells = NULL;
206}
207
208//----------------------------------------------------------------------------
210 vtkIdType cellId)
211{
212 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
213}
214
215//----------------------------------------------------------------------------
217{
218 vtkIdType *cells=this->Array[ptId].cells;
219 int ncells=this->Array[ptId].ncells;
220
221 for (int i=0; i < ncells; i++)
222 {
223 if (cells[i] == cellId)
224 {
225 for (int j=i; j < (ncells-1); j++)
226 {
227 cells[j] = cells[j+1];
228 }
229 this->Array[ptId].ncells--;
230 break;
231 }
232 }
233}
234
235//----------------------------------------------------------------------------
237{
238 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
239}
240
241//----------------------------------------------------------------------------
243{
244 int newSize;
245 vtkIdType *cells;
246
247 newSize = this->Array[ptId].ncells + size;
248 cells = new vtkIdType[newSize];
249 memcpy(cells, this->Array[ptId].cells,
250 this->Array[ptId].ncells*sizeof(vtkIdType));
251 delete [] this->Array[ptId].cells;
252 this->Array[ptId].cells = cells;
253}
254
255#endif
object to represent cell connectivity
Definition: vtkCellArray.h:51
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
a simple class to control print indentation
Definition: vtkIndent.h:40
@ size
Definition: vtkX3D.h:253
@ data
Definition: vtkX3D.h:315
int vtkIdType
Definition: vtkType.h:287