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 "vtkUnsignedCharArray.h" // Needed for inline methods
50 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
51 
52 class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
53 {
54 public:
55  static vtkCellTypes *New();
56  vtkTypeMacro(vtkCellTypes,vtkObject);
57  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
58 
62  int Allocate(int sz=512, int ext=1000);
63 
67  void InsertCell(int id, unsigned char type, int loc);
68 
72  vtkIdType InsertNextCell(unsigned char type, int loc);
73 
77  void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
78 
82  vtkIdType GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
83 
87  void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
88 
92  vtkIdType GetNumberOfTypes() { return (this->MaxId + 1);};
93 
97  int IsType(unsigned char type);
98 
102  vtkIdType InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
103 
107  unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
108 
112  void Squeeze();
113 
117  void Reset();
118 
127  unsigned long GetActualMemorySize();
128 
133  void DeepCopy(vtkCellTypes *src);
134 
139  static const char* GetClassNameFromTypeId(int typeId);
140 
145  static int GetTypeIdFromClassName(const char* classname);
146 
153  static int IsLinear(unsigned char type);
154 
155 protected:
156  vtkCellTypes();
157  ~vtkCellTypes() VTK_OVERRIDE;
158 
159  vtkUnsignedCharArray *TypeArray; // pointer to types array
160  vtkIntArray *LocationArray; // pointer to array of offsets
161  vtkIdType Size; // allocated size of data
162  vtkIdType MaxId; // maximum index inserted thus far
163  vtkIdType Extend; // grow array by this point
164 
165 private:
166  vtkCellTypes(const vtkCellTypes&) VTK_DELETE_FUNCTION;
167  void operator=(const vtkCellTypes&) VTK_DELETE_FUNCTION;
168 };
169 
170 
171 //----------------------------------------------------------------------------
172 inline int vtkCellTypes::IsType(unsigned char type)
173 {
174  vtkIdType numTypes=this->GetNumberOfTypes();
175 
176  for (vtkIdType i=0; i<numTypes; i++)
177  {
178  if ( type == this->GetCellType(i))
179  {
180  return 1;
181  }
182  }
183  return 0;
184 }
185 
186 //-----------------------------------------------------------------------------
187 inline int vtkCellTypes::IsLinear(unsigned char type)
188 {
189  return ( (type <= 20)
190  || (type == VTK_CONVEX_POINT_SET)
191  || (type == VTK_POLYHEDRON) );
192 }
193 
194 
195 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:59
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:87
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkIdType GetCellLocation(int cellId)
Return the location of the cell in the associated vtkCellArray.
Definition: vtkCellTypes.h:82
int vtkIdType
Definition: vtkType.h:287
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
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:102
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:187
dynamic, self-adjusting array of unsigned char
unsigned char GetCellType(int cellId)
Return the type of cell.
Definition: vtkCellTypes.h:107
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:52
vtkIdType GetNumberOfTypes()
Return the number of types in the list.
Definition: vtkCellTypes.h:92