VTK
|
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 int InsertNextCell(unsigned char type, int loc); 00066 00068 void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations); 00069 00071 int GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);}; 00072 00074 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);}; 00075 00077 int GetNumberOfTypes() { return (this->MaxId + 1);}; 00078 00080 int IsType(unsigned char type); 00081 00084 int 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 int Size; // allocated size of data 00128 int MaxId; // maximum index inserted thus far 00129 int Extend; // grow array by this point 00130 private: 00131 vtkCellTypes(const vtkCellTypes&); // Not implemented. 00132 void operator=(const vtkCellTypes&); // Not implemented. 00133 }; 00134 00135 00136 //---------------------------------------------------------------------------- 00137 inline int vtkCellTypes::IsType(unsigned char type) 00138 { 00139 int numTypes=this->GetNumberOfTypes(); 00140 00141 for (int i=0; i<numTypes; i++) 00142 { 00143 if ( type == this->GetCellType(i)) 00144 { 00145 return 1; 00146 } 00147 } 00148 return 0; 00149 } 00150 00151 //----------------------------------------------------------------------------- 00152 inline int vtkCellTypes::IsLinear(unsigned char type) 00153 { 00154 return ( (type <= 20) 00155 || (type == VTK_CONVEX_POINT_SET) 00156 || (type == VTK_POLYHEDRON) ); 00157 } 00158 00159 00160 #endif