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