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 =========================================================================*/
29 #ifndef vtkGenericEdgeTable_h
30 #define vtkGenericEdgeTable_h
31 
32 #include "vtkCommonDataModelModule.h" // For export macro
33 #include "vtkObject.h"
34 
35 class vtkEdgeTableEdge;
36 class vtkEdgeTablePoints;
37 
39 {
40 public:
42  static vtkGenericEdgeTable *New();
43 
45 
47  void PrintSelf(ostream& os, vtkIndent indent);
49 
51 
52  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId,
53  int ref, vtkIdType &ptId );
55 
57  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1 );
58 
61  int RemoveEdge(vtkIdType e1, vtkIdType e2);
62 
66  int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType &ptId);
67 
69 
70  int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2,
71  vtkIdType cellId);
73 
75  int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2);
76 
79  void Initialize(vtkIdType start);
80 
83  int GetNumberOfComponents();
84 
87  void SetNumberOfComponents(int count);
88 
90  int CheckPoint(vtkIdType ptId);
91 
94  int CheckPoint(vtkIdType ptId, double point[3], double *scalar);
95 
97 
98  void InsertPoint(vtkIdType ptId, double point[3]);
99  // \pre: sizeof(s)==GetNumberOfComponents()
100  void InsertPointAndScalar(vtkIdType ptId, double pt[3], double *s);
102 
104  void RemovePoint(vtkIdType ptId);
105 
107  void IncrementPointReferenceCount(vtkIdType ptId );
108 
110 
113  void DumpTable();
114  void LoadFactor();
116 
117 //BTX
119 {
120 public:
122  double Coord[3];
123  double *Scalar; // point data: all point-centered attributes at this point
125 
126  int Reference; //signed char
127 
130  PointEntry(int size);
131 
133  {
134  delete[] this->Scalar;
135  }
136 
137  PointEntry(const PointEntry &other)
138  {
139  this->PointId = other.PointId;
140 
141  memcpy(this->Coord,other.Coord,sizeof(double)*3);
142 
143  int c = other.numberOfComponents;
144  this->numberOfComponents = c;
145  this->Scalar = new double[c];
146  memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
147  this->Reference = other.Reference;
148  }
149 
150  void operator=(const PointEntry &other)
151  {
152  if(this != &other)
153  {
154  this->PointId = other.PointId;
155 
156  memcpy(this->Coord, other.Coord, sizeof(double)*3);
157 
158  int c = other.numberOfComponents;
159 
160  if(this->numberOfComponents!=c)
161  {
162  delete[] this->Scalar;
163  this->Scalar = new double[c];
164  this->numberOfComponents = c;
165  }
166  memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
167  this->Reference = other.Reference;
168  }
169  }
170 };
171 
173 {
174 public:
177 
178  int Reference; //signed char
179  int ToSplit; //signed char
181  vtkIdType CellId; //CellId the edge refer to at a step in tesselation
182 
184  {
185  this->Reference = 0;
186  this->CellId = -1;
187  }
189 
190  EdgeEntry(const EdgeEntry& copy)
191  {
192  this->E1 = copy.E1;
193  this->E2 = copy.E2;
194 
195  this->Reference = copy.Reference;
196  this->ToSplit = copy.ToSplit;
197  this->PtId = copy.PtId;
198  this->CellId = copy.CellId;
199  }
200 
201  void operator=(const EdgeEntry& entry)
202  {
203  if(this == &entry)
204  {
205  return;
206  }
207  this->E1 = entry.E1;
208  this->E2 = entry.E2;
209  this->Reference = entry.Reference;
210  this->ToSplit = entry.ToSplit;
211  this->PtId = entry.PtId;
212  this->CellId = entry.CellId;
213  }
214 };
215 //ETX
216 
217 protected:
220 
222 
223  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId,
224  int ref, int toSplit, vtkIdType &ptId );
226 
227  //Hash table that contiain entry based on edges:
228  vtkEdgeTableEdge *EdgeTable;
229 
230  //At end of process we should be able to retrieve points coord based on pointid
231  vtkEdgeTablePoints *HashPoints;
232 
233  // Main hash functions
234  //For edge table:
235  vtkIdType HashFunction(vtkIdType e1, vtkIdType e2);
236 
237  //For point table:
238  vtkIdType HashFunction(vtkIdType ptId);
239 
240  // Keep track of the last point id we inserted, increment it each time:
242 
244 
245 private:
246  vtkGenericEdgeTable(const vtkGenericEdgeTable&); // Not implemented.
247  void operator=(const vtkGenericEdgeTable&); // Not implemented.
248 
249 };
250 
251 #endif
252 
abstract base class for most VTK objects
Definition: vtkObject.h:61
void operator=(const PointEntry &other)
keep track of edges (defined by pair of integer id's)
void operator=(const EdgeEntry &entry)
int vtkIdType
Definition: vtkType.h:275
vtkEdgeTablePoints * HashPoints
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
PointEntry(const PointEntry &other)
EdgeEntry(const EdgeEntry &copy)
vtkEdgeTableEdge * EdgeTable
static vtkObject * New()
#define VTKCOMMONDATAMODEL_EXPORT