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 =========================================================================*/
27 #ifndef vtkCellLinks_h
28 #define vtkCellLinks_h
29 
30 #include "vtkCommonDataModelModule.h" // For export macro
31 #include "vtkObject.h"
32 class vtkDataSet;
33 class vtkCellArray;
34 
36 {
37 public:
38 
39  //BTX
40  class Link {
41  public:
42  unsigned short ncells;
44  };
45  //ETX
46 
47  static vtkCellLinks *New();
48  vtkTypeMacro(vtkCellLinks,vtkObject);
49  void PrintSelf(ostream& os, vtkIndent indent);
50 
53  void Allocate(vtkIdType numLinks, vtkIdType ext=1000);
54 
56  Link &GetLink(vtkIdType ptId) {return this->Array[ptId];};
57 
59  unsigned short GetNcells(vtkIdType ptId) { return this->Array[ptId].ncells;};
60 
62  void BuildLinks(vtkDataSet *data);
63 
65  void BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity);
66 
68  vtkIdType *GetCells(vtkIdType ptId) {return this->Array[ptId].cells;};
69 
72  vtkIdType InsertNextPoint(int numLinks);
73 
77  void InsertNextCellReference(vtkIdType ptId, vtkIdType cellId);
78 
80  void DeletePoint(vtkIdType ptId);
81 
85  void RemoveCellReference(vtkIdType cellId, vtkIdType ptId);
86 
90  void AddCellReference(vtkIdType cellId, vtkIdType ptId);
91 
94  void ResizeCellList(vtkIdType ptId, int size);
95 
97  void Squeeze();
98 
100  void Reset();
101 
108  unsigned long GetActualMemorySize();
109 
112  void DeepCopy(vtkCellLinks *src);
113 
114 protected:
115  vtkCellLinks():Array(NULL),Size(0),MaxId(-1),Extend(1000) {}
116  ~vtkCellLinks();
117 
119  void IncrementLinkCount(vtkIdType ptId) { this->Array[ptId].ncells++;};
120 
121  void AllocateLinks(vtkIdType n);
122 
124 
125  void InsertCellReference(vtkIdType ptId, unsigned short pos,
126  vtkIdType cellId);
128 
129  Link *Array; // pointer to data
130  vtkIdType Size; // allocated size of data
131  vtkIdType MaxId; // maximum index inserted thus far
132  vtkIdType Extend; // grow array by this point
133  Link *Resize(vtkIdType sz); // function to resize data
134 private:
135  vtkCellLinks(const vtkCellLinks&); // Not implemented.
136  void operator=(const vtkCellLinks&); // Not implemented.
137 };
138 
139 //----------------------------------------------------------------------------
141  unsigned short pos,
142  vtkIdType cellId)
143 {
144  this->Array[ptId].cells[pos] = cellId;
145 }
146 
147 //----------------------------------------------------------------------------
149 {
150  this->Array[ptId].ncells = 0;
151  delete [] this->Array[ptId].cells;
152  this->Array[ptId].cells = NULL;
153 }
154 
155 //----------------------------------------------------------------------------
157  vtkIdType cellId)
158 {
159  this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
160 }
161 
162 //----------------------------------------------------------------------------
164 {
165  vtkIdType *cells=this->Array[ptId].cells;
166  int ncells=this->Array[ptId].ncells;
167 
168  for (int i=0; i < ncells; i++)
169  {
170  if (cells[i] == cellId)
171  {
172  for (int j=i; j < (ncells-1); j++)
173  {
174  cells[j] = cells[j+1];
175  }
176  this->Array[ptId].ncells--;
177  break;
178  }
179  }
180 }
181 
182 //----------------------------------------------------------------------------
184 {
185  this->Array[ptId].cells[this->Array[ptId].ncells++] = cellId;
186 }
187 
188 //----------------------------------------------------------------------------
190 {
191  int newSize;
192  vtkIdType *cells;
193 
194  newSize = this->Array[ptId].ncells + size;
195  cells = new vtkIdType[newSize];
196  memcpy(cells, this->Array[ptId].cells,
197  this->Array[ptId].ncells*sizeof(vtkIdType));
198  delete [] this->Array[ptId].cells;
199  this->Array[ptId].cells = cells;
200 }
201 
202 #endif
203 
abstract base class for most VTK objects
Definition: vtkObject.h:61
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int vtkIdType
Definition: vtkType.h:275
virtual void PrintSelf(ostream &os, vtkIndent indent)
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