VTK  9.7.1
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
27 #ifndef vtkCellTypes_h
28 #define vtkCellTypes_h
29 
30 #include "vtkCommonDataModelModule.h" // For export macro
31 #include "vtkObject.h"
32 
33 #include "vtkCellType.h" // Needed for inline methods
34 #include "vtkCellTypeUtilities.h" // for backward compatibility
35 #include "vtkDeprecation.h" // for deprec macros
36 #include "vtkIdTypeArray.h" // Needed for inline methods
37 #include "vtkSmartPointer.h" // Needed for internals
38 #include "vtkUnsignedCharArray.h" // Needed for inline methods
39 
40 VTK_ABI_NAMESPACE_BEGIN
41 class vtkIntArray;
42 
43 class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
44 {
45 public:
46  static vtkCellTypes* New();
47  vtkTypeMacro(vtkCellTypes, vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
53  int Allocate(vtkIdType sz = 512, vtkIdType ext = 1000);
54 
56 
59  VTK_DEPRECATED_IN_9_6_0("Location is not used anymore, use InsertCell(id, type).")
60  void InsertCell(vtkIdType id, unsigned char type, vtkIdType);
61  void InsertCell(vtkIdType id, unsigned char type);
63 
65 
68  VTK_DEPRECATED_IN_9_6_0("Location is not used anymore, use InsertCell(id, type).")
69  vtkIdType InsertNextCell(unsigned char type, vtkIdType);
70  vtkIdType InsertNextCell(unsigned char type);
72 
76  void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray* cellTypes);
77 
81  void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL); }
82 
86  vtkIdType GetNumberOfTypes() { return (this->MaxId + 1); }
87 
91  int IsType(unsigned char type);
92 
96  vtkIdType InsertNextType(unsigned char type) { return this->InsertNextCell(type); }
97 
101  unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId); }
102 
106  void Squeeze();
107 
111  void Reset();
112 
121  unsigned long GetActualMemorySize();
122 
127  void DeepCopy(vtkCellTypes* src);
128 
133  VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
134  static const char* GetClassNameFromTypeId(int typeId);
135 
140  VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
141  static int GetTypeIdFromClassName(const char* classname);
142 
149  VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
150  static int IsLinear(unsigned char type);
151 
155  VTK_DEPRECATED_IN_9_6_0("Use vtkCellTypeUtilities variant instead.")
156  static int GetDimension(unsigned char type);
157 
159 
162  vtkUnsignedCharArray* GetCellTypesArray() { return this->TypeArray; }
163  VTK_DEPRECATED_IN_9_6_0("Location is not used anymore.")
164  vtkIdTypeArray* GetCellLocationsArray() { return this->LocationArray; }
166 
167 protected:
168  vtkCellTypes();
169  ~vtkCellTypes() override = default;
170 
172 
173  // VTK_DEPRECATED_IN_9_6_0
174  vtkNew<vtkIdTypeArray> LocationArray; // pointer to array of offsets
175 
176  vtkIdType MaxId; // maximum index inserted thus far
177 
178 private:
179  vtkCellTypes(const vtkCellTypes&) = delete;
180  void operator=(const vtkCellTypes&) = delete;
181 };
182 
183 //----------------------------------------------------------------------------
184 inline int vtkCellTypes::IsType(unsigned char type)
185 {
186  vtkIdType numTypes = this->GetNumberOfTypes();
187 
188  for (vtkIdType i = 0; i < numTypes; i++)
189  {
190  if (type == this->GetCellType(i))
191  {
192  return 1;
193  }
194  }
195  return 0;
196 }
197 
198 //-----------------------------------------------------------------------------
199 inline int vtkCellTypes::IsLinear(unsigned char type)
200 {
201  return vtkCellTypeUtilities::IsLinear(type);
202 }
203 
204 VTK_ABI_NAMESPACE_END
205 #endif
unsigned char GetCellType(vtkIdType cellId)
Return the type of cell.
Definition: vtkCellTypes.h:101
vtkNew< vtkIdTypeArray > LocationArray
Definition: vtkCellTypes.h:174
abstract base class for most VTK objects
Definition: vtkObject.h:52
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int IsType(unsigned char type)
Return 1 if type specified is contained in list; 0 otherwise.
Definition: vtkCellTypes.h:184
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
vtkIdType MaxId
Definition: vtkCellTypes.h:176
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
#define VTK_DEPRECATED_IN_9_6_0(reason)
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkIdType InsertNextType(unsigned char type)
Add the type specified to the end of the list.
Definition: vtkCellTypes.h:96
static int IsLinear(unsigned char type)
This convenience method is a fast check to determine if a cell type represents a linear or nonlinear ...
Definition: vtkCellTypes.h:199
dynamic, self-adjusting array of unsigned char
vtkCellTypeUtilities is a collection of methods for cell type lookup.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
static int IsLinear(unsigned char type)
This convenience method is a fast check to determine if a cell type represents a linear or nonlinear ...
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:43
vtkIdType GetNumberOfTypes()
Return the number of types in the list.
Definition: vtkCellTypes.h:86
vtkSmartPointer< vtkUnsignedCharArray > TypeArray
Definition: vtkCellTypes.h:171