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 "vtkObject.h"
33 
34 class vtkEdgeTableEdge;
35 class vtkEdgeTablePoints;
36 
38 {
39 public:
41  static vtkGenericEdgeTable *New();
42 
44 
46  void PrintSelf(ostream& os, vtkIndent indent);
48 
50 
51  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId,
52  int ref, vtkIdType &ptId );
54 
56  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1 );
57 
60  int RemoveEdge(vtkIdType e1, vtkIdType e2);
61 
65  int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType &ptId);
66 
68 
69  int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2,
70  vtkIdType cellId);
72 
74  int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2);
75 
78  void Initialize(vtkIdType start);
79 
82  int GetNumberOfComponents();
83 
86  void SetNumberOfComponents(int count);
87 
89  int CheckPoint(vtkIdType ptId);
90 
93  int CheckPoint(vtkIdType ptId, double point[3], double *scalar);
94 
96 
97  void InsertPoint(vtkIdType ptId, double point[3]);
98  // \pre: sizeof(s)==GetNumberOfComponents()
99  void InsertPointAndScalar(vtkIdType ptId, double pt[3], double *s);
101 
103  void RemovePoint(vtkIdType ptId);
104 
106  void IncrementPointReferenceCount(vtkIdType ptId );
107 
109 
112  void DumpTable();
113  void LoadFactor();
115 
116 //BTX
118 {
119 public:
121  double Coord[3];
122  double *Scalar; // point data: all point-centered attributes at this point
124 
125  int Reference; //signed char
126 
129  PointEntry(int size);
130 
132  {
133  delete[] this->Scalar;
134  }
135 
136  PointEntry(const PointEntry &other)
137  {
138  this->PointId = other.PointId;
139 
140  memcpy(this->Coord,other.Coord,sizeof(double)*3);
141 
142  int c = other.numberOfComponents;
143  this->numberOfComponents = c;
144  this->Scalar = new double[c];
145  memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
146  this->Reference = other.Reference;
147  }
148 
149  void operator=(const PointEntry &other)
150  {
151  if(this != &other)
152  {
153  this->PointId = other.PointId;
154 
155  memcpy(this->Coord, other.Coord, sizeof(double)*3);
156 
157  int c = other.numberOfComponents;
158 
159  if(this->numberOfComponents!=c)
160  {
161  delete[] this->Scalar;
162  this->Scalar = new double[c];
163  this->numberOfComponents = c;
164  }
165  memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
166  this->Reference = other.Reference;
167  }
168  }
169 };
170 
172 {
173 public:
176 
177  int Reference; //signed char
178  int ToSplit; //signed char
180  vtkIdType CellId; //CellId the edge refer to at a step in tesselation
181 
183  {
184  this->Reference = 0;
185  this->CellId = -1;
186  }
188 
189  EdgeEntry(const EdgeEntry& copy)
190  {
191  this->E1 = copy.E1;
192  this->E2 = copy.E2;
193 
194  this->Reference = copy.Reference;
195  this->ToSplit = copy.ToSplit;
196  this->PtId = copy.PtId;
197  this->CellId = copy.CellId;
198  }
199 
200  void operator=(const EdgeEntry& entry)
201  {
202  if(this == &entry)
203  {
204  return;
205  }
206  this->E1 = entry.E1;
207  this->E2 = entry.E2;
208  this->Reference = entry.Reference;
209  this->ToSplit = entry.ToSplit;
210  this->PtId = entry.PtId;
211  this->CellId = entry.CellId;
212  }
213 };
214 //ETX
215 
216 protected:
219 
221 
222  void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId,
223  int ref, int toSplit, vtkIdType &ptId );
225 
226  //Hash table that contiain entry based on edges:
227  vtkEdgeTableEdge *EdgeTable;
228 
229  //At end of process we should be able to retrieve points coord based on pointid
230  vtkEdgeTablePoints *HashPoints;
231 
232  // Main hash functions
233  //For edge table:
234  vtkIdType HashFunction(vtkIdType e1, vtkIdType e2);
235 
236  //For point table:
237  vtkIdType HashFunction(vtkIdType ptId);
238 
239  // Keep track of the last point id we inserted, increment it each time:
241 
243 
244 private:
245  vtkGenericEdgeTable(const vtkGenericEdgeTable&); // Not implemented.
246  void operator=(const vtkGenericEdgeTable&); // Not implemented.
247 
248 };
249 
250 #endif
251 
abstract base class for most VTK objects
Definition: vtkObject.h:60
void operator=(const PointEntry &other)
#define VTK_FILTERING_EXPORT
keep track of edges (defined by pair of integer id's)
void operator=(const EdgeEntry &entry)
int vtkIdType
Definition: vtkType.h:255
vtkEdgeTablePoints * HashPoints
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
PointEntry(const PointEntry &other)
EdgeEntry(const EdgeEntry &copy)
vtkEdgeTableEdge * EdgeTable
static vtkObject * New()