VTK  9.0.1
vtkGenericEdgeTable.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGenericEdgeTable.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 =========================================================================*/
30 #ifndef vtkGenericEdgeTable_h
31 #define vtkGenericEdgeTable_h
32 
33 #include "vtkCommonDataModelModule.h" // For export macro
34 #include "vtkObject.h"
35 
36 class vtkEdgeTableEdge;
37 class vtkEdgeTablePoints;
38 
39 class VTKCOMMONDATAMODEL_EXPORT vtkGenericEdgeTable : public vtkObject
40 {
41 public:
46 
48 
52  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, vtkIdType& ptId);
59 
63  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1);
64 
70 
76  int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType& ptId);
77 
82 
87 
92  void Initialize(vtkIdType start);
93 
99 
104  void SetNumberOfComponents(int count);
105 
110 
115  int CheckPoint(vtkIdType ptId, double point[3], double* scalar);
116 
118 
121  void InsertPoint(vtkIdType ptId, double point[3]);
122  // \pre: sizeof(s)==GetNumberOfComponents()
123  void InsertPointAndScalar(vtkIdType ptId, double pt[3], double* s);
125 
129  void RemovePoint(vtkIdType ptId);
130 
135 
137 
142  void DumpTable();
143  void LoadFactor();
145 
147  {
148  public:
150  double Coord[3];
151  double* Scalar; // point data: all point-centered attributes at this point
153 
154  int Reference; // signed char
155 
161 
162  ~PointEntry() { delete[] this->Scalar; }
163 
164  PointEntry(const PointEntry& other)
165  {
166  this->PointId = other.PointId;
167 
168  memcpy(this->Coord, other.Coord, sizeof(double) * 3);
169 
170  int c = other.numberOfComponents;
171  this->numberOfComponents = c;
172  this->Scalar = new double[c];
173  memcpy(this->Scalar, other.Scalar, sizeof(double) * c);
174  this->Reference = other.Reference;
175  }
176 
178  {
179  if (this != &other)
180  {
181  this->PointId = other.PointId;
182 
183  memcpy(this->Coord, other.Coord, sizeof(double) * 3);
184 
185  int c = other.numberOfComponents;
186 
187  if (this->numberOfComponents != c)
188  {
189  delete[] this->Scalar;
190  this->Scalar = new double[c];
191  this->numberOfComponents = c;
192  }
193  memcpy(this->Scalar, other.Scalar, sizeof(double) * c);
194  this->Reference = other.Reference;
195  }
196  return *this;
197  }
198  };
199 
200  class EdgeEntry
201  {
202  public:
205 
206  int Reference; // signed char
207  int ToSplit; // signed char
209  vtkIdType CellId; // CellId the edge refer to at a step in tessellation
210 
212  {
213  this->Reference = 0;
214  this->CellId = -1;
215  }
217 
218  EdgeEntry(const EdgeEntry& copy)
219  {
220  this->E1 = copy.E1;
221  this->E2 = copy.E2;
222 
223  this->Reference = copy.Reference;
224  this->ToSplit = copy.ToSplit;
225  this->PtId = copy.PtId;
226  this->CellId = copy.CellId;
227  }
228 
230  {
231  if (this == &entry)
232  {
233  return *this;
234  }
235  this->E1 = entry.E1;
236  this->E2 = entry.E2;
237  this->Reference = entry.Reference;
238  this->ToSplit = entry.ToSplit;
239  this->PtId = entry.PtId;
240  this->CellId = entry.CellId;
241  return *this;
242  }
243  };
244 
245 protected:
248 
253  vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, int toSplit, vtkIdType& ptId);
254 
255  // Hash table that contiain entry based on edges:
256  vtkEdgeTableEdge* EdgeTable;
257 
258  // At end of process we should be able to retrieve points coord based on pointid
259  vtkEdgeTablePoints* HashPoints;
260 
261  // Main hash functions
262  // For edge table:
264 
265  // For point table:
267 
268  // Keep track of the last point id we inserted, increment it each time:
270 
272 
273 private:
274  vtkGenericEdgeTable(const vtkGenericEdgeTable&) = delete;
275  void operator=(const vtkGenericEdgeTable&) = delete;
276 };
277 
278 #endif
vtkGenericEdgeTable::SetNumberOfComponents
void SetNumberOfComponents(int count)
Set the total number of components for the point-centered attributes.
vtkGenericEdgeTable::EdgeEntry::CellId
vtkIdType CellId
Definition: vtkGenericEdgeTable.h:209
vtkGenericEdgeTable::PointEntry::operator=
PointEntry & operator=(const PointEntry &other)
Definition: vtkGenericEdgeTable.h:177
vtkGenericEdgeTable::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGenericEdgeTable::PointEntry::Coord
double Coord[3]
Definition: vtkGenericEdgeTable.h:150
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkGenericEdgeTable::EdgeEntry::E2
vtkIdType E2
Definition: vtkGenericEdgeTable.h:204
vtkGenericEdgeTable::HashFunction
vtkIdType HashFunction(vtkIdType e1, vtkIdType e2)
vtkGenericEdgeTable::InsertEdge
void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref=1)
Insert an edge but do not split it.
vtkGenericEdgeTable::vtkGenericEdgeTable
vtkGenericEdgeTable()
vtkGenericEdgeTable::InsertPoint
void InsertPoint(vtkIdType ptId, double point[3])
Insert point associated with an edge.
vtkGenericEdgeTable::PointEntry::PointEntry
PointEntry(int size)
Constructor with a scalar field of ‘size’ doubles.
vtkGenericEdgeTable::LoadFactor
void LoadFactor()
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
vtkGenericEdgeTable::CheckPoint
int CheckPoint(vtkIdType ptId)
Check if a point is already in the point table.
vtkGenericEdgeTable::EdgeEntry::ToSplit
int ToSplit
Definition: vtkGenericEdgeTable.h:207
vtkGenericEdgeTable::CheckPoint
int CheckPoint(vtkIdType ptId, double point[3], double *scalar)
Check for the existence of a point and return its coordinate value.
vtkGenericEdgeTable::PointEntry::~PointEntry
~PointEntry()
Definition: vtkGenericEdgeTable.h:162
vtkGenericEdgeTable::EdgeEntry::Reference
int Reference
Definition: vtkGenericEdgeTable.h:206
vtkGenericEdgeTable::PointEntry::numberOfComponents
int numberOfComponents
Definition: vtkGenericEdgeTable.h:152
vtkGenericEdgeTable::HashFunction
vtkIdType HashFunction(vtkIdType ptId)
vtkGenericEdgeTable::PointEntry::PointId
vtkIdType PointId
Definition: vtkGenericEdgeTable.h:149
vtkGenericEdgeTable::EdgeEntry
Definition: vtkGenericEdgeTable.h:201
vtkGenericEdgeTable::InsertEdge
void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, int toSplit, vtkIdType &ptId)
Split the edge with the indicated point id.
vtkX3D::point
@ point
Definition: vtkX3D.h:242
vtkGenericEdgeTable::IncrementPointReferenceCount
void IncrementPointReferenceCount(vtkIdType ptId)
Increment the reference count for the indicated point.
vtkGenericEdgeTable::PointEntry::Scalar
double * Scalar
Definition: vtkGenericEdgeTable.h:151
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkGenericEdgeTable::EdgeEntry::operator=
EdgeEntry & operator=(const EdgeEntry &entry)
Definition: vtkGenericEdgeTable.h:229
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkGenericEdgeTable::Initialize
void Initialize(vtkIdType start)
To specify the starting point id.
vtkGenericEdgeTable::RemovePoint
void RemovePoint(vtkIdType ptId)
Remove a point from the point table.
vtkGenericEdgeTable::CheckEdgeReferenceCount
int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2)
Return the edge reference count.
vtkGenericEdgeTable::LastPointId
vtkIdType LastPointId
Definition: vtkGenericEdgeTable.h:269
vtkObject.h
vtkGenericEdgeTable::HashPoints
vtkEdgeTablePoints * HashPoints
Definition: vtkGenericEdgeTable.h:259
vtkGenericEdgeTable
keep track of edges (defined by pair of integer id's)
Definition: vtkGenericEdgeTable.h:40
vtkGenericEdgeTable::EdgeTable
vtkEdgeTableEdge * EdgeTable
Definition: vtkGenericEdgeTable.h:256
vtkGenericEdgeTable::EdgeEntry::~EdgeEntry
~EdgeEntry()
Definition: vtkGenericEdgeTable.h:216
vtkGenericEdgeTable::InsertPointAndScalar
void InsertPointAndScalar(vtkIdType ptId, double pt[3], double *s)
vtkGenericEdgeTable::PointEntry
Definition: vtkGenericEdgeTable.h:147
vtkGenericEdgeTable::IncrementEdgeReferenceCount
int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2, vtkIdType cellId)
Method that increments the referencecount and returns it.
vtkGenericEdgeTable::New
static vtkGenericEdgeTable * New()
Instantiate an empty edge table.
vtkGenericEdgeTable::InsertEdge
void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref, vtkIdType &ptId)
Split the edge with the indicated point id.
vtkGenericEdgeTable::EdgeEntry::EdgeEntry
EdgeEntry(const EdgeEntry &copy)
Definition: vtkGenericEdgeTable.h:218
vtkGenericEdgeTable::EdgeEntry::E1
vtkIdType E1
Definition: vtkGenericEdgeTable.h:203
vtkGenericEdgeTable::RemoveEdge
int RemoveEdge(vtkIdType e1, vtkIdType e2)
Method to remove an edge from the table.
vtkGenericEdgeTable::DumpTable
void DumpTable()
For debugging purposes.
vtkGenericEdgeTable::~vtkGenericEdgeTable
~vtkGenericEdgeTable() override
vtkGenericEdgeTable::PointEntry::Reference
int Reference
Definition: vtkGenericEdgeTable.h:154
vtkGenericEdgeTable::GetNumberOfComponents
int GetNumberOfComponents()
Return the total number of components for the point-centered attributes.
vtkGenericEdgeTable::EdgeEntry::PtId
vtkIdType PtId
Definition: vtkGenericEdgeTable.h:208
vtkGenericEdgeTable::CheckEdge
int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType &ptId)
Method to determine whether an edge is in the table (0 or 1), or not (-1).
vtkGenericEdgeTable::NumberOfComponents
vtkIdType NumberOfComponents
Definition: vtkGenericEdgeTable.h:271
vtkGenericEdgeTable::PointEntry::PointEntry
PointEntry(const PointEntry &other)
Definition: vtkGenericEdgeTable.h:164
vtkGenericEdgeTable::EdgeEntry::EdgeEntry
EdgeEntry()
Definition: vtkGenericEdgeTable.h:211