Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkGenericEdgeTable.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkGenericEdgeTable.h,v $
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 "vtkObject.h"
00033 
00034 class vtkEdgeTableEdge;
00035 class vtkEdgeTablePoints;
00036 
00037 class VTK_FILTERING_EXPORT vtkGenericEdgeTable : public vtkObject
00038 {
00039 public:
00041   static vtkGenericEdgeTable *New();
00042   
00044 
00045   vtkTypeRevisionMacro(vtkGenericEdgeTable,vtkObject);
00046   void PrintSelf(ostream& os, vtkIndent indent);
00048 
00050 
00051   void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, 
00052                   int ref, vtkIdType &ptId );
00054 
00056   void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1 );
00057 
00060   int RemoveEdge(vtkIdType e1, vtkIdType e2);
00061 
00065   int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType &ptId);
00066   
00068 
00069   int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2, 
00070                                   vtkIdType cellId);
00072   
00074   int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2);
00075 
00078   void Initialize(vtkIdType start);
00079   
00082   int GetNumberOfComponents();
00083   
00086   void SetNumberOfComponents(int count);
00087   
00089   int CheckPoint(vtkIdType ptId);
00090 
00093   int CheckPoint(vtkIdType ptId, double point[3], double *scalar);
00094 
00096 
00097   void InsertPoint(vtkIdType ptId, double point[3]);
00098   // \pre: sizeof(s)==GetNumberOfComponents()
00099   void InsertPointAndScalar(vtkIdType ptId, double pt[3], double *s);
00101 
00103   void RemovePoint(vtkIdType ptId);
00104   
00106   void IncrementPointReferenceCount(vtkIdType ptId );
00107 
00109 
00112   void DumpTable();
00113   void LoadFactor();
00115 
00116 //BTX
00117 class PointEntry
00118 {
00119 public:
00120   vtkIdType PointId;
00121   double Coord[3];
00122   double *Scalar;  // point data: all point-centered attributes at this point
00123   int numberOfComponents;
00124   
00125   int Reference;  //signed char
00126   
00129   PointEntry(int size);
00130   
00131   ~PointEntry()
00132     {
00133       delete[] this->Scalar;
00134     }
00135 
00136   PointEntry(const PointEntry &other)
00137     {
00138     this->PointId  = other.PointId;
00139 
00140     memcpy(this->Coord,other.Coord,sizeof(double)*3);
00141 
00142     int c = other.numberOfComponents;
00143     this->numberOfComponents = c;
00144     this->Scalar = new double[c];
00145     memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
00146     this->Reference = other.Reference;
00147     }
00148 
00149   void operator=(const PointEntry &other) 
00150     {
00151     if(this != &other)
00152       {
00153       this->PointId  = other.PointId;
00154       
00155       memcpy(this->Coord, other.Coord, sizeof(double)*3);
00156       
00157       int c = other.numberOfComponents;
00158       
00159       if(this->numberOfComponents!=c)
00160         {
00161         delete[] this->Scalar;
00162         this->Scalar = new double[c];
00163         this->numberOfComponents = c;
00164         }
00165       memcpy(this->Scalar, other.Scalar, sizeof(double)*c);
00166       this->Reference = other.Reference;
00167       }
00168     }
00169 };
00170 
00171 class EdgeEntry
00172 {
00173 public:
00174   vtkIdType E1;
00175   vtkIdType E2;
00176 
00177   int Reference;  //signed char
00178   int ToSplit;  //signed char
00179   vtkIdType PtId;
00180   vtkIdType CellId; //CellId the edge refer to at a step in tesselation
00181   
00182   EdgeEntry() 
00183     { 
00184     this->Reference = 0; 
00185     this->CellId = -1;
00186     }
00187   ~EdgeEntry() {}
00188 
00189   EdgeEntry(const EdgeEntry& copy)
00190     {
00191     this->E1 = copy.E1;
00192     this->E2 = copy.E2;
00193 
00194     this->Reference = copy.Reference;
00195     this->ToSplit = copy.ToSplit;
00196     this->PtId = copy.PtId;
00197     this->CellId = copy.CellId;
00198     }
00199   
00200   void operator=(const EdgeEntry& entry) 
00201     {
00202     if(this == &entry)
00203       {
00204       return;
00205       }
00206     this->E1 = entry.E1;
00207     this->E2 = entry.E2;
00208     this->Reference = entry.Reference;
00209     this->ToSplit = entry.ToSplit;
00210     this->PtId = entry.PtId;
00211     this->CellId = entry.CellId;
00212     }
00213 };
00214 //ETX
00215 
00216 protected:
00217   vtkGenericEdgeTable();
00218   ~vtkGenericEdgeTable();
00219 
00221 
00222   void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, 
00223                   int ref, int toSplit, vtkIdType &ptId );
00225   
00226   //Hash table that contiain entry based on edges:
00227   vtkEdgeTableEdge   *EdgeTable;
00228 
00229   //At end of process we should be able to retrieve points coord based on pointid
00230   vtkEdgeTablePoints *HashPoints;
00231 
00232   // Main hash functions
00233   //For edge table:
00234   vtkIdType HashFunction(vtkIdType e1, vtkIdType e2);
00235 
00236   //For point table:
00237   vtkIdType HashFunction(vtkIdType ptId);
00238 
00239   // Keep track of the last point id we inserted, increment it each time:
00240   vtkIdType LastPointId;
00241 
00242   vtkIdType NumberOfComponents;
00243   
00244 private:
00245   vtkGenericEdgeTable(const vtkGenericEdgeTable&);  // Not implemented.
00246   void operator=(const vtkGenericEdgeTable&);  // Not implemented.
00247 
00248 };
00249 
00250 #endif
00251 

Generated on Mon Jan 21 23:07:19 2008 for VTK by  doxygen 1.4.3-20050530