VTK  9.3.1
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 
27 #include "vtkAbstractCellLinks.h"
28 #include "vtkCommonDataModelModule.h" // For export macro
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class vtkDataSet;
32 class vtkCellArray;
33 
34 class VTKCOMMONDATAMODEL_EXPORT vtkCellLinks : public vtkAbstractCellLinks
35 {
36 public:
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 
99  vtkIdType InsertNextPoint(int numLinks);
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 
159 protected:
160  vtkCellLinks();
161  ~vtkCellLinks() override;
162 
166  void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++; }
167 
168  void AllocateLinks(vtkIdType n);
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 
185 private:
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 //----------------------------------------------------------------------------
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 
247 VTK_ABI_NAMESPACE_END
248 #endif
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
int vtkIdType
Definition: vtkType.h:315
a simple class to control print indentation
Definition: vtkIndent.h:28
object to represent cell connectivity
Definition: vtkCellArray.h:175
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...