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=========================================================================*/
35
36#ifndef vtkCellTypes_h
37#define vtkCellTypes_h
38
39#include "vtkCommonDataModelModule.h" // For export macro
40#include "vtkObject.h"
41
42#include "vtkCellType.h" // Needed for inline methods
43#include "vtkDeprecation.h" // Needed for deprecation
44#include "vtkIdTypeArray.h" // Needed for inline methods
45#include "vtkSmartPointer.h" // Needed for internals
46#include "vtkUnsignedCharArray.h" // Needed for inline methods
47
48class vtkIntArray;
49
50class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
51{
52public:
53 static vtkCellTypes* New();
54 vtkTypeMacro(vtkCellTypes, vtkObject);
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
60 int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
61
65 void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc);
66
70 vtkIdType InsertNextCell(unsigned char type, vtkIdType loc);
71
77 VTK_DEPRECATED_IN_9_2_0("Please use version without cellLocations.")
79 vtkIdType ncells, vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations);
80
85
86 VTK_DEPRECATED_IN_9_2_0("Please use version without cellLocations.")
87 void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray* cellTypes, vtkIntArray* cellLocations);
88
95 VTK_DEPRECATED_IN_9_2_0("The Location API will disappear.")
96 vtkIdType GetCellLocation(vtkIdType cellId) { return this->LocationArray->GetValue(cellId); }
97
101 void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
102
106 vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
107
111 int IsType(unsigned char type);
112
116 vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type, -1); }
117
121 unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
122
126 void Squeeze();
127
131 void Reset();
132
141 unsigned long GetActualMemorySize();
142
148
153 static const char* GetClassNameFromTypeId(int typeId);
154
159 static int GetTypeIdFromClassName(const char* classname);
160
167 static int IsLinear(unsigned char type);
168
172 static int GetDimension(unsigned char type);
173
175
181
182protected:
184 ~vtkCellTypes() override = default;
185
187
188 // DEPRECATION_IN_9_2_0 Note for whoever is in deprecation duties:
189 // The attribute LocationArray needs to be deleted, and any code in this class that would fail
190 // compiling because of its removal deleted as well.
191 vtkSmartPointer<vtkIdTypeArray> LocationArray; // pointer to array of offsets
192
193 vtkIdType MaxId; // maximum index inserted thus far
194
195private:
196 vtkCellTypes(const vtkCellTypes&) = delete;
197 void operator=(const vtkCellTypes&) = delete;
198};
199
200//----------------------------------------------------------------------------
201inline int vtkCellTypes::IsType(unsigned char type)
202{
203 vtkIdType numTypes = this->GetNumberOfTypes();
204
205 for (vtkIdType i = 0; i < numTypes; i++)
206 {
207 if (type == this->GetCellType(i))
208 {
209 return 1;
210 }
211 }
212 return 0;
213}
214
215//-----------------------------------------------------------------------------
216inline int vtkCellTypes::IsLinear(unsigned char type)
217{
218 return ((type <= 20) || (type == VTK_CONVEX_POINT_SET) || (type == VTK_POLYHEDRON));
219}
220
221#endif
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
vtkIdType GetCellLocation(vtkIdType cellId)
Return the location of the cell in the associated vtkCellArray.
void Squeeze()
Reclaim any extra memory.
void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations)
Specify a group of cell types.
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:34
dynamic, self-adjusting array of int
Definition vtkIntArray.h:40
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