VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/DataModel/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 "vtkCommonDataModelModule.h" // For export macro
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 VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
00052 {
00053 public:
00054   static vtkCellTypes *New();
00055   vtkTypeMacro(vtkCellTypes,vtkObject);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059   int Allocate(int sz=512, int ext=1000);
00060 
00062   void InsertCell(int id, unsigned char type, int loc);
00063 
00065   vtkIdType InsertNextCell(unsigned char type, int loc);
00066 
00068   void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
00069 
00071   vtkIdType GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
00072 
00074   void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
00075 
00077   vtkIdType GetNumberOfTypes() { return (this->MaxId + 1);};
00078 
00080   int IsType(unsigned char type);
00081 
00084   vtkIdType InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
00085 
00087   unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
00088 
00090   void Squeeze();
00091 
00093   void Reset();
00094 
00101   unsigned long GetActualMemorySize();
00102 
00105   void DeepCopy(vtkCellTypes *src);
00106 
00109   static const char* GetClassNameFromTypeId(int typeId);
00110 
00113   static int GetTypeIdFromClassName(const char* classname);
00114 
00119   static int IsLinear(unsigned char type);
00120 
00121 protected:
00122   vtkCellTypes();
00123   ~vtkCellTypes();
00124 
00125   vtkUnsignedCharArray *TypeArray; // pointer to types array
00126   vtkIntArray *LocationArray;   // pointer to array of offsets
00127   vtkIdType Size;            // allocated size of data
00128   vtkIdType MaxId;           // maximum index inserted thus far
00129   vtkIdType Extend;          // grow array by this point
00130 
00131 private:
00132   vtkCellTypes(const vtkCellTypes&);  // Not implemented.
00133   void operator=(const vtkCellTypes&);    // Not implemented.
00134 };
00135 
00136 
00137 //----------------------------------------------------------------------------
00138 inline int vtkCellTypes::IsType(unsigned char type)
00139 {
00140   int numTypes=this->GetNumberOfTypes();
00141 
00142   for (int i=0; i<numTypes; i++)
00143     {
00144     if ( type == this->GetCellType(i))
00145       {
00146       return 1;
00147       }
00148     }
00149   return 0;
00150 }
00151 
00152 //-----------------------------------------------------------------------------
00153 inline int vtkCellTypes::IsLinear(unsigned char type)
00154 {
00155   return (   (type <= 20)
00156           || (type == VTK_CONVEX_POINT_SET)
00157           || (type == VTK_POLYHEDRON) );
00158 }
00159 
00160 
00161 #endif