VTK  9.1.0
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=========================================================================*/
36#ifndef vtkCellTypes_h
37#define vtkCellTypes_h
38
39#include "vtkCommonDataModelModule.h" // For export macro
40#include "vtkObject.h"
41
42#include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
43#include "vtkIdTypeArray.h" // Needed for inline methods
44#include "vtkIntArray.h" // Needed for inline methods
45#include "vtkUnsignedCharArray.h" // Needed for inline methods
46
47class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
48{
49public:
50 static vtkCellTypes* New();
51 vtkTypeMacro(vtkCellTypes, vtkObject);
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
57 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
58
62 void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc);
63
68
73 vtkIdType ncells, vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations);
74
79 void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray* cellTypes, vtkIntArray* cellLocations);
80
84 vtkIdType GetCellLocation(vtkIdType cellId) { return this->LocationArray->GetValue(cellId); }
85
89 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
90
94 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
95
99 int IsType(unsigned char type);
100
104 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type, -1); }
105
109 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
110
114 void Squeeze();
115
119 void Reset();
120
129 unsigned long GetActualMemorySize();
130
136
141 static const char* GetClassNameFromTypeId(int typeId);
142
147 static int GetTypeIdFromClassName(const char* classname);
148
155 static int IsLinear(unsigned char type);
156
158
161 vtkUnsignedCharArray* GetCellTypesArray() { return this->TypeArray; }
162 vtkIdTypeArray* GetCellLocationsArray() { return this->LocationArray; }
164
165protected:
167 ~vtkCellTypes() override;
168
169 vtkUnsignedCharArray* TypeArray; // pointer to types array
170 vtkIdTypeArray* LocationArray; // pointer to array of offsets
171 vtkIdType Size; // allocated size of data
172 vtkIdType MaxId; // maximum index inserted thus far
173 vtkIdType Extend; // grow array by this point
174
175private:
176 vtkCellTypes(const vtkCellTypes&) = delete;
177 void operator=(const vtkCellTypes&) = delete;
178};
179
180//----------------------------------------------------------------------------
181inline int vtkCellTypes::IsType(unsigned char type)
182{
183 vtkIdType numTypes = this->GetNumberOfTypes();
184
185 for (vtkIdType i = 0; i < numTypes; i++)
186 {
187 if (type == this->GetCellType(i))
188 {
189 return 1;
190 }
191 }
192 return 0;
193}
194
195//-----------------------------------------------------------------------------
196inline int vtkCellTypes::IsLinear(unsigned char type)
197{
198 return ((type <= 20) || (type == VTK_CONVEX_POINT_SET) || (type == VTK_POLYHEDRON));
199}
200
201#endif
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:48
vtkIdType InsertNextCell(unsigned char type, vtkIdType loc)
Add a cell to the object in the next available slot.
vtkIdTypeArray * LocationArray
Definition: vtkCellTypes.h:170
int Allocate(vtkIdType sz=512, vtkIdType ext=1000)
Allocate memory for this array.
void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc)
Add a cell at specified id.
vtkIdType MaxId
Definition: vtkCellTypes.h:172
vtkIdType GetCellLocation(vtkIdType cellId)
Return the location of the cell in the associated vtkCellArray.
Definition: vtkCellTypes.h:84
void Squeeze()
Reclaim any extra memory.
void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations)
Specify a group of cell types.
void Reset()
Initialize object without releasing memory.
vtkIdType InsertNextType(unsigned char type)
Add the type specified to the end of the list.
Definition: vtkCellTypes.h:104
~vtkCellTypes() override
static vtkCellTypes * New()
static int IsLinear(unsigned char type)
This convenience method is a fast check to determine if a cell type represents a linear or nonlinear ...
Definition: vtkCellTypes.h:196
void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations)
Specify a group of cell types.
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this cell type array.
vtkIdType GetNumberOfTypes()
Return the number of types in the list.
Definition: vtkCellTypes.h:94
void DeleteCell(vtkIdType cellId)
Delete cell by setting to nullptr cell type.
Definition: vtkCellTypes.h:89
static const char * GetClassNameFromTypeId(int typeId)
Given an int (as defined in vtkCellType.h) identifier for a class return it's classname.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUnsignedCharArray * TypeArray
Definition: vtkCellTypes.h:169
vtkIdType Extend
Definition: vtkCellTypes.h:173
int IsType(unsigned char type)
Return 1 if type specified is contained in list; 0 otherwise.
Definition: vtkCellTypes.h:181
unsigned char GetCellType(vtkIdType cellId)
Return the type of cell.
Definition: vtkCellTypes.h:109
void DeepCopy(vtkCellTypes *src)
Standard DeepCopy method.
vtkIdType Size
Definition: vtkCellTypes.h:171
static int GetTypeIdFromClassName(const char *classname)
Given a data object classname, return it's int identified (as defined in vtkCellType....
vtkUnsignedCharArray * GetCellTypesArray()
Methods for obtaining the arrays representing types and locations.
Definition: vtkCellTypes.h:161
vtkIdTypeArray * GetCellLocationsArray()
Methods for obtaining the arrays representing types and locations.
Definition: vtkCellTypes.h:162
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:34
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:63
dynamic, self-adjusting array of unsigned char
@ type
Definition: vtkX3D.h:522
@ VTK_EMPTY_CELL
Definition: vtkCellType.h:46
@ VTK_POLYHEDRON
Definition: vtkCellType.h:89
@ VTK_CONVEX_POINT_SET
Definition: vtkCellType.h:86
int vtkIdType
Definition: vtkType.h:332