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

vtkCellTypes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkCellTypes.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00042 #ifndef __vtkCellTypes_h
00043 #define __vtkCellTypes_h
00044 
00045 #include "vtkObject.h"
00046 
00047 #include "vtkIntArray.h" // Needed for inline methods
00048 #include "vtkUnsignedCharArray.h" // Needed for inline methods
00049 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
00050 
00051 class VTK_COMMON_EXPORT vtkCellTypes : public vtkObject 
00052 {
00053 public:
00054   static vtkCellTypes *New();
00055   vtkTypeRevisionMacro(vtkCellTypes,vtkObject);
00056 
00058   int Allocate(int sz=512, int ext=1000);
00059 
00061   void InsertCell(int id, unsigned char type, int loc);
00062   
00064   int InsertNextCell(unsigned char type, int loc);
00065 
00067   void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
00068 
00070   int GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
00071 
00073   void DeleteCell(int cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
00074 
00076   int GetNumberOfTypes() { return (this->MaxId + 1);};
00077 
00079   int IsType(unsigned char type);
00080 
00083   int InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
00084   
00086   unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
00087 
00089   void Squeeze();
00090 
00092   void Reset();
00093 
00100   unsigned long GetActualMemorySize();
00101 
00104   void DeepCopy(vtkCellTypes *src);
00105 
00106 protected:
00107   vtkCellTypes();
00108   ~vtkCellTypes();
00109 
00110   vtkUnsignedCharArray *TypeArray; // pointer to types array
00111   vtkIntArray *LocationArray;   // pointer to array of offsets
00112   int Size;            // allocated size of data
00113   int MaxId;           // maximum index inserted thus far
00114   int Extend;          // grow array by this point
00115 private:
00116   vtkCellTypes(const vtkCellTypes&);  // Not implemented.
00117   void operator=(const vtkCellTypes&);    // Not implemented.
00118 };
00119 
00120 
00121 
00122 inline int vtkCellTypes::IsType(unsigned char type)
00123 {
00124   int numTypes=this->GetNumberOfTypes();
00125 
00126   for (int i=0; i<numTypes; i++)
00127     {
00128     if ( type == this->GetCellType(i))
00129       {
00130       return 1;
00131       }
00132     }
00133   return 0;
00134 }
00135 
00136 
00137 #endif