VTK
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 =========================================================================*/
36 #ifndef vtkCellTypes_h
37 #define vtkCellTypes_h
38 
39 #include "vtkCommonDataModelModule.h" // For export macro
40 #include "vtkObject.h"
41 
42 #include "vtkIntArray.h" // Needed for inline methods
43 #include "vtkIdTypeArray.h" // Needed for inline methods
44 #include "vtkUnsignedCharArray.h" // Needed for inline methods
45 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
46 
47 class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
48 {
49 public:
50  static vtkCellTypes *New();
51  vtkTypeMacro(vtkCellTypes,vtkObject);
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
57  int Allocate(int sz=512, int ext=1000);
58 
62  void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc);
63 
67  vtkIdType InsertNextCell(unsigned char type, vtkIdType loc);
68 
72  void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations);
73 
78  void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
79 
83  vtkIdType GetCellLocation(vtkIdType cellId) { return this->LocationArray->GetValue(cellId);};
84 
88  void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
89 
93  vtkIdType GetNumberOfTypes() { return (this->MaxId + 1);};
94 
98  int IsType(unsigned char type);
99 
103  vtkIdType InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
104 
108  unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId);};
109 
113  void Squeeze();
114 
118  void Reset();
119 
128  unsigned long GetActualMemorySize();
129 
134  void DeepCopy(vtkCellTypes *src);
135 
140  static const char* GetClassNameFromTypeId(int typeId);
141 
146  static int GetTypeIdFromClassName(const char* classname);
147 
154  static int IsLinear(unsigned char type);
155 
156 protected:
157  vtkCellTypes();
158  ~vtkCellTypes() override;
159 
160  vtkUnsignedCharArray *TypeArray; // pointer to types array
161  vtkIdTypeArray *LocationArray; // pointer to array of offsets
162  vtkIdType Size; // allocated size of data
163  vtkIdType MaxId; // maximum index inserted thus far
164  vtkIdType Extend; // grow array by this point
165 
166 private:
167  vtkCellTypes(const vtkCellTypes&) = delete;
168  void operator=(const vtkCellTypes&) = delete;
169 };
170 
171 
172 //----------------------------------------------------------------------------
173 inline int vtkCellTypes::IsType(unsigned char type)
174 {
175  vtkIdType numTypes=this->GetNumberOfTypes();
176 
177  for (vtkIdType i=0; i<numTypes; i++)
178  {
179  if ( type == this->GetCellType(i))
180  {
181  return 1;
182  }
183  }
184  return 0;
185 }
186 
187 //-----------------------------------------------------------------------------
188 inline int vtkCellTypes::IsLinear(unsigned char type)
189 {
190  return ( (type <= 20)
191  || (type == VTK_CONVEX_POINT_SET)
192  || (type == VTK_POLYHEDRON) );
193 }
194 
195 
196 #endif
unsigned char GetCellType(vtkIdType cellId)
Return the type of cell.
Definition: vtkCellTypes.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkIdType Extend
Definition: vtkCellTypes.h:164
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DeleteCell(vtkIdType cellId)
Delete cell by setting to nullptr cell type.
Definition: vtkCellTypes.h:88
int IsType(unsigned char type)
Return 1 if type specified is contained in list; 0 otherwise.
Definition: vtkCellTypes.h:173
vtkUnsignedCharArray * TypeArray
Definition: vtkCellTypes.h:160
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
vtkIdType MaxId
Definition: vtkCellTypes.h:163
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkIdType GetCellLocation(vtkIdType cellId)
Return the location of the cell in the associated vtkCellArray.
Definition: vtkCellTypes.h:83
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIdType InsertNextType(unsigned char type)
Add the type specified to the end of the list.
Definition: vtkCellTypes.h:103
vtkIdTypeArray * LocationArray
Definition: vtkCellTypes.h:161
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:188
dynamic, self-adjusting array of unsigned char
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkIdType Size
Definition: vtkCellTypes.h:162
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:47
vtkIdType GetNumberOfTypes()
Return the number of types in the list.
Definition: vtkCellTypes.h:93