VTK  9.3.20240328
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:
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 
59 
65  int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType& ptId);
66 
71 
76 
81  void Initialize(vtkIdType start);
82 
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 
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 
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:
237 
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:
253 
254  // For point table:
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
EdgeEntry(const EdgeEntry &copy)
EdgeEntry & operator=(const EdgeEntry &entry)
PointEntry(int size)
Constructor with a scalar field of ‘size’ doubles.
PointEntry(const PointEntry &other)
PointEntry & operator=(const PointEntry &other)
keep track of edges (defined by pair of integer id's)
int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2)
Return the edge reference count.
vtkEdgeTablePoints * HashPoints
void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, vtkIdType &ptId)
Split the edge with the indicated point id.
void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, int toSplit, vtkIdType &ptId)
Split the edge with the indicated point id.
void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref=1)
Insert an edge but do not split it.
int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType &ptId)
Method to determine whether an edge is in the table (0 or 1), or not (-1).
void InsertPointAndScalar(vtkIdType ptId, double pt[3], double *s)
Insert point associated with an edge.
vtkEdgeTableEdge * EdgeTable
void RemovePoint(vtkIdType ptId)
Remove a point from the point table.
int CheckPoint(vtkIdType ptId)
Check if a point is already in the point table.
~vtkGenericEdgeTable() override
int CheckPoint(vtkIdType ptId, double point[3], double *scalar)
Check for the existence of a point and return its coordinate value.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard VTK type and print macros.
static vtkGenericEdgeTable * New()
Instantiate an empty edge table.
void IncrementPointReferenceCount(vtkIdType ptId)
Increment the reference count for the indicated point.
vtkIdType HashFunction(vtkIdType e1, vtkIdType e2)
int GetNumberOfComponents()
Return the total number of components for the point-centered attributes.
void Initialize(vtkIdType start)
To specify the starting point id.
void LoadFactor()
For debugging purposes.
int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2, vtkIdType cellId)
Method that increments the referencecount and returns it.
int RemoveEdge(vtkIdType e1, vtkIdType e2)
Method to remove an edge from the table.
void DumpTable()
For debugging purposes.
vtkIdType HashFunction(vtkIdType ptId)
void SetNumberOfComponents(int count)
Set the total number of components for the point-centered attributes.
void InsertPoint(vtkIdType ptId, double point[3])
Insert point associated with an edge.
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:161
@ point
Definition: vtkX3D.h:236
@ size
Definition: vtkX3D.h:253
int vtkIdType
Definition: vtkType.h:315