VTK  9.7.20260712
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
115
116#ifndef vtkCellTypes_h
117#define vtkCellTypes_h
118
119#include "vtkCommonDataModelModule.h" // For export macro
120#include "vtkObject.h"
121
122#include "vtkCellType.h" // Needed for inline methods
123#include "vtkCellTypeUtilities.h" // for backward compatibility
124#include "vtkIdTypeArray.h" // Needed for inline methods
125#include "vtkSmartPointer.h" // Needed for internals
126#include "vtkUnsignedCharArray.h" // Needed for inline methods
127
128VTK_ABI_NAMESPACE_BEGIN
129class vtkIntArray;
130
131class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
132{
133public:
134 static vtkCellTypes* New();
135 vtkTypeMacro(vtkCellTypes, vtkObject);
136 void PrintSelf(ostream& os, vtkIndent indent) override;
137
141 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
142
146 void InsertCell(vtkIdType id, unsigned char type);
147
151 vtkIdType InsertNextCell(unsigned char type);
152
157
161 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
162
166 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
167
171 int IsType(unsigned char type);
172
176 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type); }
177
181 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
182
186 void Squeeze();
187
191 void Reset();
192
201 unsigned long GetActualMemorySize();
202
208
213
214protected:
216 ~vtkCellTypes() override = default;
217
219
220 vtkIdType MaxId; // maximum index inserted thus far
221
222private:
223 vtkCellTypes(const vtkCellTypes&) = delete;
224 void operator=(const vtkCellTypes&) = delete;
225};
226
227//----------------------------------------------------------------------------
228inline int vtkCellTypes::IsType(unsigned char type)
229{
230 vtkIdType numTypes = this->GetNumberOfTypes();
231
232 for (vtkIdType i = 0; i < numTypes; i++)
233 {
234 if (type == this->GetCellType(i))
235 {
236 return 1;
237 }
238 }
239 return 0;
240}
241
242VTK_ABI_NAMESPACE_END
243#endif
int Allocate(vtkIdType sz=512, vtkIdType ext=1000)
Allocate memory for this array.
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
static vtkCellTypes * New()
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.
vtkIdType InsertNextCell(unsigned char type)
Add a cell to the object in the next available slot.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void InsertCell(vtkIdType id, unsigned char type)
Add a cell at specified id.
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.
vtkUnsignedCharArray * GetCellTypesArray()
Methods for obtaining the arrays representing types and locations.
a simple class to control print indentation
Definition vtkIndent.h:108
dynamic, self-adjusting array of int
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
@ VTK_EMPTY_CELL
Definition vtkCellType.h:37
int vtkIdType
Definition vtkType.h:363