VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkGenericEdgeTable.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00029 #ifndef __vtkGenericEdgeTable_h 00030 #define __vtkGenericEdgeTable_h 00031 00032 #include "vtkCommonDataModelModule.h" // For export macro 00033 #include "vtkObject.h" 00034 00035 class vtkEdgeTableEdge; 00036 class vtkEdgeTablePoints; 00037 00038 class VTKCOMMONDATAMODEL_EXPORT vtkGenericEdgeTable : public vtkObject 00039 { 00040 public: 00042 static vtkGenericEdgeTable *New(); 00043 00045 00046 vtkTypeMacro(vtkGenericEdgeTable,vtkObject); 00047 void PrintSelf(ostream& os, vtkIndent indent); 00049 00051 00052 void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, 00053 int ref, vtkIdType &ptId ); 00055 00057 void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1 ); 00058 00061 int RemoveEdge(vtkIdType e1, vtkIdType e2); 00062 00066 int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType &ptId); 00067 00069 00070 int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2, 00071 vtkIdType cellId); 00073 00075 int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2); 00076 00079 void Initialize(vtkIdType start); 00080 00083 int GetNumberOfComponents(); 00084 00087 void SetNumberOfComponents(int count); 00088 00090 int CheckPoint(vtkIdType ptId); 00091 00094 int CheckPoint(vtkIdType ptId, double point[3], double *scalar); 00095 00097 00098 void InsertPoint(vtkIdType ptId, double point[3]); 00099 // \pre: sizeof(s)==GetNumberOfComponents() 00100 void InsertPointAndScalar(vtkIdType ptId, double pt[3], double *s); 00102 00104 void RemovePoint(vtkIdType ptId); 00105 00107 void IncrementPointReferenceCount(vtkIdType ptId ); 00108 00110 00113 void DumpTable(); 00114 void LoadFactor(); 00116 00117 //BTX 00118 class PointEntry 00119 { 00120 public: 00121 vtkIdType PointId; 00122 double Coord[3]; 00123 double *Scalar; // point data: all point-centered attributes at this point 00124 int numberOfComponents; 00125 00126 int Reference; //signed char 00127 00130 PointEntry(int size); 00131 00132 ~PointEntry() 00133 { 00134 delete[] this->Scalar; 00135 } 00136 00137 PointEntry(const PointEntry &other) 00138 { 00139 this->PointId = other.PointId; 00140 00141 memcpy(this->Coord,other.Coord,sizeof(double)*3); 00142 00143 int c = other.numberOfComponents; 00144 this->numberOfComponents = c; 00145 this->Scalar = new double[c]; 00146 memcpy(this->Scalar, other.Scalar, sizeof(double)*c); 00147 this->Reference = other.Reference; 00148 } 00149 00150 void operator=(const PointEntry &other) 00151 { 00152 if(this != &other) 00153 { 00154 this->PointId = other.PointId; 00155 00156 memcpy(this->Coord, other.Coord, sizeof(double)*3); 00157 00158 int c = other.numberOfComponents; 00159 00160 if(this->numberOfComponents!=c) 00161 { 00162 delete[] this->Scalar; 00163 this->Scalar = new double[c]; 00164 this->numberOfComponents = c; 00165 } 00166 memcpy(this->Scalar, other.Scalar, sizeof(double)*c); 00167 this->Reference = other.Reference; 00168 } 00169 } 00170 }; 00171 00172 class EdgeEntry 00173 { 00174 public: 00175 vtkIdType E1; 00176 vtkIdType E2; 00177 00178 int Reference; //signed char 00179 int ToSplit; //signed char 00180 vtkIdType PtId; 00181 vtkIdType CellId; //CellId the edge refer to at a step in tesselation 00182 00183 EdgeEntry() 00184 { 00185 this->Reference = 0; 00186 this->CellId = -1; 00187 } 00188 ~EdgeEntry() {} 00189 00190 EdgeEntry(const EdgeEntry& copy) 00191 { 00192 this->E1 = copy.E1; 00193 this->E2 = copy.E2; 00194 00195 this->Reference = copy.Reference; 00196 this->ToSplit = copy.ToSplit; 00197 this->PtId = copy.PtId; 00198 this->CellId = copy.CellId; 00199 } 00200 00201 void operator=(const EdgeEntry& entry) 00202 { 00203 if(this == &entry) 00204 { 00205 return; 00206 } 00207 this->E1 = entry.E1; 00208 this->E2 = entry.E2; 00209 this->Reference = entry.Reference; 00210 this->ToSplit = entry.ToSplit; 00211 this->PtId = entry.PtId; 00212 this->CellId = entry.CellId; 00213 } 00214 }; 00215 //ETX 00216 00217 protected: 00218 vtkGenericEdgeTable(); 00219 ~vtkGenericEdgeTable(); 00220 00222 00223 void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, 00224 int ref, int toSplit, vtkIdType &ptId ); 00226 00227 //Hash table that contiain entry based on edges: 00228 vtkEdgeTableEdge *EdgeTable; 00229 00230 //At end of process we should be able to retrieve points coord based on pointid 00231 vtkEdgeTablePoints *HashPoints; 00232 00233 // Main hash functions 00234 //For edge table: 00235 vtkIdType HashFunction(vtkIdType e1, vtkIdType e2); 00236 00237 //For point table: 00238 vtkIdType HashFunction(vtkIdType ptId); 00239 00240 // Keep track of the last point id we inserted, increment it each time: 00241 vtkIdType LastPointId; 00242 00243 vtkIdType NumberOfComponents; 00244 00245 private: 00246 vtkGenericEdgeTable(const vtkGenericEdgeTable&); // Not implemented. 00247 void operator=(const vtkGenericEdgeTable&); // Not implemented. 00248 00249 }; 00250 00251 #endif 00252