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