VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
35 class VTKCOMMONCORE_EXPORT vtkIdList : public vtkObject
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 
105  //BTX
106  // This method should become legacy
107  void IntersectWith(vtkIdList& otherIds) {
108  this->IntersectWith(&otherIds); };
109  //ETX
110 
111 protected:
112  vtkIdList();
113  ~vtkIdList();
114 
118 
119  vtkIdType *Resize(const vtkIdType sz);
120 private:
121  vtkIdList(const vtkIdList&); // Not implemented.
122  void operator=(const vtkIdList&); // Not implemented.
123 };
124 
125 // In-lined for performance
127 {
128  if ( this->NumberOfIds >= this->Size )
129  {
130  this->Resize(this->NumberOfIds+1);
131  }
132  this->Ids[this->NumberOfIds++] = vtkid;
133  return this->NumberOfIds-1;
134 }
135 
137 {
138  vtkIdType *ptr, i;
139  for (ptr=this->Ids, i=0; i<this->NumberOfIds; i++, ptr++)
140  {
141  if ( vtkid == *ptr )
142  {
143  return i;
144  }
145  }
146  return (-1);
147 }
148 
149 #endif
vtkIdType Size
Definition: vtkIdList.h:116
abstract base class for most VTK objects
Definition: vtkObject.h:61
void Squeeze()
Definition: vtkIdList.h:88
vtkIdType * Ids
Definition: vtkIdList.h:117
void SetId(const vtkIdType i, const vtkIdType vtkid)
Definition: vtkIdList.h:62
void Reset()
Definition: vtkIdList.h:85
vtkIdType GetNumberOfIds()
Definition: vtkIdList.h:50
int vtkIdType
Definition: vtkType.h:268
vtkIdType NumberOfIds
Definition: vtkIdList.h:115
void IntersectWith(vtkIdList &otherIds)
Definition: vtkIdList.h:107
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:136
vtkIdType GetId(const vtkIdType i)
Definition: vtkIdList.h:53
static vtkObject * New()
vtkIdType InsertNextId(const vtkIdType vtkid)
Definition: vtkIdList.h:126
vtkIdType * GetPointer(const vtkIdType i)
Definition: vtkIdList.h:77
vtkIdType * Resize(const vtkIdType sz)