Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | 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 =========================================================================*/
00039 #ifndef __vtkGenericEdgeTable_h
00040 #define __vtkGenericEdgeTable_h
00041 
00042 #include "vtkObject.h"
00043 
00044 class vtkEdgeTableEdge;
00045 class vtkEdgeTablePoints;
00046 
00047 class VTK_FILTERING_EXPORT vtkGenericEdgeTable : public vtkObject
00048 {
00049 public:
00051   static vtkGenericEdgeTable *New();
00052   
00054 
00055   vtkTypeRevisionMacro(vtkGenericEdgeTable,vtkObject);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00058 
00060 
00061   void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, 
00062                   int ref, vtkIdType &ptId );
00064 
00066 
00067   void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, 
00068                   int ref, int toSplit, vtkIdType &ptId );
00070 
00072   void InsertEdge(vtkIdType e1, vtkIdType e2, vtkIdType cellId, int ref = 1 );
00073 
00076   int RemoveEdge(vtkIdType e1, vtkIdType e2);
00077 
00080   int CheckEdge(vtkIdType e1, vtkIdType e2, vtkIdType &ptId);
00081   
00083 
00084   int IncrementEdgeReferenceCount(vtkIdType e1, vtkIdType e2, 
00085                                   vtkIdType cellId);
00087   
00089   int CheckEdgeReferenceCount(vtkIdType e1, vtkIdType e2);
00090 
00092   void Initialize(vtkIdType start);
00093   
00095   vtkIdType GetLastPointId();
00096   
00098   void IncrementLastPointId();
00099   
00101   int CheckPoint(vtkIdType ptId);
00102 
00104   int CheckPoint(vtkIdType ptId, double point[3], double scalar[3]);
00105 
00107 
00108   void InsertPoint(vtkIdType ptId, double point[3]);
00109   void InsertPointAndScalar(vtkIdType ptId, double pt[3], double s[3]);
00111 
00113   void RemovePoint(vtkIdType ptId);
00114   
00116   void IncrementPointReferenceCount(vtkIdType ptId );
00117 
00118 //BTX
00119 class PointEntry
00120 {
00121 public:
00122   vtkIdType PointId;
00123   double Coord[3];
00124   double Scalar[3];  //FIXME
00125   int Reference;  //signed char
00126 
00127   PointEntry() 
00128     { 
00129     this->Reference = -10;
00130 
00131     this->Coord[0]  = -100;
00132     this->Coord[1]  = -100;
00133     this->Coord[2]  = -100;
00134     this->Scalar[0]  = -200;
00135     this->Scalar[1]  = -200;
00136     this->Scalar[2]  = -200;
00137     }
00138   ~PointEntry() {}
00139 
00140   PointEntry(const PointEntry& copy)
00141     {
00142     this->PointId  = copy.PointId;
00143 
00144     this->Coord[0]  = copy.Coord[0];
00145     this->Coord[1]  = copy.Coord[1];
00146     this->Coord[2]  = copy.Coord[2];
00147 
00148     this->Scalar[0] = copy.Scalar[0];
00149     this->Scalar[1] = copy.Scalar[1];
00150     this->Scalar[2] = copy.Scalar[2];
00151 
00152     this->Reference = copy.Reference;
00153     }
00154 
00155   void operator=(const PointEntry& entry) 
00156     {
00157     if(this == &entry)
00158       {
00159       return;
00160       }
00161     this->PointId  = entry.PointId;
00162 
00163     this->Coord[0] = entry.Coord[0];
00164     this->Coord[1] = entry.Coord[1];
00165     this->Coord[2] = entry.Coord[2];
00166 
00167     this->Scalar[0] = entry.Scalar[0];
00168     this->Scalar[1] = entry.Scalar[1];
00169     this->Scalar[2] = entry.Scalar[2];
00170 
00171     this->Reference = entry.Reference;
00172     }
00173 };
00174 
00175 class EdgeEntry
00176 {
00177 public:
00178   vtkIdType E1;
00179   vtkIdType E2;
00180 
00181   int Reference;  //signed char
00182   int ToSplit;  //signed char
00183   vtkIdType PtId;
00184   vtkIdType CellId; //CellId the edge refer to at a step in tesselation
00185   
00186   EdgeEntry() 
00187     { 
00188     this->Reference = 0; 
00189     this->CellId = -1;
00190     }
00191   ~EdgeEntry() {}
00192 
00193   EdgeEntry(const EdgeEntry& copy)
00194     {
00195     this->E1 = copy.E1;
00196     this->E2 = copy.E2;
00197 
00198     this->Reference = copy.Reference;
00199     this->ToSplit = copy.ToSplit;
00200     this->PtId = copy.PtId;
00201     this->CellId = copy.CellId;
00202     }
00203   
00204   void operator=(const EdgeEntry& entry) 
00205     {
00206     if(this == &entry)
00207       {
00208       return;
00209       }
00210     this->E1 = entry.E1;
00211     this->E2 = entry.E2;
00212     this->Reference = entry.Reference;
00213     this->ToSplit = entry.ToSplit;
00214     this->PtId = entry.PtId;
00215     this->CellId = entry.CellId;
00216     }
00217 };
00218 //ETX
00219 
00220 protected:
00221   vtkGenericEdgeTable();
00222   ~vtkGenericEdgeTable();
00223 
00225 
00226   void DumpTable();
00227   void LoadFactor();
00229   
00230   //Hash table that contiain entry based on edges:
00231   vtkEdgeTableEdge   *EdgeTable;
00232 
00233   //At end of process we should be able to retrieve points coord based on pointid
00234   vtkEdgeTablePoints *HashPoints;
00235 
00236   // Main hash functions
00237   //For edge table:
00238   vtkIdType HashFunction(vtkIdType e1, vtkIdType e2);
00239 
00240   //For point table:
00241   vtkIdType HashFunction(vtkIdType ptId);
00242 
00243   // Keep track of the last point id we inserted, increment it each time:
00244   vtkIdType LastPointId;  //static
00245 //  vtkGetMacro(LastPointId, vtkIdType);
00246   //Use only once !
00247 //  vtkSetMacro(LastPointId, vtkIdType);
00248 
00249 private:
00250   vtkGenericEdgeTable(const vtkGenericEdgeTable&);  // Not implemented.
00251   void operator=(const vtkGenericEdgeTable&);  // Not implemented.
00252 
00253 };
00254 
00255 #endif
00256