VTK  9.5.20250904
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
119#ifndef vtkCellTypes_h
120#define vtkCellTypes_h
121
122#include "vtkCommonDataModelModule.h" // For export macro
123#include "vtkObject.h"
124
125#include "vtkCellType.h" // Needed for inline methods
126#include "vtkDeprecation.h" // for deprec macros
127#include "vtkIdTypeArray.h" // Needed for inline methods
128#include "vtkSmartPointer.h" // Needed for internals
129#include "vtkUnsignedCharArray.h" // Needed for inline methods
130
131VTK_ABI_NAMESPACE_BEGIN
132class vtkIntArray;
133
134class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
135{
136public:
137 static vtkCellTypes* New();
138 vtkTypeMacro(vtkCellTypes, vtkObject);
139 void PrintSelf(ostream& os, vtkIndent indent) override;
140
144 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
145
147
150 VTK_DEPRECATED_IN_9_6_0("Location is not used anymore, use InsertCell(id, type).")
151 void InsertCell(vtkIdType id, unsigned char type, vtkIdType);
152 void InsertCell(vtkIdType id, unsigned char type);
154
156
159 VTK_DEPRECATED_IN_9_6_0("Location is not used anymore, use InsertCell(id, type).")
160 vtkIdType InsertNextCell(unsigned char type, vtkIdType);
161 vtkIdType InsertNextCell(unsigned char type);
163
167 void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray* cellTypes);
168
172 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
173
177 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
178
182 int IsType(unsigned char type);
183
187 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type); }
188
192 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
193
197 void Squeeze();
198
202 void Reset();
203
212 unsigned long GetActualMemorySize();
213
219
224 static const char* GetClassNameFromTypeId(int typeId);
225
230 static int GetTypeIdFromClassName(const char* classname);
231
238 static int IsLinear(unsigned char type);
239
243 static int GetDimension(unsigned char type);
244
246
249 vtkUnsignedCharArray* GetCellTypesArray() { return this->TypeArray; }
250 VTK_DEPRECATED_IN_9_6_0("Location is not used anymore.")
251 vtkIdTypeArray* GetCellLocationsArray() { return this->LocationArray; }
253
254protected:
256 ~vtkCellTypes() override = default;
257
259
260 // VTK_DEPRECATED_IN_9_6_0
261 vtkNew<vtkIdTypeArray> LocationArray; // pointer to array of offsets
262
263 vtkIdType MaxId; // maximum index inserted thus far
264
265private:
266 vtkCellTypes(const vtkCellTypes&) = delete;
267 void operator=(const vtkCellTypes&) = delete;
268};
269
270//----------------------------------------------------------------------------
271inline int vtkCellTypes::IsType(unsigned char type)
272{
273 vtkIdType numTypes = this->GetNumberOfTypes();
274
275 for (vtkIdType i = 0; i < numTypes; i++)
276 {
277 if (type == this->GetCellType(i))
278 {
279 return 1;
280 }
281 }
282 return 0;
283}
284
285//-----------------------------------------------------------------------------
286inline int vtkCellTypes::IsLinear(unsigned char type)
287{
288 return ((type <= 20) || (type == VTK_CONVEX_POINT_SET) || (type == VTK_POLYHEDRON));
289}
290
291VTK_ABI_NAMESPACE_END
292#endif
object provides direct access to cells in vtkCellArray and type information
int Allocate(vtkIdType sz=512, vtkIdType ext=1000)
Allocate memory for this array.
vtkIdType MaxId
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()
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
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.
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
abstract base class for most VTK objects
Definition vtkObject.h:162
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
@ VTK_EMPTY_CELL
Definition vtkCellType.h:37
@ VTK_POLYHEDRON
Definition vtkCellType.h:80
@ VTK_CONVEX_POINT_SET
Definition vtkCellType.h:77
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:332