VTK  9.3.0
vtkCellLinks.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
24#ifndef vtkCellLinks_h
25#define vtkCellLinks_h
26
28#include "vtkCommonDataModelModule.h" // For export macro
29
30VTK_ABI_NAMESPACE_BEGIN
31class vtkDataSet;
32class vtkCellArray;
33
34class VTKCOMMONDATAMODEL_EXPORT vtkCellLinks : public vtkAbstractCellLinks
35{
36public:
37 class Link
38 {
39 public:
42 };
43
45
48 static vtkCellLinks* New();
50 void PrintSelf(ostream& os, vtkIndent indent) override;
52
56 void BuildLinks() override;
57
62 void Allocate(vtkIdType numLinks, vtkIdType ext = 1000);
63
67 void Initialize() override;
68
72 Link& GetLink(vtkIdType ptId) { return this->Array[ptId]; }
73
77 vtkIdType GetNcells(vtkIdType ptId) { return this->Array[ptId].ncells; }
78
82 vtkIdType* GetCells(vtkIdType ptId) { return this->Array[ptId].cells; }
83
85
92 void SelectCells(vtkIdType minMaxDegree[2], unsigned char* cellSelection) override;
94
100
106 void InsertNextCellReference(vtkIdType ptId, vtkIdType cellId);
107
111 void DeletePoint(vtkIdType ptId);
112
118 void RemoveCellReference(vtkIdType cellId, vtkIdType ptId);
119
125 void AddCellReference(vtkIdType cellId, vtkIdType ptId);
126
131 void ResizeCellList(vtkIdType ptId, int size);
132
136 void Squeeze() override;
137
141 void Reset() override;
142
151 unsigned long GetActualMemorySize() override;
152
157 void DeepCopy(vtkAbstractCellLinks* src) override;
158
159protected:
161 ~vtkCellLinks() override;
162
166 void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++; }
167
169
173 void InsertCellReference(vtkIdType ptId, vtkIdType pos, vtkIdType cellId);
174
175 Link* Array; // pointer to data
176 vtkIdType Size; // allocated size of data
177 vtkIdType MaxId; // maximum index inserted thus far
178 vtkIdType Extend; // grow array by this point
179 Link* Resize(vtkIdType sz); // function to resize data
180
181 // Some information recorded at build time
184
185private:
186 vtkCellLinks(const vtkCellLinks&) = delete;
187 void operator=(const vtkCellLinks&) = delete;
188};
189
190//----------------------------------------------------------------------------
192{
193 this->Array[ptId].cells[pos] = cellId;
194}
195
196//----------------------------------------------------------------------------
198{
199 this->Array[ptId].ncells = 0;
200 delete[] this->Array[ptId].cells;
201 this->Array[ptId].cells = nullptr;
202}
203
204//----------------------------------------------------------------------------
206{
207 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
208}
209
210//----------------------------------------------------------------------------
212{
213 vtkIdType* cells = this->Array[ptId].cells;
214 vtkIdType ncells = this->Array[ptId].ncells;
215
216 for (vtkIdType i = 0; i < ncells; i++)
217 {
218 if (cells[i] == cellId)
219 {
220 for (vtkIdType j = i; j < (ncells - 1); j++)
221 {
222 cells[j] = cells[j + 1];
223 }
224 this->Array[ptId].ncells--;
225 break;
226 }
227 }
228}
229
230//----------------------------------------------------------------------------
232{
233 this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
234}
235
236//----------------------------------------------------------------------------
237inline void vtkCellLinks::ResizeCellList(vtkIdType ptId, int size)
238{
239 vtkIdType newSize = this->Array[ptId].ncells + size;
240 vtkIdType* cells = new vtkIdType[newSize];
241 memcpy(cells, this->Array[ptId].cells,
242 static_cast<size_t>(this->Array[ptId].ncells) * sizeof(vtkIdType));
243 delete[] this->Array[ptId].cells;
244 this->Array[ptId].cells = cells;
245}
246
247VTK_ABI_NAMESPACE_END
248#endif
object to represent cell connectivity
abstract class to specify dataset behavior
Definition vtkDataSet.h:53
a simple class to control print indentation
Definition vtkIndent.h:29
int vtkIdType
Definition vtkType.h:315