VTK
dox/Filtering/vtkCellTypes.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCellTypes.h
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 =========================================================================*/
00041 #ifndef __vtkCellTypes_h
00042 #define __vtkCellTypes_h
00043 
00044 #include "vtkObject.h"
00045 
00046 #include "vtkIntArray.h" // Needed for inline methods
00047 #include "vtkUnsignedCharArray.h" // Needed for inline methods
00048 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
00049 
00050 class VTK_FILTERING_EXPORT vtkCellTypes : public vtkObject 
00051 {
00052 public:
00053   static vtkCellTypes *New();
00054   vtkTypeMacro(vtkCellTypes,vtkObject);
00055   void PrintSelf(ostream& os, vtkIndent indent);
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(vtkIdType 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 
00108   static const char* GetClassNameFromTypeId(int typeId);
00109 
00112   static int GetTypeIdFromClassName(const char* classname);
00113 
00118   static int IsLinear(unsigned char type);
00119 
00120 protected:
00121   vtkCellTypes();
00122   ~vtkCellTypes();
00123 
00124   vtkUnsignedCharArray *TypeArray; // pointer to types array
00125   vtkIntArray *LocationArray;   // pointer to array of offsets
00126   int Size;            // allocated size of data
00127   int MaxId;           // maximum index inserted thus far
00128   int Extend;          // grow array by this point
00129 private:
00130   vtkCellTypes(const vtkCellTypes&);  // Not implemented.
00131   void operator=(const vtkCellTypes&);    // Not implemented.
00132 };
00133 
00134 
00135 //----------------------------------------------------------------------------
00136 inline int vtkCellTypes::IsType(unsigned char type)
00137 {
00138   int numTypes=this->GetNumberOfTypes();
00139 
00140   for (int i=0; i<numTypes; i++)
00141     {
00142     if ( type == this->GetCellType(i))
00143       {
00144       return 1;
00145       }
00146     }
00147   return 0;
00148 }
00149 
00150 //-----------------------------------------------------------------------------
00151 inline int vtkCellTypes::IsLinear(unsigned char type)
00152 {
00153   return (   (type <= 20)
00154           || (type == VTK_CONVEX_POINT_SET)
00155           || (type == VTK_POLYHEDRON) );
00156 }
00157 
00158 
00159 #endif