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 =========================================================================*/
41 #ifndef vtkCellTypes_h
42 #define vtkCellTypes_h
43 
44 #include "vtkCommonDataModelModule.h" // For export macro
45 #include "vtkObject.h"
46 
47 #include "vtkIntArray.h" // Needed for inline methods
48 #include "vtkUnsignedCharArray.h" // Needed for inline methods
49 #include "vtkCellType.h" // Needed for VTK_EMPTY_CELL
50 
52 {
53 public:
54  static vtkCellTypes *New();
55  vtkTypeMacro(vtkCellTypes,vtkObject);
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
59  int Allocate(int sz=512, int ext=1000);
60 
62  void InsertCell(int id, unsigned char type, int loc);
63 
65  vtkIdType InsertNextCell(unsigned char type, int loc);
66 
68  void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
69 
71  vtkIdType GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
72 
74  void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
75 
77  vtkIdType GetNumberOfTypes() { return (this->MaxId + 1);};
78 
80  int IsType(unsigned char type);
81 
84  vtkIdType InsertNextType(unsigned char type){return this->InsertNextCell(type,-1);};
85 
87  unsigned char GetCellType(int cellId) { return this->TypeArray->GetValue(cellId);};
88 
90  void Squeeze();
91 
93  void Reset();
94 
101  unsigned long GetActualMemorySize();
102 
105  void DeepCopy(vtkCellTypes *src);
106 
109  static const char* GetClassNameFromTypeId(int typeId);
110 
113  static int GetTypeIdFromClassName(const char* classname);
114 
119  static int IsLinear(unsigned char type);
120 
121 protected:
122  vtkCellTypes();
123  ~vtkCellTypes();
124 
125  vtkUnsignedCharArray *TypeArray; // pointer to types array
126  vtkIntArray *LocationArray; // pointer to array of offsets
127  vtkIdType Size; // allocated size of data
128  vtkIdType MaxId; // maximum index inserted thus far
129  vtkIdType Extend; // grow array by this point
130 
131 private:
132  vtkCellTypes(const vtkCellTypes&); // Not implemented.
133  void operator=(const vtkCellTypes&); // Not implemented.
134 };
135 
136 
137 //----------------------------------------------------------------------------
138 inline int vtkCellTypes::IsType(unsigned char type)
139 {
140  vtkIdType numTypes=this->GetNumberOfTypes();
141 
142  for (vtkIdType i=0; i<numTypes; i++)
143  {
144  if ( type == this->GetCellType(i))
145  {
146  return 1;
147  }
148  }
149  return 0;
150 }
151 
152 //-----------------------------------------------------------------------------
153 inline int vtkCellTypes::IsLinear(unsigned char type)
154 {
155  return ( (type <= 20)
156  || (type == VTK_CONVEX_POINT_SET)
157  || (type == VTK_POLYHEDRON) );
158 }
159 
160 
161 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkIdType Extend
Definition: vtkCellTypes.h:129
void DeleteCell(vtkIdType cellId)
Definition: vtkCellTypes.h:74
int IsType(unsigned char type)
Definition: vtkCellTypes.h:138
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkUnsignedCharArray * TypeArray
Definition: vtkCellTypes.h:125
vtkIdType GetCellLocation(int cellId)
Definition: vtkCellTypes.h:71
vtkIntArray * LocationArray
Definition: vtkCellTypes.h:126
int vtkIdType
Definition: vtkType.h:275
vtkIdType MaxId
Definition: vtkCellTypes.h:128
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:49
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkIdType InsertNextType(unsigned char type)
Definition: vtkCellTypes.h:84
static int IsLinear(unsigned char type)
Definition: vtkCellTypes.h:153
dynamic, self-adjusting array of unsigned char
unsigned char GetCellType(int cellId)
Definition: vtkCellTypes.h:87
static vtkObject * New()
vtkIdType Size
Definition: vtkCellTypes.h:127
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:51
vtkIdType GetNumberOfTypes()
Definition: vtkCellTypes.h:77
#define VTKCOMMONDATAMODEL_EXPORT