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 =========================================================================*/
42 #ifndef vtkCellTypes_h
43 #define vtkCellTypes_h
44 
45 #include "vtkCommonDataModelModule.h" // For export macro
46 #include "vtkObject.h"
47 
48 #include "vtkIntArray.h" // Needed for inline methods
49 #include "vtkIdTypeArray.h" // Needed for inline methods
50 #include "vtkUnsignedCharArray.h" // Needed for inline methods
51 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
52 
53 class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
54 {
55 public:
56  static vtkCellTypes *New();
57  vtkTypeMacro(vtkCellTypes,vtkObject);
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
63  int Allocate(int sz=512, int ext=1000);
64 
68  void InsertCell(vtkIdType id, unsigned char type, vtkIdType loc);
69 
73  vtkIdType InsertNextCell(unsigned char type, vtkIdType loc);
74 
78  void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations);
79 
84  void SetCellTypes(vtkIdType ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
85 
89  vtkIdType GetCellLocation(vtkIdType cellId) { return this->LocationArray->GetValue(cellId);};
90 
94  void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
95 
99  vtkIdType GetNumberOfTypes() { return (this->MaxId + 1);};
100 
104  int IsType(unsigned char type);
105 
109  vtkIdType InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
110 
114  unsigned char GetCellType(vtkIdType cellId) { return this->TypeArray->GetValue(cellId);};
115 
119  void Squeeze();
120 
124  void Reset();
125 
134  unsigned long GetActualMemorySize();
135 
140  void DeepCopy(vtkCellTypes *src);
141 
146  static const char* GetClassNameFromTypeId(int typeId);
147 
152  static int GetTypeIdFromClassName(const char* classname);
153 
160  static int IsLinear(unsigned char type);
161 
162 protected:
163  vtkCellTypes();
164  ~vtkCellTypes() override;
165 
166  vtkUnsignedCharArray *TypeArray; // pointer to types array
167  vtkIdTypeArray *LocationArray; // pointer to array of offsets
168  vtkIdType Size; // allocated size of data
169  vtkIdType MaxId; // maximum index inserted thus far
170  vtkIdType Extend; // grow array by this point
171 
172 private:
173  vtkCellTypes(const vtkCellTypes&) = delete;
174  void operator=(const vtkCellTypes&) = delete;
175 };
176 
177 
178 //----------------------------------------------------------------------------
179 inline int vtkCellTypes::IsType(unsigned char type)
180 {
181  vtkIdType numTypes=this->GetNumberOfTypes();
182 
183  for (vtkIdType i=0; i<numTypes; i++)
184  {
185  if ( type == this->GetCellType(i))
186  {
187  return 1;
188  }
189  }
190  return 0;
191 }
192 
193 //-----------------------------------------------------------------------------
194 inline int vtkCellTypes::IsLinear(unsigned char type)
195 {
196  return ( (type <= 20)
197  || (type == VTK_CONVEX_POINT_SET)
198  || (type == VTK_POLYHEDRON) );
199 }
200 
201 
202 #endif
unsigned char GetCellType(vtkIdType cellId)
Return the type of cell.
Definition: vtkCellTypes.h:114
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkIdType Extend
Definition: vtkCellTypes.h:170
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:94
int IsType(unsigned char type)
Return 1 if type specified is contained in list; 0 otherwise.
Definition: vtkCellTypes.h:179
vtkUnsignedCharArray * TypeArray
Definition: vtkCellTypes.h:166
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkIdType MaxId
Definition: vtkCellTypes.h:169
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
vtkIdType GetCellLocation(vtkIdType cellId)
Return the location of the cell in the associated vtkCellArray.
Definition: vtkCellTypes.h:89
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkIdType InsertNextType(unsigned char type)
Add the type specified to the end of the list.
Definition: vtkCellTypes.h:109
vtkIdTypeArray * LocationArray
Definition: vtkCellTypes.h:167
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:194
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:168
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:53
vtkIdType GetNumberOfTypes()
Return the number of types in the list.
Definition: vtkCellTypes.h:99