VTK  9.5.20251201
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 "vtkDeprecation.h" // for deprec macros
125#include "vtkIdTypeArray.h" // Needed for inline methods
126#include "vtkSmartPointer.h" // Needed for internals
127#include "vtkUnsignedCharArray.h" // Needed for inline methods
128
129VTK_ABI_NAMESPACE_BEGIN
130class vtkIntArray;
131
132class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
133{
134public:
135 static vtkCellTypes* New();
136 vtkTypeMacro(vtkCellTypes, vtkObject);
137 void PrintSelf(ostream& os, vtkIndent indent) override;
138
142 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
143
145
148 VTK_DEPRECATED_IN_9_6_0("Location is not used anymore, use InsertCell(id, type).")
149 void InsertCell(vtkIdType id, unsigned char type, vtkIdType);
150 void InsertCell(vtkIdType id, unsigned char type);
152
154
157 VTK_DEPRECATED_IN_9_6_0("Location is not used anymore, use InsertCell(id, type).")
158 vtkIdType InsertNextCell(unsigned char type, vtkIdType);
159 vtkIdType InsertNextCell(unsigned char type);
161
166
170 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
171
175 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
176
180 int IsType(unsigned char type);
181
185 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type); }
186
190 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
191
195 void Squeeze();
196
200 void Reset();
201
210 unsigned long GetActualMemorySize();
211
217
222 VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
223 static const char* GetClassNameFromTypeId(int typeId);
224
229 VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
230 static int GetTypeIdFromClassName(const char* classname);
231
238 VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
239 static int IsLinear(unsigned char type);
240
244 VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
245 static int GetDimension(unsigned char type);
246
248
252 VTK_DEPRECATED_IN_9_6_0("Location is not used anymore.")
255
256protected:
258 ~vtkCellTypes() override = default;
259
261
262 // VTK_DEPRECATED_IN_9_6_0
263 vtkNew<vtkIdTypeArray> LocationArray; // pointer to array of offsets
264
265 vtkIdType MaxId; // maximum index inserted thus far
266
267private:
268 vtkCellTypes(const vtkCellTypes&) = delete;
269 void operator=(const vtkCellTypes&) = delete;
270};
271
272//----------------------------------------------------------------------------
273inline int vtkCellTypes::IsType(unsigned char type)
274{
275 vtkIdType numTypes = this->GetNumberOfTypes();
276
277 for (vtkIdType i = 0; i < numTypes; i++)
278 {
279 if (type == this->GetCellType(i))
280 {
281 return 1;
282 }
283 }
284 return 0;
285}
286
287//-----------------------------------------------------------------------------
288inline int vtkCellTypes::IsLinear(unsigned char type)
289{
291}
292
293VTK_ABI_NAMESPACE_END
294#endif
static int IsLinear(unsigned char type)
This convenience method is a fast check to determine if a cell type represents a linear or nonlinear ...
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()
vtkIdType InsertNextCell(unsigned char type, vtkIdType)
Add a cell to the object in the next available slot.
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.
void InsertCell(vtkIdType id, unsigned char type, vtkIdType)
Add a cell at specified id.
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.
vtkNew< vtkIdTypeArray > LocationArray
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:108
dynamic, self-adjusting array of int
Allocate and hold a VTK object.
Definition vtkNew.h:167
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
@ VTK_EMPTY_CELL
Definition vtkCellType.h:36
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:367