VTK  9.3.20240425
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 "vtkIdTypeArray.h" // Needed for inline methods
127#include "vtkSmartPointer.h" // Needed for internals
128#include "vtkUnsignedCharArray.h" // Needed for inline methods
129
130VTK_ABI_NAMESPACE_BEGIN
131class vtkIntArray;
132
133class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
134{
135public:
136 static vtkCellTypes* New();
137 vtkTypeMacro(vtkCellTypes, vtkObject);
138 void PrintSelf(ostream& os, vtkIndent indent) override;
139
143 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
144
148 void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc);
149
153 vtkIdType InsertNextCell(unsigned char type, vtkIdType loc);
154
159
163 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
164
168 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
169
173 int IsType(unsigned char type);
174
178 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type, -1); }
179
183 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
184
188 void Squeeze();
189
193 void Reset();
194
203 unsigned long GetActualMemorySize();
204
210
215 static const char* GetClassNameFromTypeId(int typeId);
216
221 static int GetTypeIdFromClassName(const char* classname);
222
229 static int IsLinear(unsigned char type);
230
234 static int GetDimension(unsigned char type);
235
237
240 vtkUnsignedCharArray* GetCellTypesArray() { return this->TypeArray; }
241 vtkIdTypeArray* GetCellLocationsArray() { return this->LocationArray; }
243
244protected:
246 ~vtkCellTypes() override = default;
247
249
250 // DEPRECATION_IN_9_2_0 Note for whoever is in deprecation duties:
251 // The attribute LocationArray needs to be deleted, and any code in this class that would fail
252 // compiling because of its removal deleted as well.
253 vtkSmartPointer<vtkIdTypeArray> LocationArray; // pointer to array of offsets
254
255 vtkIdType MaxId; // maximum index inserted thus far
256
257private:
258 vtkCellTypes(const vtkCellTypes&) = delete;
259 void operator=(const vtkCellTypes&) = delete;
260};
261
262//----------------------------------------------------------------------------
263inline int vtkCellTypes::IsType(unsigned char type)
264{
265 vtkIdType numTypes = this->GetNumberOfTypes();
266
267 for (vtkIdType i = 0; i < numTypes; i++)
268 {
269 if (type == this->GetCellType(i))
270 {
271 return 1;
272 }
273 }
274 return 0;
275}
276
277//-----------------------------------------------------------------------------
278inline int vtkCellTypes::IsLinear(unsigned char type)
279{
280 return ((type <= 20) || (type == VTK_CONVEX_POINT_SET) || (type == VTK_POLYHEDRON));
281}
282
283VTK_ABI_NAMESPACE_END
284#endif
object provides direct access to cells in vtkCellArray and type information
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:108
dynamic, self-adjusting array of int
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:56
@ VTK_POLYHEDRON
Definition vtkCellType.h:99
@ VTK_CONVEX_POINT_SET
Definition vtkCellType.h:96
int vtkIdType
Definition vtkType.h:315