/usr/include/vtk-6.3/vtkCellIterator.h is in libvtk6-dev 6.3.0+dfsg1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkCellIterator.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkCellIterator - Efficient cell iterator for vtkDataSet topologies.
//
// .SECTION Description
// vtkCellIterator provides a method for traversing cells in a data set. Call
// the vtkDataSet::NewCellIterator() method to use this class.
//
// The cell is represented as a set of three pieces of information: The cell
// type, the ids of the points constituting the cell, and the points themselves.
// This iterator fetches these as needed. If only the cell type is used,
// the type is not looked up until GetCellType is called, and the point
// information is left uninitialized. This allows efficient screening of cells,
// since expensive point lookups may be skipped depending on the cell type/etc.
//
// An example usage of this class:
// ~~~
// void myWorkerFunction(vtkDataSet *ds)
// {
// vtkCellIterator *it = ds->NewCellIterator();
// for (it->InitTraversal(); it->IsDoneWithTraversal(); it->GoToNextCell())
// {
// if (it->GetCellType() != VTK_TETRA)
// {
// continue; /* Skip non-tetrahedral cells */
// }
//
// vtkIdList *pointIds = it->GetPointIds();
// /* Do screening on the point ids, maybe figure out scalar range and skip
// cells that do not lie in a certain range? */
//
// vtkPoints *points = it->GetPoints();
// /* Do work using the cell points, or ... */
//
// vtkGenericCell *cell = ...;
// it->GetCell(cell);
// /* ... do work with a vtkCell. */
// }
// it->Delete();
// }
// ~~~
//
// The example above pulls in bits of information as needed to filter out cells
// that aren't relevent. The least expensive lookups are performed first
// (cell type, then point ids, then points/full cell) to prevent wasted cycles
// fetching unnecessary data. Also note that at the end of the loop, the
// iterator must be deleted as these iterators are vtkObject subclasses.
#ifndef vtkCellIterator_h
#define vtkCellIterator_h
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkObject.h"
#include "vtkNew.h" // For vtkNew
#include "vtkIdList.h" // For inline methods
class vtkGenericCell;
class vtkPoints;
class VTKCOMMONDATAMODEL_EXPORT vtkCellIterator : public vtkObject
{
public:
virtual void PrintSelf(ostream &os, vtkIndent indent);
vtkAbstractTypeMacro(vtkCellIterator, vtkObject)
// Description:
// Reset to the first cell.
void InitTraversal();
// Description:
// Increment to next cell. Always safe to call.
void GoToNextCell();
// Description:
// Returns false while the iterator is valid. Always safe to call.
virtual bool IsDoneWithTraversal() = 0;
// Description:
// Get the current cell type (e.g. VTK_LINE, VTK_VERTEX, VTK_TETRA, etc).
// This should only be called when IsDoneWithTraversal() returns false.
int GetCellType();
// Description:
// Get the id of the current cell.
virtual vtkIdType GetCellId() = 0;
// Description:
// Get the ids of the points in the current cell.
// This should only be called when IsDoneWithTraversal() returns false.
vtkIdList *GetPointIds();
// Description:
// Get the points in the current cell.
// This is usually a very expensive call, and should be avoided when possible.
// This should only be called when IsDoneWithTraversal() returns false.
vtkPoints *GetPoints();
// Description:
// Get the faces for a polyhedral cell.
vtkIdList *GetFaces();
// Description:
// Write the current full cell information into the argument.
// This is usually a very expensive call, and should be avoided when possible.
// This should only be called when IsDoneWithTraversal() returns false.
void GetCell(vtkGenericCell *cell);
// Description:
// Return the number of points in the current cell.
// This should only be called when IsDoneWithTraversal() returns false.
vtkIdType GetNumberOfPoints();
// Description:
// Return the number of faces in the current polyhedral cell.
// This should only be called when IsDoneWithTraversal() returns false.
vtkIdType GetNumberOfFaces();
protected:
vtkCellIterator();
~vtkCellIterator();
// Description:
// Update internal state to point to the first cell.
virtual void ResetToFirstCell() = 0;
// Description:
// Update internal state to point to the next cell.
virtual void IncrementToNextCell() = 0;
// Description:
// Lookup the cell type in the data set and store it in this->CellType.
virtual void FetchCellType() = 0;
// Description:
// Lookup the cell point ids in the data set and store them in this->PointIds.
virtual void FetchPointIds() = 0;
// Description:
// Lookup the cell points in the data set and store them in this->Points.
virtual void FetchPoints() = 0;
// Description:
// Lookup the cell faces in the data set and store them in this->Points.
// Few data sets support faces, so this method has a no-op default
// implementation. See vtkUnstructuredGrid::GetFaceStream for
// a description of the layout that Faces should have.
virtual void FetchFaces() { }
int CellType;
vtkPoints *Points;
vtkIdList *PointIds;
vtkIdList *Faces;
private:
vtkCellIterator(const vtkCellIterator &); // Not implemented.
void operator=(const vtkCellIterator &); // Not implemented.
enum
{
UninitializedFlag = 0x0,
CellTypeFlag = 0x1,
PointIdsFlag = 0x2,
PointsFlag = 0x4,
FacesFlag = 0x8
};
void ResetCache()
{
this->CacheFlags = UninitializedFlag;
this->ResetContainers();
}
void SetCache(unsigned char flags)
{
this->CacheFlags |= flags;
}
bool CheckCache(unsigned char flags)
{
return (this->CacheFlags & flags) == flags;
}
void ResetContainers();
vtkNew<vtkPoints> PointsContainer;
vtkNew<vtkIdList> PointIdsContainer;
vtkNew<vtkIdList> FacesContainer;
unsigned char CacheFlags;
};
//------------------------------------------------------------------------------
inline void vtkCellIterator::InitTraversal()
{
this->ResetToFirstCell();
this->ResetCache();
}
//------------------------------------------------------------------------------
inline void vtkCellIterator::GoToNextCell()
{
this->IncrementToNextCell();
this->ResetCache();
}
//------------------------------------------------------------------------------
inline int vtkCellIterator::GetCellType()
{
if (!this->CheckCache(CellTypeFlag))
{
this->FetchCellType();
this->SetCache(CellTypeFlag);
}
return this->CellType;
}
//------------------------------------------------------------------------------
inline vtkIdList* vtkCellIterator::GetPointIds()
{
if (!this->CheckCache(PointIdsFlag))
{
this->FetchPointIds();
this->SetCache(PointIdsFlag);
}
return this->PointIds;
}
//------------------------------------------------------------------------------
inline vtkPoints* vtkCellIterator::GetPoints()
{
if (!this->CheckCache(PointsFlag))
{
this->FetchPoints();
this->SetCache(PointsFlag);
}
return this->Points;
}
//------------------------------------------------------------------------------
inline vtkIdList *vtkCellIterator::GetFaces()
{
if (!this->CheckCache(FacesFlag))
{
this->FetchFaces();
this->SetCache(FacesFlag);
}
return this->Faces;
}
//------------------------------------------------------------------------------
inline vtkIdType vtkCellIterator::GetNumberOfPoints()
{
if (!this->CheckCache(PointIdsFlag))
{
this->FetchPointIds();
this->SetCache(PointIdsFlag);
}
return this->PointIds->GetNumberOfIds();
}
//------------------------------------------------------------------------------
inline vtkIdType vtkCellIterator::GetNumberOfFaces()
{
if (!this->CheckCache(FacesFlag))
{
this->FetchFaces();
this->SetCache(FacesFlag);
}
return this->Faces->GetNumberOfIds() != 0 ? this->Faces->GetId(0) : 0;
}
#endif //vtkCellIterator_h
|