/usr/include/vtk-7.1/vtkCellArray.h is in libvtk7-dev 7.1.1+dfsg1-2.
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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkCellArray.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.
=========================================================================*/
/**
* @class vtkCellArray
* @brief object to represent cell connectivity
*
* vtkCellArray is a supporting object that explicitly represents cell
* connectivity. The cell array structure is a raw integer list
* of the form: (n,id1,id2,...,idn, n,id1,id2,...,idn, ...)
* where n is the number of points in the cell, and id is a zero-offset index
* into an associated point list.
*
* Advantages of this data structure are its compactness, simplicity, and
* easy interface to external data. However, it is totally inadequate for
* random access. This functionality (when necessary) is accomplished by
* using the vtkCellTypes and vtkCellLinks objects to extend the definition of
* the data structure.
*
* @sa
* vtkCellTypes vtkCellLinks
*/
#ifndef vtkCellArray_h
#define vtkCellArray_h
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkObject.h"
#include "vtkIdTypeArray.h" // Needed for inline methods
#include "vtkCell.h" // Needed for inline methods
class VTKCOMMONDATAMODEL_EXPORT vtkCellArray : public vtkObject
{
public:
vtkTypeMacro(vtkCellArray,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
/**
* Instantiate cell array (connectivity list).
*/
static vtkCellArray *New();
/**
* Allocate memory and set the size to extend by.
*/
int Allocate(const vtkIdType sz, const int ext=1000)
{return this->Ia->Allocate(sz,ext);}
/**
* Free any memory and reset to an empty state.
*/
void Initialize();
//@{
/**
* Get the number of cells in the array.
*/
vtkGetMacro(NumberOfCells, vtkIdType);
//@}
//@{
/**
* Set the number of cells in the array.
* DO NOT do any kind of allocation, advanced use only.
*/
vtkSetMacro(NumberOfCells, vtkIdType);
//@}
/**
* Utility routines help manage memory of cell array. EstimateSize()
* returns a value used to initialize and allocate memory for array based
* on number of cells and maximum number of points making up cell. If
* every cell is the same size (in terms of number of points), then the
* memory estimate is guaranteed exact. (If not exact, use Squeeze() to
* reclaim any extra memory.)
*/
vtkIdType EstimateSize(vtkIdType numCells, int maxPtsPerCell)
{return numCells*(1+maxPtsPerCell);}
/**
* A cell traversal methods that is more efficient than vtkDataSet traversal
* methods. InitTraversal() initializes the traversal of the list of cells.
*/
void InitTraversal() {this->TraversalLocation=0;};
/**
* A cell traversal methods that is more efficient than vtkDataSet traversal
* methods. GetNextCell() gets the next cell in the list. If end of list
* is encountered, 0 is returned. A value of 1 is returned whenever
* npts and pts have been updated without error.
*/
int GetNextCell(vtkIdType& npts, vtkIdType* &pts);
/**
* A cell traversal methods that is more efficient than vtkDataSet traversal
* methods. GetNextCell() gets the next cell in the list. If end of list
* is encountered, 0 is returned.
*/
int GetNextCell(vtkIdList *pts);
/**
* Get the size of the allocated connectivity array.
*/
vtkIdType GetSize()
{return this->Ia->GetSize();}
/**
* Get the total number of entries (i.e., data values) in the connectivity
* array. This may be much less than the allocated size (i.e., return value
* from GetSize().)
*/
vtkIdType GetNumberOfConnectivityEntries()
{return this->Ia->GetMaxId()+1;}
/**
* Internal method used to retrieve a cell given an offset into
* the internal array.
*/
void GetCell(vtkIdType loc, vtkIdType &npts, vtkIdType* &pts);
/**
* Internal method used to retrieve a cell given an offset into
* the internal array.
*/
void GetCell(vtkIdType loc, vtkIdList* pts);
/**
* Insert a cell object. Return the cell id of the cell.
*/
vtkIdType InsertNextCell(vtkCell *cell);
/**
* Create a cell by specifying the number of points and an array of point
* id's. Return the cell id of the cell.
*/
vtkIdType InsertNextCell(vtkIdType npts, const vtkIdType* pts);
/**
* Create a cell by specifying a list of point ids. Return the cell id of
* the cell.
*/
vtkIdType InsertNextCell(vtkIdList *pts);
/**
* Create cells by specifying count, and then adding points one at a time
* using method InsertCellPoint(). If you don't know the count initially,
* use the method UpdateCellCount() to complete the cell. Return the cell
* id of the cell.
*/
vtkIdType InsertNextCell(int npts);
/**
* Used in conjunction with InsertNextCell(int npts) to add another point
* to the list of cells.
*/
void InsertCellPoint(vtkIdType id);
/**
* Used in conjunction with InsertNextCell(int npts) and InsertCellPoint() to
* update the number of points defining the cell.
*/
void UpdateCellCount(int npts);
/**
* Computes the current insertion location within the internal array.
* Used in conjunction with GetCell(int loc,...).
*/
vtkIdType GetInsertLocation(int npts)
{return (this->InsertLocation - npts - 1);};
/**
* Get/Set the current traversal location.
*/
vtkIdType GetTraversalLocation()
{return this->TraversalLocation;}
void SetTraversalLocation(vtkIdType loc)
{this->TraversalLocation = loc;}
/**
* Computes the current traversal location within the internal array. Used
* in conjunction with GetCell(int loc,...).
*/
vtkIdType GetTraversalLocation(vtkIdType npts)
{return(this->TraversalLocation-npts-1);}
/**
* Special method inverts ordering of current cell. Must be called
* carefully or the cell topology may be corrupted.
*/
void ReverseCell(vtkIdType loc);
/**
* Replace the point ids of the cell with a different list of point ids.
* Calling this method does not mark the vtkCellArray as modified. This is
* the responsibility of the caller and may be done after multiple calls to
* ReplaceCell.
*/
void ReplaceCell(vtkIdType loc, int npts, const vtkIdType *pts);
/**
* Returns the size of the largest cell. The size is the number of points
* defining the cell.
*/
int GetMaxCellSize();
/**
* Get pointer to array of cell data.
*/
vtkIdType *GetPointer()
{return this->Ia->GetPointer(0);}
/**
* Get pointer to data array for purpose of direct writes of data. Size is the
* total storage consumed by the cell array. ncells is the number of cells
* represented in the array.
*/
vtkIdType *WritePointer(const vtkIdType ncells, const vtkIdType size);
/**
* Define multiple cells by providing a connectivity list. The list is in
* the form (npts,p0,p1,...p(npts-1), repeated for each cell). Be careful
* using this method because it discards the old cells, and anything
* referring these cells becomes invalid (for example, if BuildCells() has
* been called see vtkPolyData). The traversal location is reset to the
* beginning of the list; the insertion location is set to the end of the
* list.
*/
void SetCells(vtkIdType ncells, vtkIdTypeArray *cells);
/**
* Perform a deep copy (no reference counting) of the given cell array.
*/
void DeepCopy(vtkCellArray *ca);
/**
* Return the underlying data as a data array.
*/
vtkIdTypeArray* GetData()
{return this->Ia;}
/**
* Reuse list. Reset to initial condition.
*/
void Reset();
/**
* Reclaim any extra memory.
*/
void Squeeze()
{this->Ia->Squeeze();}
/**
* Return the memory in kibibytes (1024 bytes) consumed by this cell array. Used to
* support streaming and reading/writing data. The value returned is
* guaranteed to be greater than or equal to the memory required to
* actually represent the data represented by this object. The
* information returned is valid only after the pipeline has
* been updated.
*/
unsigned long GetActualMemorySize();
protected:
vtkCellArray();
~vtkCellArray() VTK_OVERRIDE;
vtkIdType NumberOfCells;
vtkIdType InsertLocation; //keep track of current insertion point
vtkIdType TraversalLocation; //keep track of traversal position
vtkIdTypeArray *Ia;
private:
vtkCellArray(const vtkCellArray&) VTK_DELETE_FUNCTION;
void operator=(const vtkCellArray&) VTK_DELETE_FUNCTION;
};
//----------------------------------------------------------------------------
inline vtkIdType vtkCellArray::InsertNextCell(vtkIdType npts,
const vtkIdType* pts)
{
vtkIdType i = this->Ia->GetMaxId() + 1;
vtkIdType *ptr = this->Ia->WritePointer(i, npts+1);
for ( *ptr++ = npts, i = 0; i < npts; i++)
{
*ptr++ = *pts++;
}
this->NumberOfCells++;
this->InsertLocation += npts + 1;
return this->NumberOfCells - 1;
}
//----------------------------------------------------------------------------
inline vtkIdType vtkCellArray::InsertNextCell(int npts)
{
this->InsertLocation = this->Ia->InsertNextValue(npts) + 1;
this->NumberOfCells++;
return this->NumberOfCells - 1;
}
//----------------------------------------------------------------------------
inline void vtkCellArray::InsertCellPoint(vtkIdType id)
{
this->Ia->InsertValue(this->InsertLocation++, id);
}
//----------------------------------------------------------------------------
inline void vtkCellArray::UpdateCellCount(int npts)
{
this->Ia->SetValue(this->InsertLocation-npts-1, npts);
}
//----------------------------------------------------------------------------
inline vtkIdType vtkCellArray::InsertNextCell(vtkIdList *pts)
{
return this->InsertNextCell(pts->GetNumberOfIds(), pts->GetPointer(0));
}
//----------------------------------------------------------------------------
inline vtkIdType vtkCellArray::InsertNextCell(vtkCell *cell)
{
return this->InsertNextCell(cell->GetNumberOfPoints(),
cell->PointIds->GetPointer(0));
}
//----------------------------------------------------------------------------
inline void vtkCellArray::Reset()
{
this->NumberOfCells = 0;
this->InsertLocation = 0;
this->TraversalLocation = 0;
this->Ia->Reset();
}
//----------------------------------------------------------------------------
inline int vtkCellArray::GetNextCell(vtkIdType& npts, vtkIdType* &pts)
{
if ( this->Ia->GetMaxId() >= 0 &&
this->TraversalLocation <= this->Ia->GetMaxId() )
{
npts = this->Ia->GetValue(this->TraversalLocation++);
pts = this->Ia->GetPointer(this->TraversalLocation);
this->TraversalLocation += npts;
return 1;
}
npts=0;
pts=0;
return 0;
}
//----------------------------------------------------------------------------
inline void vtkCellArray::GetCell(vtkIdType loc, vtkIdType &npts,
vtkIdType* &pts)
{
npts = this->Ia->GetValue(loc++);
pts = this->Ia->GetPointer(loc);
}
//----------------------------------------------------------------------------
inline void vtkCellArray::ReverseCell(vtkIdType loc)
{
int i;
vtkIdType tmp;
vtkIdType npts=this->Ia->GetValue(loc);
vtkIdType *pts=this->Ia->GetPointer(loc+1);
for (i=0; i < (npts/2); i++)
{
tmp = pts[i];
pts[i] = pts[npts-i-1];
pts[npts-i-1] = tmp;
}
}
//----------------------------------------------------------------------------
inline void vtkCellArray::ReplaceCell(vtkIdType loc, int npts,
const vtkIdType *pts)
{
vtkIdType *oldPts=this->Ia->GetPointer(loc+1);
for (int i=0; i < npts; i++)
{
oldPts[i] = pts[i];
}
}
//----------------------------------------------------------------------------
inline vtkIdType *vtkCellArray::WritePointer(const vtkIdType ncells,
const vtkIdType size)
{
this->NumberOfCells = ncells;
this->InsertLocation = 0;
this->TraversalLocation = 0;
return this->Ia->WritePointer(0,size);
}
#endif
|