VTK  9.3.1
vtkGenericEdgeTable.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
18 #ifndef vtkGenericEdgeTable_h
19 #define vtkGenericEdgeTable_h
20 
21 #include "vtkCommonDataModelModule.h" // For export macro
22 #include "vtkObject.h"
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkEdgeTableEdge;
26 class vtkEdgeTablePoints;
27 
28 class VTKCOMMONDATAMODEL_EXPORT vtkGenericEdgeTable : public vtkObject
29 {
30 public:
34  static vtkGenericEdgeTable* New();
35 
37 
41  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
47  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, vtkIdType& ptId);
48 
52  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1);
53 
58  int RemoveEdge(vtkIdType e1, vtkIdType e2);
59 
65  int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType& ptId);
66 
70  int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2, vtkIdType cellId);
71 
75  int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2);
76 
81  void Initialize(vtkIdType start);
82 
87  int GetNumberOfComponents();
88 
93  void SetNumberOfComponents(int count);
94 
98  int CheckPoint(vtkIdType ptId);
99 
104  int CheckPoint(vtkIdType ptId, double point[3], double* scalar);
105 
107 
110  void InsertPoint(vtkIdType ptId, double point[3]);
111  // \pre: sizeof(s)==GetNumberOfComponents()
112  void InsertPointAndScalar(vtkIdType ptId, double pt[3], double* s);
114 
118  void RemovePoint(vtkIdType ptId);
119 
123  void IncrementPointReferenceCount(vtkIdType ptId);
124 
126 
131  void DumpTable();
132  void LoadFactor();
134 
136  {
137  public:
139  double Coord[3];
140  double* Scalar; // point data: all point-centered attributes at this point
142 
143  int Reference; // signed char
144 
149  PointEntry(int size);
150 
151  ~PointEntry() { delete[] this->Scalar; }
152 
153  PointEntry(const PointEntry& other)
154  {
155  this->PointId = other.PointId;
156 
157  memcpy(this->Coord, other.Coord, sizeof(double) * 3);
158 
159  int c = other.numberOfComponents;
160  this->numberOfComponents = c;
161  this->Scalar = new double[c];
162  memcpy(this->Scalar, other.Scalar, sizeof(double) * c);
163  this->Reference = other.Reference;
164  }
165 
167  {
168  if (this != &other)
169  {
170  this->PointId = other.PointId;
171 
172  memcpy(this->Coord, other.Coord, sizeof(double) * 3);
173 
174  int c = other.numberOfComponents;
175 
176  if (this->numberOfComponents != c)
177  {
178  delete[] this->Scalar;
179  this->Scalar = new double[c];
180  this->numberOfComponents = c;
181  }
182  memcpy(this->Scalar, other.Scalar, sizeof(double) * c);
183  this->Reference = other.Reference;
184  }
185  return *this;
186  }
187  };
188 
189  class EdgeEntry
190  {
191  public:
194 
195  int Reference; // signed char
196  int ToSplit; // signed char
198  vtkIdType CellId; // CellId the edge refer to at a step in tessellation
199 
201  {
202  this->Reference = 0;
203  this->CellId = -1;
204  }
205  ~EdgeEntry() = default;
206 
207  EdgeEntry(const EdgeEntry& copy)
208  {
209  this->E1 = copy.E1;
210  this->E2 = copy.E2;
211 
212  this->Reference = copy.Reference;
213  this->ToSplit = copy.ToSplit;
214  this->PtId = copy.PtId;
215  this->CellId = copy.CellId;
216  }
217 
219  {
220  if (this == &entry)
221  {
222  return *this;
223  }
224  this->E1 = entry.E1;
225  this->E2 = entry.E2;
226  this->Reference = entry.Reference;
227  this->ToSplit = entry.ToSplit;
228  this->PtId = entry.PtId;
229  this->CellId = entry.CellId;
230  return *this;
231  }
232  };
233 
234 protected:
236  ~vtkGenericEdgeTable() override;
237 
241  void InsertEdge(
242  vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, int toSplit, vtkIdType& ptId);
243 
244  // Hash table that contiain entry based on edges:
245  vtkEdgeTableEdge* EdgeTable;
246 
247  // At end of process we should be able to retrieve points coord based on pointid
248  vtkEdgeTablePoints* HashPoints;
249 
250  // Main hash functions
251  // For edge table:
252  vtkIdType HashFunction(vtkIdType e1, vtkIdType e2);
253 
254  // For point table:
255  vtkIdType HashFunction(vtkIdType ptId);
256 
257  // Keep track of the last point id we inserted, increment it each time:
259 
261 
262 private:
263  vtkGenericEdgeTable(const vtkGenericEdgeTable&) = delete;
264  void operator=(const vtkGenericEdgeTable&) = delete;
265 };
266 
267 VTK_ABI_NAMESPACE_END
268 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
keep track of edges (defined by pair of integer id's)
int vtkIdType
Definition: vtkType.h:315
vtkEdgeTablePoints * HashPoints
a simple class to control print indentation
Definition: vtkIndent.h:28
PointEntry & operator=(const PointEntry &other)
PointEntry(const PointEntry &other)
EdgeEntry(const EdgeEntry &copy)
EdgeEntry & operator=(const EdgeEntry &entry)
vtkEdgeTableEdge * EdgeTable
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...