57 The example above pulls in bits of information as needed to filter out cells
58 that aren
't relevent. The least expensive lookups are performed first
59 (cell type, then point ids, then points/full cell) to prevent wasted cycles
60 fetching unnecessary data. Also note that at the end of the loop, the
61 iterator must be deleted as these iterators are vtkObject subclasses.
64 @ref c2_vtk_t_vtkCellIterator "vtkCellIterator (Tests)"
67 #ifndef vtkCellIterator_h
68 #define vtkCellIterator_h
70 #include "vtkCommonDataModelModule.h" // For export macro
71 #include "vtkObject.h"
72 #include "vtkNew.h" // For vtkNew
73 #include "vtkIdList.h" // For inline methods
78 class VTKCOMMONDATAMODEL_EXPORT vtkCellIterator : public vtkObject
81 virtual void PrintSelf(ostream &os, vtkIndent indent);
82 vtkAbstractTypeMacro(vtkCellIterator, vtkObject)
91 virtual bool IsDoneWithTraversal() = 0;
99 virtual vtkIdType GetCellId() = 0;
103 vtkIdList *GetPointIds();
108 vtkPoints *GetPoints();
111 vtkIdList *GetFaces();
116 void GetCell(vtkGenericCell *cell);
120 vtkIdType GetNumberOfPoints();
124 vtkIdType GetNumberOfFaces();
131 virtual void ResetToFirstCell() = 0;
134 virtual void IncrementToNextCell() = 0;
137 virtual void FetchCellType() = 0;
141 virtual void FetchPointIds() = 0;
145 virtual void FetchPoints() = 0;
151 virtual void FetchFaces() { }
159 vtkCellIterator(const vtkCellIterator &); // Not implemented.
160 void operator=(const vtkCellIterator &); // Not implemented.
164 UninitializedFlag = 0x0,
173 this->CacheFlags = UninitializedFlag;
174 this->ResetContainers();
177 void SetCache(unsigned char flags)
179 this->CacheFlags |= flags;
182 bool CheckCache(unsigned char flags)
184 return (this->CacheFlags & flags) == flags;
187 void ResetContainers();
189 vtkNew<vtkPoints> PointsContainer;
190 vtkNew<vtkIdList> PointIdsContainer;
191 vtkNew<vtkIdList> FacesContainer;
192 unsigned char CacheFlags;
195 //------------------------------------------------------------------------------
196 inline void vtkCellIterator::InitTraversal()
198 this->ResetToFirstCell();
202 //------------------------------------------------------------------------------
203 inline void vtkCellIterator::GoToNextCell()
205 this->IncrementToNextCell();
209 //------------------------------------------------------------------------------
210 inline int vtkCellIterator::GetCellType()
212 if (!this->CheckCache(CellTypeFlag))
214 this->FetchCellType();
215 this->SetCache(CellTypeFlag);
217 return this->CellType;
220 //------------------------------------------------------------------------------
221 inline vtkIdList* vtkCellIterator::GetPointIds()
223 if (!this->CheckCache(PointIdsFlag))
225 this->FetchPointIds();
226 this->SetCache(PointIdsFlag);
228 return this->PointIds;
231 //------------------------------------------------------------------------------
232 inline vtkPoints* vtkCellIterator::GetPoints()
234 if (!this->CheckCache(PointsFlag))
237 this->SetCache(PointsFlag);
242 //------------------------------------------------------------------------------
243 inline vtkIdList *vtkCellIterator::GetFaces()
245 if (!this->CheckCache(FacesFlag))
248 this->SetCache(FacesFlag);
253 //------------------------------------------------------------------------------
254 inline vtkIdType vtkCellIterator::GetNumberOfPoints()
256 if (!this->CheckCache(PointIdsFlag))
258 this->FetchPointIds();
259 this->SetCache(PointIdsFlag);
261 return this->PointIds->GetNumberOfIds();
264 //------------------------------------------------------------------------------
265 inline vtkIdType vtkCellIterator::GetNumberOfFaces()
267 if (!this->CheckCache(FacesFlag))
270 this->SetCache(FacesFlag);
272 return this->Faces->GetNumberOfIds() != 0 ? this->Faces->GetId(0) : 0;
275 #endif //vtkCellIterator_h
provides thread-safe access to cells
list of point or cell ids
represent and manipulate 3D points