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 "vtkObject.h"
33 
35 {
36 public:
37  static vtkIdList *New();
38 
39  void Initialize();
40  int Allocate(const vtkIdType sz, const int strategy=0);
41  vtkTypeMacro(vtkIdList,vtkObject);
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
45  vtkIdType GetNumberOfIds() {return this->NumberOfIds;};
46 
48  vtkIdType GetId(const vtkIdType i) {return this->Ids[i];};
49 
52  void SetNumberOfIds(const vtkIdType number);
53 
57  void SetId(const vtkIdType i, const vtkIdType vtkid) {this->Ids[i] = vtkid;};
58 
61  void InsertId(const vtkIdType i, const vtkIdType vtkid);
62 
65  vtkIdType InsertNextId(const vtkIdType vtkid);
66 
69  vtkIdType InsertUniqueId(const vtkIdType vtkid);
70 
72  vtkIdType *GetPointer(const vtkIdType i) {return this->Ids + i;};
73 
77  vtkIdType *WritePointer(const vtkIdType i, const vtkIdType number);
78 
80  void Reset() {this->NumberOfIds = 0;};
81 
83  void Squeeze() {this->Resize(this->NumberOfIds);};
84 
86  void DeepCopy(vtkIdList *ids);
87 
90  void DeleteId(vtkIdType vtkid);
91 
94  vtkIdType IsId(vtkIdType vtkid);
95 
98  void IntersectWith(vtkIdList* otherIds);
99 
100  //BTX
101  // This method should become legacy
102  void IntersectWith(vtkIdList& otherIds) {
103  return this->IntersectWith(&otherIds); };
104  //ETX
105 
106 protected:
107  vtkIdList();
108  ~vtkIdList();
109 
113 
114  vtkIdType *Resize(const vtkIdType sz);
115 private:
116  vtkIdList(const vtkIdList&); // Not implemented.
117  void operator=(const vtkIdList&); // Not implemented.
118 };
119 
120 // In-lined for performance
122 {
123  if ( this->NumberOfIds >= this->Size )
124  {
125  this->Resize(this->NumberOfIds+1);
126  }
127  this->Ids[this->NumberOfIds++] = vtkid;
128  return this->NumberOfIds-1;
129 }
130 
132 {
133  vtkIdType *ptr, i;
134  for (ptr=this->Ids, i=0; i<this->NumberOfIds; i++, ptr++)
135  {
136  if ( vtkid == *ptr )
137  {
138  return i;
139  }
140  }
141  return (-1);
142 }
143 
144 #endif
vtkIdType Size
Definition: vtkIdList.h:111
abstract base class for most VTK objects
Definition: vtkObject.h:60
void Squeeze()
Definition: vtkIdList.h:83
vtkIdType * Ids
Definition: vtkIdList.h:112
void SetId(const vtkIdType i, const vtkIdType vtkid)
Definition: vtkIdList.h:57
void Reset()
Definition: vtkIdList.h:80
vtkIdType GetNumberOfIds()
Definition: vtkIdList.h:45
int vtkIdType
Definition: vtkType.h:255
vtkIdType NumberOfIds
Definition: vtkIdList.h:110
void IntersectWith(vtkIdList &otherIds)
Definition: vtkIdList.h:102
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
list of point or cell ids
Definition: vtkIdList.h:34
#define VTK_COMMON_EXPORT
vtkIdType IsId(vtkIdType vtkid)
Definition: vtkIdList.h:131
vtkIdType GetId(const vtkIdType i)
Definition: vtkIdList.h:48
static vtkObject * New()
vtkIdType InsertNextId(const vtkIdType vtkid)
Definition: vtkIdList.h:121
vtkIdType * GetPointer(const vtkIdType i)
Definition: vtkIdList.h:72
vtkIdType * Resize(const vtkIdType sz)