VTK
vtkCellTypes.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCellTypes.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
41 #ifndef vtkCellTypes_h
42 #define vtkCellTypes_h
43 
44 #include "vtkCommonDataModelModule.h" // For export macro
45 #include "vtkObject.h"
46 
47 #include "vtkIntArray.h" // Needed for inline methods
48 #include "vtkUnsignedCharArray.h" // Needed for inline methods
49 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
50 
52 {
53 public:
54  static vtkCellTypes *New();
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
59  int Allocate(int sz=512, int ext=1000);
60 
62  void InsertCell(int id, unsigned char type, int loc);
63 
65  vtkIdType InsertNextCell(unsigned char type, int loc);
66 
68  void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
69 
71  vtkIdType GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
72 
74  void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
75 
77  vtkIdType GetNumberOfTypes() { return (this->MaxId + 1);};
78 
80  int IsType(unsigned char type);
81 
84  vtkIdType InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
85 
87  unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
88 
90  void Squeeze();
91 
93  void Reset();
94 
101  unsigned long GetActualMemorySize();
102 
106 
109  static const char* GetClassNameFromTypeId(int typeId);
110 
113  static int GetTypeIdFromClassName(const char* classname);
114 
119  static int IsLinear(unsigned char type);
120 
121 protected:
124 
125  vtkUnsignedCharArray *TypeArray; // pointer to types array
126  vtkIntArray *LocationArray; // pointer to array of offsets
127  vtkIdType Size; // allocated size of data
128  vtkIdType MaxId; // maximum index inserted thus far
129  vtkIdType Extend; // grow array by this point
130 
131 private:
132  vtkCellTypes(const vtkCellTypes&); // Not implemented.
133  void operator=(const vtkCellTypes&); // Not implemented.
134 };
135 
136 
137 //----------------------------------------------------------------------------
138 inline int vtkCellTypes::IsType(unsigned char type)
139 {
140  vtkIdType numTypes=this->GetNumberOfTypes();
141 
142  for (vtkIdType i=0; i<numTypes; i++)
143  {
144  if ( type == this->GetCellType(i))
145  {
146  return 1;
147  }
148  }
149  return 0;
150 }
151 
152 //-----------------------------------------------------------------------------
153 inline int vtkCellTypes::IsLinear(unsigned char type)
154 {
155  return ( (type <= 20)
156  || (type == VTK_CONVEX_POINT_SET)
157  || (type == VTK_POLYHEDRON) );
158 }
159 
160 
161 #endif
vtkCellTypes::SetCellTypes
void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations)
vtkCellTypes::InsertNextType
vtkIdType InsertNextType(unsigned char type)
Definition: vtkCellTypes.h:84
VTK_POLYHEDRON
@ VTK_POLYHEDRON
Definition: vtkCellType.h:86
vtkCellTypes::vtkCellTypes
vtkCellTypes()
vtkCellTypes
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:52
vtkCellTypes::Reset
void Reset()
vtkCellTypes::InsertCell
void InsertCell(int id, unsigned char type, int loc)
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkCommonDataModelModule.h
vtkCellTypes::Squeeze
void Squeeze()
vtkCellTypes::New
static vtkCellTypes * New()
vtkCellTypes::GetClassNameFromTypeId
static const char * GetClassNameFromTypeId(int typeId)
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:49
vtkCellTypes::Extend
vtkIdType Extend
Definition: vtkCellTypes.h:129
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkCellTypes::IsType
int IsType(unsigned char type)
Definition: vtkCellTypes.h:138
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkCellTypes::GetCellType
unsigned char GetCellType(int cellId)
Definition: vtkCellTypes.h:87
vtkCellTypes::DeepCopy
void DeepCopy(vtkCellTypes *src)
vtkCellTypes::TypeArray
vtkUnsignedCharArray * TypeArray
Definition: vtkCellTypes.h:125
vtkCellTypes::GetNumberOfTypes
vtkIdType GetNumberOfTypes()
Definition: vtkCellTypes.h:77
vtkCellTypes::GetCellLocation
vtkIdType GetCellLocation(int cellId)
Definition: vtkCellTypes.h:71
VTK_CONVEX_POINT_SET
@ VTK_CONVEX_POINT_SET
Definition: vtkCellType.h:83
vtkCellTypes::Size
vtkIdType Size
Definition: vtkCellTypes.h:127
VTK_EMPTY_CELL
@ VTK_EMPTY_CELL
Definition: vtkCellType.h:44
vtkCellTypes::IsLinear
static int IsLinear(unsigned char type)
Definition: vtkCellTypes.h:153
vtkgl::src
GLenum src
Definition: vtkgl.h:12525
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:53
vtkCellType.h
vtkUnsignedCharArray.h
vtkCellTypes::GetActualMemorySize
unsigned long GetActualMemorySize()
vtkCellTypes::GetTypeIdFromClassName
static int GetTypeIdFromClassName(const char *classname)
vtkCellTypes::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkObject.h
vtkCellTypes::DeleteCell
void DeleteCell(vtkIdType cellId)
Definition: vtkCellTypes.h:74
vtkIntArray.h
vtkCellTypes::LocationArray
vtkIntArray * LocationArray
Definition: vtkCellTypes.h:126
VTKCOMMONDATAMODEL_EXPORT
#define VTKCOMMONDATAMODEL_EXPORT
Definition: vtkCommonDataModelModule.h:15
vtkCellTypes::MaxId
vtkIdType MaxId
Definition: vtkCellTypes.h:128
vtkgl::type
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
vtkCellTypes::InsertNextCell
vtkIdType InsertNextCell(unsigned char type, int loc)
vtkCellTypes::~vtkCellTypes
~vtkCellTypes()
vtkCellTypes::Allocate
int Allocate(int sz=512, int ext=1000)