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 "vtkCellType.h" // For VTK_EMPTY_CELL
72 #include "vtkObject.h"
73 #include "vtkNew.h" // For vtkNew
74 #include "vtkIdList.h" // For inline methods
79 class VTKCOMMONDATAMODEL_EXPORT vtkCellIterator : public vtkObject
82 virtual void PrintSelf(ostream &os, vtkIndent indent);
83 vtkAbstractTypeMacro(vtkCellIterator, vtkObject)
92 virtual bool IsDoneWithTraversal() = 0;
100 virtual vtkIdType GetCellId() = 0;
104 vtkIdList *GetPointIds();
109 vtkPoints *GetPoints();
112 vtkIdList *GetFaces();
117 void GetCell(vtkGenericCell *cell);
121 vtkIdType GetNumberOfPoints();
125 vtkIdType GetNumberOfFaces();
132 virtual void ResetToFirstCell() = 0;
135 virtual void IncrementToNextCell() = 0;
138 virtual void FetchCellType() = 0;
142 virtual void FetchPointIds() = 0;
146 virtual void FetchPoints() = 0;
152 virtual void FetchFaces() { }
160 vtkCellIterator(const vtkCellIterator &); // Not implemented.
161 void operator=(const vtkCellIterator &); // Not implemented.
165 UninitializedFlag = 0x0,
174 this->CacheFlags = UninitializedFlag;
175 this->CellType = VTK_EMPTY_CELL;
178 void SetCache(unsigned char flags)
180 this->CacheFlags |= flags;
183 bool CheckCache(unsigned char flags)
185 return (this->CacheFlags & flags) == flags;
188 vtkNew<vtkPoints> PointsContainer;
189 vtkNew<vtkIdList> PointIdsContainer;
190 vtkNew<vtkIdList> FacesContainer;
191 unsigned char CacheFlags;
194 //------------------------------------------------------------------------------
195 inline void vtkCellIterator::InitTraversal()
197 this->ResetToFirstCell();
201 //------------------------------------------------------------------------------
202 inline void vtkCellIterator::GoToNextCell()
204 this->IncrementToNextCell();
208 //------------------------------------------------------------------------------
209 inline int vtkCellIterator::GetCellType()
211 if (!this->CheckCache(CellTypeFlag))
213 this->FetchCellType();
214 this->SetCache(CellTypeFlag);
216 return this->CellType;
219 //------------------------------------------------------------------------------
220 inline vtkIdList* vtkCellIterator::GetPointIds()
222 if (!this->CheckCache(PointIdsFlag))
224 this->FetchPointIds();
225 this->SetCache(PointIdsFlag);
227 return this->PointIds;
230 //------------------------------------------------------------------------------
231 inline vtkPoints* vtkCellIterator::GetPoints()
233 if (!this->CheckCache(PointsFlag))
236 this->SetCache(PointsFlag);
241 //------------------------------------------------------------------------------
242 inline vtkIdList *vtkCellIterator::GetFaces()
244 if (!this->CheckCache(FacesFlag))
247 this->SetCache(FacesFlag);
252 //------------------------------------------------------------------------------
253 inline vtkIdType vtkCellIterator::GetNumberOfPoints()
255 if (!this->CheckCache(PointIdsFlag))
257 this->FetchPointIds();
258 this->SetCache(PointIdsFlag);
260 return this->PointIds->GetNumberOfIds();
263 //------------------------------------------------------------------------------
264 inline vtkIdType vtkCellIterator::GetNumberOfFaces()
266 if (!this->CheckCache(FacesFlag))
269 this->SetCache(FacesFlag);
271 return this->Faces->GetNumberOfIds() != 0 ? this->Faces->GetId(0) : 0;
274 #endif //vtkCellIterator_h
provides thread-safe access to cells
list of point or cell ids
represent and manipulate 3D points