VTK  9.5.2
vtkCellTypes.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
29
30#ifndef vtkCellTypes_h
31#define vtkCellTypes_h
32
33#include "vtkCommonDataModelModule.h" // For export macro
34#include "vtkObject.h"
35
36#include "vtkCellType.h" // Needed for inline methods
37#include "vtkIdTypeArray.h" // Needed for inline methods
38#include "vtkSmartPointer.h" // Needed for internals
39#include "vtkUnsignedCharArray.h" // Needed for inline methods
40
41VTK_ABI_NAMESPACE_BEGIN
42class vtkIntArray;
43
44class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
45{
46public:
47 static vtkCellTypes* New();
48 vtkTypeMacro(vtkCellTypes, vtkObject);
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
54 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
55
59 void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc);
60
64 vtkIdType InsertNextCell(unsigned char type, vtkIdType loc);
65
70
74 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
75
79 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
80
84 int IsType(unsigned char type);
85
89 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type, -1); }
90
94 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
95
99 void Squeeze();
100
104 void Reset();
105
114 unsigned long GetActualMemorySize();
115
121
126 static const char* GetClassNameFromTypeId(int typeId);
127
132 static int GetTypeIdFromClassName(const char* classname);
133
140 static int IsLinear(unsigned char type);
141
145 static int GetDimension(unsigned char type);
146
148
154
155protected:
157 ~vtkCellTypes() override = default;
158
160
161 // DEPRECATION_IN_9_2_0 Note for whoever is in deprecation duties:
162 // The attribute LocationArray needs to be deleted, and any code in this class that would fail
163 // compiling because of its removal deleted as well.
164 vtkSmartPointer<vtkIdTypeArray> LocationArray; // pointer to array of offsets
165
166 vtkIdType MaxId; // maximum index inserted thus far
167
168private:
169 vtkCellTypes(const vtkCellTypes&) = delete;
170 void operator=(const vtkCellTypes&) = delete;
171};
172
173//----------------------------------------------------------------------------
174inline int vtkCellTypes::IsType(unsigned char type)
175{
176 vtkIdType numTypes = this->GetNumberOfTypes();
177
178 for (vtkIdType i = 0; i < numTypes; i++)
179 {
180 if (type == this->GetCellType(i))
181 {
182 return 1;
183 }
184 }
185 return 0;
186}
187
188//-----------------------------------------------------------------------------
189inline int vtkCellTypes::IsLinear(unsigned char type)
190{
191 return ((type <= 20) || (type == VTK_CONVEX_POINT_SET) || (type == VTK_POLYHEDRON));
192}
193
194VTK_ABI_NAMESPACE_END
195#endif
vtkIdType InsertNextCell(unsigned char type, vtkIdType loc)
Add a cell to the object in the next available slot.
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
void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes)
Specify a group of cell types.
void Squeeze()
Reclaim any extra memory.
void Reset()
Initialize object without releasing memory.
vtkIdType InsertNextType(unsigned char type)
Add the type specified to the end of the list.
~vtkCellTypes() override=default
vtkSmartPointer< vtkIdTypeArray > LocationArray
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 ...
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.
vtkSmartPointer< vtkUnsignedCharArray > TypeArray
void DeleteCell(vtkIdType cellId)
Delete cell by setting to nullptr cell type.
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.
static int GetDimension(unsigned char type)
Get the dimension of a cell.
int IsType(unsigned char type)
Return 1 if type specified is contained in list; 0 otherwise.
unsigned char GetCellType(vtkIdType cellId)
Return the type of cell.
void DeepCopy(vtkCellTypes *src)
Standard DeepCopy method.
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.
vtkIdTypeArray * GetCellLocationsArray()
Methods for obtaining the arrays representing types and locations.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:29
dynamic, self-adjusting array of int
Definition vtkIntArray.h:35
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
int GetCellType() override
Implement the vtkCell API.
@ VTK_EMPTY_CELL
Definition vtkCellType.h:37
@ VTK_POLYHEDRON
Definition vtkCellType.h:80
@ VTK_CONVEX_POINT_SET
Definition vtkCellType.h:77
int vtkIdType
Definition vtkType.h:332