VTK  9.0.20200930
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 =========================================================================*/
36 #ifndef vtkCellLinks_h
37 #define vtkCellLinks_h
38 
39 #include "vtkAbstractCellLinks.h"
40 #include "vtkCommonDataModelModule.h" // For export macro
41 
42 class vtkDataSet;
43 class vtkCellArray;
44 
45 class VTKCOMMONDATAMODEL_EXPORT vtkCellLinks : public vtkAbstractCellLinks
46 {
47 public:
48  class Link
49  {
50  public:
53  };
54 
56 
59  static vtkCellLinks* New();
61  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
68  void BuildLinks(vtkDataSet* data) override;
69 
74  void Allocate(vtkIdType numLinks, vtkIdType ext = 1000);
75 
79  void Initialize() override;
80 
84  Link& GetLink(vtkIdType ptId) { return this->Array[ptId]; }
85 
89  vtkIdType GetNcells(vtkIdType ptId) { return this->Array[ptId].ncells; }
90 
94  vtkIdType* GetCells(vtkIdType ptId) { return this->Array[ptId].cells; }
95 
97 
104  void SelectCells(vtkIdType minMaxDegree[2], unsigned char* cellSelection) override;
106 
111  vtkIdType InsertNextPoint(int numLinks);
112 
118  void InsertNextCellReference(vtkIdType ptId, vtkIdType cellId);
119 
123  void DeletePoint(vtkIdType ptId);
124 
130  void RemoveCellReference(vtkIdType cellId, vtkIdType ptId);
131 
137  void AddCellReference(vtkIdType cellId, vtkIdType ptId);
138 
143  void ResizeCellList(vtkIdType ptId, int size);
144 
148  void Squeeze() override;
149 
153  void Reset() override;
154 
163  unsigned long GetActualMemorySize() override;
164 
169  void DeepCopy(vtkAbstractCellLinks* src) override;
170 
171 protected:
173  : Array(nullptr)
174  , Size(0)
175  , MaxId(-1)
176  , Extend(1000)
177  , NumberOfPoints(0)
178  , NumberOfCells(0)
179  {
180  }
181  ~vtkCellLinks() override;
182 
186  void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++; }
187 
188  void AllocateLinks(vtkIdType n);
189 
193  void InsertCellReference(vtkIdType ptId, vtkIdType pos, vtkIdType cellId);
194 
195  Link* Array; // pointer to data
196  vtkIdType Size; // allocated size of data
197  vtkIdType MaxId; // maximum index inserted thus far
198  vtkIdType Extend; // grow array by this point
199  Link* Resize(vtkIdType sz); // function to resize data
200 
201  // Some information recorded at build time
204 
205 private:
206  vtkCellLinks(const vtkCellLinks&) = delete;
207  void operator=(const vtkCellLinks&) = delete;
208 };
209 
210 //----------------------------------------------------------------------------
212 {
213  this->Array[ptId].cells[pos] = cellId;
214 }
215 
216 //----------------------------------------------------------------------------
218 {
219  this->Array[ptId].ncells = 0;
220  delete[] this->Array[ptId].cells;
221  this->Array[ptId].cells = nullptr;
222 }
223 
224 //----------------------------------------------------------------------------
226 {
227  this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
228 }
229 
230 //----------------------------------------------------------------------------
232 {
233  vtkIdType* cells = this->Array[ptId].cells;
234  vtkIdType ncells = this->Array[ptId].ncells;
235 
236  for (vtkIdType i = 0; i < ncells; i++)
237  {
238  if (cells[i] == cellId)
239  {
240  for (vtkIdType j = i; j < (ncells - 1); j++)
241  {
242  cells[j] = cells[j + 1];
243  }
244  this->Array[ptId].ncells--;
245  break;
246  }
247  }
248 }
249 
250 //----------------------------------------------------------------------------
252 {
253  this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
254 }
255 
256 //----------------------------------------------------------------------------
258 {
259  vtkIdType newSize = this->Array[ptId].ncells + size;
260  vtkIdType* cells = new vtkIdType[newSize];
261  memcpy(cells, this->Array[ptId].cells,
262  static_cast<size_t>(this->Array[ptId].ncells) * sizeof(vtkIdType));
263  delete[] this->Array[ptId].cells;
264  this->Array[ptId].cells = cells;
265 }
266 
267 #endif
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkX3D::data
Definition: vtkX3D.h:321
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:180
vtkX3D::size
Definition: vtkX3D.h:259
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56