Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | 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 
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 =========================================================================*/
00048 #ifndef __vtkCellTypes_h
00049 #define __vtkCellTypes_h
00050 
00051 #include "vtkObject.h"
00052 
00053 #include "vtkIntArray.h" // Needed for inline methods
00054 #include "vtkUnsignedCharArray.h" // Needed for inline methods
00055 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
00056 
00057 class VTK_FILTERING_EXPORT vtkCellTypes : public vtkObject 
00058 {
00059 public:
00060   static vtkCellTypes *New();
00061   vtkTypeRevisionMacro(vtkCellTypes,vtkObject);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00063 
00065   int Allocate(int sz=512, int ext=1000);
00066 
00068   void InsertCell(int id, unsigned char type, int loc);
00069   
00071   int InsertNextCell(unsigned char type, int loc);
00072 
00074   void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
00075 
00077   int GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
00078 
00080   void DeleteCell(int cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
00081 
00083   int GetNumberOfTypes() { return (this->MaxId + 1);};
00084 
00086   int IsType(unsigned char type);
00087 
00090   int InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
00091   
00093   unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
00094 
00096   void Squeeze();
00097 
00099   void Reset();
00100 
00107   unsigned long GetActualMemorySize();
00108 
00111   void DeepCopy(vtkCellTypes *src);
00112 
00113 protected:
00114   vtkCellTypes();
00115   ~vtkCellTypes();
00116 
00117   vtkUnsignedCharArray *TypeArray; // pointer to types array
00118   vtkIntArray *LocationArray;   // pointer to array of offsets
00119   int Size;            // allocated size of data
00120   int MaxId;           // maximum index inserted thus far
00121   int Extend;          // grow array by this point
00122 private:
00123   vtkCellTypes(const vtkCellTypes&);  // Not implemented.
00124   void operator=(const vtkCellTypes&);    // Not implemented.
00125 };
00126 
00127 
00128 //----------------------------------------------------------------------------
00129 inline int vtkCellTypes::IsType(unsigned char type)
00130 {
00131   int numTypes=this->GetNumberOfTypes();
00132 
00133   for (int i=0; i<numTypes; i++)
00134     {
00135     if ( type == this->GetCellType(i))
00136       {
00137       return 1;
00138       }
00139     }
00140   return 0;
00141 }
00142 
00143 
00144 #endif