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 "vtkUnsignedCharArray.h" // Needed for inline methods
44 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
45 
46 class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
47 {
48 public:
49  static vtkCellTypes *New();
50  vtkTypeMacro(vtkCellTypes,vtkObject);
51  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
52 
56  int Allocate(int sz=512, int ext=1000);
57 
61  void InsertCell(int id, unsigned char type, int loc);
62 
66  vtkIdType InsertNextCell(unsigned char type, int loc);
67 
71  void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
72 
76  vtkIdType GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
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,-1);};
97 
101  unsigned char GetCellType(int 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  static const char* GetClassNameFromTypeId(int typeId);
134 
139  static int GetTypeIdFromClassName(const char* classname);
140 
147  static int IsLinear(unsigned char type);
148 
149 protected:
150  vtkCellTypes();
151  ~vtkCellTypes() VTK_OVERRIDE;
152 
153  vtkUnsignedCharArray *TypeArray; // pointer to types array
154  vtkIntArray *LocationArray; // pointer to array of offsets
155  vtkIdType Size; // allocated size of data
156  vtkIdType MaxId; // maximum index inserted thus far
157  vtkIdType Extend; // grow array by this point
158 
159 private:
160  vtkCellTypes(const vtkCellTypes&) VTK_DELETE_FUNCTION;
161  void operator=(const vtkCellTypes&) VTK_DELETE_FUNCTION;
162 };
163 
164 
165 //----------------------------------------------------------------------------
166 inline int vtkCellTypes::IsType(unsigned char type)
167 {
168  vtkIdType numTypes=this->GetNumberOfTypes();
169 
170  for (vtkIdType i=0; i<numTypes; i++)
171  {
172  if ( type == this->GetCellType(i))
173  {
174  return 1;
175  }
176  }
177  return 0;
178 }
179 
180 //-----------------------------------------------------------------------------
181 inline int vtkCellTypes::IsLinear(unsigned char type)
182 {
183  return ( (type <= 20)
184  || (type == VTK_CONVEX_POINT_SET)
185  || (type == VTK_POLYHEDRON) );
186 }
187 
188 
189 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkIdType Extend
Definition: vtkCellTypes.h:157
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 NULL cell type.
Definition: vtkCellTypes.h:81
int IsType(unsigned char type)
Return 1 if type specified is contained in list; 0 otherwise.
Definition: vtkCellTypes.h:166
vtkUnsignedCharArray * TypeArray
Definition: vtkCellTypes.h:153
vtkIdType GetCellLocation(int cellId)
Return the location of the cell in the associated vtkCellArray.
Definition: vtkCellTypes.h:76
vtkIntArray * LocationArray
Definition: vtkCellTypes.h:154
int vtkIdType
Definition: vtkType.h:345
vtkIdType MaxId
Definition: vtkCellTypes.h:156
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
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: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:181
dynamic, self-adjusting array of unsigned char
unsigned char GetCellType(int cellId)
Return the type of cell.
Definition: vtkCellTypes.h:101
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkIdType Size
Definition: vtkCellTypes.h:155
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:46
vtkIdType GetNumberOfTypes()
Return the number of types in the list.
Definition: vtkCellTypes.h:86