VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
51 class VTKCOMMONDATAMODEL_EXPORT vtkCellTypes : public vtkObject
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  int InsertNextCell(unsigned char type, int loc);
66 
68  void SetCellTypes(int ncells, vtkUnsignedCharArray *cellTypes, vtkIntArray *cellLocations);
69 
71  int GetCellLocation(int cellId) { return this->LocationArray->GetValue(cellId);};
72 
74  void DeleteCell(vtkIdType cellId) { this->TypeArray->SetValue(cellId, VTK_EMPTY_CELL);};
75 
77  int GetNumberOfTypes() { return (this->MaxId + 1);};
78 
80  int IsType(unsigned char type);
81 
84  int 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  int Size; // allocated size of data
128  int MaxId; // maximum index inserted thus far
129  int Extend; // grow array by this point
130 private:
131  vtkCellTypes(const vtkCellTypes&); // Not implemented.
132  void operator=(const vtkCellTypes&); // Not implemented.
133 };
134 
135 
136 //----------------------------------------------------------------------------
137 inline int vtkCellTypes::IsType(unsigned char type)
138 {
139  int numTypes=this->GetNumberOfTypes();
140 
141  for (int i=0; i<numTypes; i++)
142  {
143  if ( type == this->GetCellType(i))
144  {
145  return 1;
146  }
147  }
148  return 0;
149 }
150 
151 //-----------------------------------------------------------------------------
152 inline int vtkCellTypes::IsLinear(unsigned char type)
153 {
154  return ( (type <= 20)
155  || (type == VTK_CONVEX_POINT_SET)
156  || (type == VTK_POLYHEDRON) );
157 }
158 
159 
160 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:61
void DeleteCell(vtkIdType cellId)
Definition: vtkCellTypes.h:74
int IsType(unsigned char type)
Definition: vtkCellTypes.h:137
int GetCellLocation(int cellId)
Definition: vtkCellTypes.h:71
int InsertNextType(unsigned char type)
Definition: vtkCellTypes.h:84
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkUnsignedCharArray * TypeArray
Definition: vtkCellTypes.h:125
vtkIntArray * LocationArray
Definition: vtkCellTypes.h:126
int vtkIdType
Definition: vtkType.h:268
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:43
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
static int IsLinear(unsigned char type)
Definition: vtkCellTypes.h:152
dynamic, self-adjusting array of unsigned char
int GetNumberOfTypes()
Definition: vtkCellTypes.h:77
unsigned char GetCellType(int cellId)
Definition: vtkCellTypes.h:87
static vtkObject * New()
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:51