VTK
vtkIdList.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkIdList.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 =========================================================================*/
29 #ifndef vtkIdList_h
30 #define vtkIdList_h
31 
32 #include "vtkCommonCoreModule.h" // For export macro
33 #include "vtkObject.h"
34 
36 {
37 public:
38  static vtkIdList *New();
39 
40  void Initialize();
41 
44  int Allocate(const vtkIdType sz, const int strategy=0);
45 
46  vtkTypeMacro(vtkIdList,vtkObject);
47  void PrintSelf(ostream& os, vtkIndent indent);
48 
50  vtkIdType GetNumberOfIds() {return this->NumberOfIds;};
51 
53  vtkIdType GetId(const vtkIdType i) {return this->Ids[i];};
54 
57  void SetNumberOfIds(const vtkIdType number);
58 
62  void SetId(const vtkIdType i, const vtkIdType vtkid) {this->Ids[i] = vtkid;};
63 
66  void InsertId(const vtkIdType i, const vtkIdType vtkid);
67 
70  vtkIdType InsertNextId(const vtkIdType vtkid);
71 
74  vtkIdType InsertUniqueId(const vtkIdType vtkid);
75 
77  vtkIdType *GetPointer(const vtkIdType i) {return this->Ids + i;};
78 
82  vtkIdType *WritePointer(const vtkIdType i, const vtkIdType number);
83 
85  void Reset() {this->NumberOfIds = 0;};
86 
88  void Squeeze() {this->Resize(this->NumberOfIds);};
89 
91  void DeepCopy(vtkIdList *ids);
92 
95  void DeleteId(vtkIdType vtkid);
96 
99  vtkIdType IsId(vtkIdType vtkid);
100 
103  void IntersectWith(vtkIdList* otherIds);
104 
107  vtkIdType *Resize(const vtkIdType sz);
108 
109  //BTX
110  // This method should become legacy
111  void IntersectWith(vtkIdList& otherIds) {
112  this->IntersectWith(&otherIds); };
113  //ETX
114 
115 protected:
116  vtkIdList();
117  ~vtkIdList();
118 
122 
123 private:
124  vtkIdList(const vtkIdList&); // Not implemented.
125  void operator=(const vtkIdList&); // Not implemented.
126 };
127 
128 // In-lined for performance
129 inline void vtkIdList::InsertId(const vtkIdType i, const vtkIdType vtkid)
130 {
131  if (i >= this->Size)
132  {
133  this->Resize(i + 1);
134  }
135  this->Ids[i] = vtkid;
136  if (i >= this->NumberOfIds)
137  {
138  this->NumberOfIds = i + 1;
139  }
140 }
141 
142 // In-lined for performance
144 {
145  if ( this->NumberOfIds >= this->Size )
146  {
147  if (!this->Resize(this->NumberOfIds+1))
148  {
149  return this->NumberOfIds-1;
150  }
151  }
152  this->Ids[this->NumberOfIds++] = vtkid;
153  return this->NumberOfIds-1;
154 }
155 
157 {
158  vtkIdType *ptr, i;
159  for (ptr=this->Ids, i=0; i<this->NumberOfIds; i++, ptr++)
160  {
161  if ( vtkid == *ptr )
162  {
163  return i;
164  }
165  }
166  return (-1);
167 }
168 
169 #endif
void InsertId(const vtkIdType i, const vtkIdType vtkid)
Definition: vtkIdList.h:129
vtkIdType Size
Definition: vtkIdList.h:120
abstract base class for most VTK objects
Definition: vtkObject.h:61
void Squeeze()
Definition: vtkIdList.h:88
vtkIdType * Ids
Definition: vtkIdList.h:121
void SetId(const vtkIdType i, const vtkIdType vtkid)
Definition: vtkIdList.h:62
#define VTKCOMMONCORE_EXPORT
void Reset()
Definition: vtkIdList.h:85
vtkIdType GetNumberOfIds()
Definition: vtkIdList.h:50
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int vtkIdType
Definition: vtkType.h:247
vtkIdType NumberOfIds
Definition: vtkIdList.h:119
void IntersectWith(vtkIdList &otherIds)
Definition: vtkIdList.h:111
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
list of point or cell ids
Definition: vtkIdList.h:35
vtkIdType IsId(vtkIdType vtkid)
Definition: vtkIdList.h:156
vtkIdType GetId(const vtkIdType i)
Definition: vtkIdList.h:53
static vtkObject * New()
vtkIdType InsertNextId(const vtkIdType vtkid)
Definition: vtkIdList.h:143
vtkIdType * GetPointer(const vtkIdType i)
Definition: vtkIdList.h:77
vtkIdType * Resize(const vtkIdType sz)