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

Common/vtkCellTypes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkCellTypes.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 =========================================================================*/
00038 #ifndef __vtkCellTypes_h
00039 #define __vtkCellTypes_h
00040 
00041 #include "vtkObject.h"
00042 
00043 #include "vtkIntArray.h" // Needed for inline methods
00044 #include "vtkUnsignedCharArray.h" // Needed for inline methods
00045 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
00046 
00047 class VTK_COMMON_EXPORT vtkCellTypes : public vtkObject 
00048 {
00049 public:
00050   static vtkCellTypes *New();
00051   vtkTypeRevisionMacro(vtkCellTypes,vtkObject);
00052 
00054   int Allocate(int sz=512, int ext=1000);
00055 
00057   void InsertCell(int id, unsigned char type, int loc);
00058   
00060   int InsertNextCell(unsigned char type, int loc);
00061 
00063   void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
00064 
00066   int GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
00067 
00069   void DeleteCell(int cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
00070 
00072   int GetNumberOfTypes() { return (this->MaxId + 1);};
00073 
00075   int IsType(unsigned char type);
00076 
00079   int InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
00080   
00082   unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
00083 
00085   void Squeeze();
00086 
00088   void Reset();
00089 
00096   unsigned long GetActualMemorySize();
00097 
00100   void DeepCopy(vtkCellTypes *src);
00101 
00102 protected:
00103   vtkCellTypes();
00104   ~vtkCellTypes();
00105 
00106   vtkUnsignedCharArray *TypeArray; // pointer to types array
00107   vtkIntArray *LocationArray;   // pointer to array of offsets
00108   int Size;            // allocated size of data
00109   int MaxId;           // maximum index inserted thus far
00110   int Extend;          // grow array by this point
00111 private:
00112   vtkCellTypes(const vtkCellTypes&);  // Not implemented.
00113   void operator=(const vtkCellTypes&);    // Not implemented.
00114 };
00115 
00116 
00117 
00118 inline int vtkCellTypes::IsType(unsigned char type)
00119 {
00120   int numTypes=this->GetNumberOfTypes();
00121 
00122   for (int i=0; i<numTypes; i++)
00123     {
00124     if ( type == this->GetCellType(i))
00125       {
00126       return 1;
00127       }
00128     }
00129   return 0;
00130 }
00131 
00132 
00133 #endif