VTK
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
36class vtkEdgeTableEdge;
37class vtkEdgeTablePoints;
38
39class VTKCOMMONDATAMODEL_EXPORT vtkGenericEdgeTable : public vtkObject
40{
41public:
46
48
52 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
54
59 int ref, vtkIdType &ptId );
60
64 void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1 );
65
71
78
83 vtkIdType cellId);
84
89
94 void Initialize(vtkIdType start);
95
101
106 void SetNumberOfComponents(int count);
107
112
117 int CheckPoint(vtkIdType ptId, double point[3], double *scalar);
118
120
123 void InsertPoint(vtkIdType ptId, double point[3]);
124 // \pre: sizeof(s)==GetNumberOfComponents()
125 void InsertPointAndScalar(vtkIdType ptId, double pt[3], double *s);
127
132
137
139
144 void DumpTable();
147
149{
150public:
152 double Coord[3];
153 double *Scalar; // point data: all point-centered attributes at this point
155
156 int Reference; //signed char
157
163
165 {
166 delete[] this->Scalar;
167 }
168
169 PointEntry(const PointEntry &other)
170 {
171 this->PointId = other.PointId;
172
173 memcpy(this->Coord,other.Coord,sizeof(double)*3);
174
175 int c = other.numberOfComponents;
176 this->numberOfComponents = c;
177 this->Scalar = new double[c];
178 memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
179 this->Reference = other.Reference;
180 }
181
183 {
184 if(this != &other)
185 {
186 this->PointId = other.PointId;
187
188 memcpy(this->Coord, other.Coord, sizeof(double)*3);
189
190 int c = other.numberOfComponents;
191
192 if(this->numberOfComponents!=c)
193 {
194 delete[] this->Scalar;
195 this->Scalar = new double[c];
196 this->numberOfComponents = c;
197 }
198 memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
199 this->Reference = other.Reference;
200 }
201 return *this;
202 }
203};
204
206{
207public:
210
211 int Reference; //signed char
212 int ToSplit; //signed char
214 vtkIdType CellId; //CellId the edge refer to at a step in tesselation
215
217 {
218 this->Reference = 0;
219 this->CellId = -1;
220 }
222
223 EdgeEntry(const EdgeEntry& copy)
224 {
225 this->E1 = copy.E1;
226 this->E2 = copy.E2;
227
228 this->Reference = copy.Reference;
229 this->ToSplit = copy.ToSplit;
230 this->PtId = copy.PtId;
231 this->CellId = copy.CellId;
232 }
233
235 {
236 if(this == &entry)
237 {
238 return *this;
239 }
240 this->E1 = entry.E1;
241 this->E2 = entry.E2;
242 this->Reference = entry.Reference;
243 this->ToSplit = entry.ToSplit;
244 this->PtId = entry.PtId;
245 this->CellId = entry.CellId;
246 return *this;
247 }
248};
249
250protected:
252 ~vtkGenericEdgeTable() VTK_OVERRIDE;
253
257 void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId,
258 int ref, int toSplit, vtkIdType &ptId );
259
260 //Hash table that contiain entry based on edges:
261 vtkEdgeTableEdge *EdgeTable;
262
263 //At end of process we should be able to retrieve points coord based on pointid
264 vtkEdgeTablePoints *HashPoints;
265
266 // Main hash functions
267 //For edge table:
268 vtkIdType HashFunction(vtkIdType e1, vtkIdType e2);
269
270 //For point table:
271 vtkIdType HashFunction(vtkIdType ptId);
272
273 // Keep track of the last point id we inserted, increment it each time:
274 vtkIdType LastPointId;
275
276 vtkIdType NumberOfComponents;
277
278private:
279 vtkGenericEdgeTable(const vtkGenericEdgeTable&) VTK_DELETE_FUNCTION;
280 void operator=(const vtkGenericEdgeTable&) VTK_DELETE_FUNCTION;
281
282};
283
284#endif
285
EdgeEntry(const EdgeEntry &copy)
EdgeEntry & operator=(const EdgeEntry &entry)
PointEntry & operator=(const PointEntry &other)
PointEntry(int size)
Constructor with a scalar field of ‘size’ doubles.
PointEntry(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.
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=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)
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
Methods invoked by print to print information about the object including superclasses.
void IncrementPointReferenceCount(vtkIdType ptId)
Increment the reference count for the indicated point.
int GetNumberOfComponents()
Return the total number of components for the point-centered attributes.
void Initialize(vtkIdType start)
To specify the starting point id.
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.
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.
static vtkGenericEdgeTable * New()
Instantiate an empty edge table.
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
@ point
Definition: vtkX3D.h:236
@ size
Definition: vtkX3D.h:253
int vtkIdType
Definition: vtkType.h:287