VTK  9.2.6
vtkCellTypes.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkCellTypes.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
51#ifndef vtkCellTypes_h
52#define vtkCellTypes_h
53
54#include "vtkCommonDataModelModule.h" // For export macro
55#include "vtkObject.h"
56
57#include "vtkCellType.h" // Needed for inline methods
58#include "vtkDeprecation.h" // Needed for deprecation
59#include "vtkIdTypeArray.h" // Needed for inline methods
60#include "vtkSmartPointer.h" // Needed for internals
61#include "vtkUnsignedCharArray.h" // Needed for inline methods
62
63class vtkIntArray;
64
65class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
66{
67public:
68 static vtkCellTypes* New();
69 vtkTypeMacro(vtkCellTypes, vtkObject);
70 void PrintSelf(ostream& os, vtkIndent indent) override;
71
75 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
76
80 void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc);
81
85 vtkIdType InsertNextCell(unsigned char type, vtkIdType loc);
86
92 VTK_DEPRECATED_IN_9_2_0("Please use version without cellLocations.")
93 void SetCellTypes(
94 vtkIdType ncells, vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations);
95
99 void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray* cellTypes);
100
101 VTK_DEPRECATED_IN_9_2_0("Please use version without cellLocations.")
102 void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray* cellTypes, vtkIntArray* cellLocations);
103
110 VTK_DEPRECATED_IN_9_2_0("The Location API will disappear.")
111 vtkIdType GetCellLocation(vtkIdType cellId) { return this->LocationArray->GetValue(cellId); }
112
116 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
117
121 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
122
126 int IsType(unsigned char type);
127
131 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type, -1); }
132
136 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
137
141 void Squeeze();
142
146 void Reset();
147
156 unsigned long GetActualMemorySize();
157
163
168 static const char* GetClassNameFromTypeId(int typeId);
169
174 static int GetTypeIdFromClassName(const char* classname);
175
182 static int IsLinear(unsigned char type);
183
187 static int GetDimension(unsigned char type);
188
190
193 vtkUnsignedCharArray* GetCellTypesArray() { return this->TypeArray; }
194 vtkIdTypeArray* GetCellLocationsArray() { return this->LocationArray; }
196
197protected:
199 ~vtkCellTypes() override = default;
200
202
203 // DEPRECATION_IN_9_2_0 Note for whoever is in deprecation duties:
204 // The attribute LocationArray needs to be deleted, and any code in this class that would fail
205 // compiling because of its removal deleted as well.
206 vtkSmartPointer<vtkIdTypeArray> LocationArray; // pointer to array of offsets
207
208 vtkIdType MaxId; // maximum index inserted thus far
209
210private:
211 vtkCellTypes(const vtkCellTypes&) = delete;
212 void operator=(const vtkCellTypes&) = delete;
213};
214
215//----------------------------------------------------------------------------
216inline int vtkCellTypes::IsType(unsigned char type)
217{
218 vtkIdType numTypes = this->GetNumberOfTypes();
219
220 for (vtkIdType i = 0; i < numTypes; i++)
221 {
222 if (type == this->GetCellType(i))
223 {
224 return 1;
225 }
226 }
227 return 0;
228}
229
230//-----------------------------------------------------------------------------
231inline int vtkCellTypes::IsLinear(unsigned char type)
232{
233 return ((type <= 20) || (type == VTK_CONVEX_POINT_SET) || (type == VTK_POLYHEDRON));
234}
235
236#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 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:49
dynamic, self-adjusting array of int
Definition vtkIntArray.h:55
abstract base class for most VTK objects
Definition vtkObject.h:72
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
@ VTK_EMPTY_CELL
Definition vtkCellType.h:46
@ VTK_POLYHEDRON
Definition vtkCellType.h:89
@ VTK_CONVEX_POINT_SET
Definition vtkCellType.h:86
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition vtkType.h:332