VTK: vtkCellArray Class Reference

| VTK 9.3.1

Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
vtkCellArray Class Reference

object to represent cell connectivity More...

`#include <vtkCellArray.h>`

Inheritance diagram for vtkCellArray:
[legend]
Collaboration diagram for vtkCellArray:
[legend]

## Classes
struct | Storage
struct | VisitState

## Public Types
using | ArrayType32 = vtkTypeInt32Array
using | ArrayType64 = vtkTypeInt64Array
using | StorageArrayList = vtkTypeList::Create< ArrayType32, ArrayType64 >
| List of possible array types used for storage. More...
using | InputArrayList = typename vtkTypeList::Unique< vtkTypeList::Create< vtkAOSDataArrayTemplate< int >, vtkAOSDataArrayTemplate< long >, vtkAOSDataArrayTemplate< long long > >>::Result
| List of possible ArrayTypes that are compatible with internal storage. More...

## Public Member Functions
vtkTypeBool | Allocate (vtkIdType sz, vtkIdType vtkNotUsed(ext)=1000)
| Allocate memory. More...
bool | AllocateEstimate (vtkIdType numCells, vtkIdType maxCellSize)
| Pre-allocate memory in internal data structures. More...
bool | AllocateExact (vtkIdType numCells, vtkIdType connectivitySize)
| Pre-allocate memory in internal data structures. More...
bool | AllocateCopy (vtkCellArray *other)
| Pre-allocate memory in internal data structures to match the used size of the input vtkCellArray. More...
bool | ResizeExact (vtkIdType numCells, vtkIdType connectivitySize)
| ResizeExact() resizes the internal structures to hold numCells total cell offsets and connectivitySize total pointIds. More...
void | Initialize ()
| Free any memory and reset to an empty state. More...
void | Reset ()
| Reuse list. More...
void | Squeeze ()
| Reclaim any extra memory while preserving data. More...
bool | IsValid ()
| Check that internal storage is consistent and in a valid state. More...
vtkIdType | GetNumberOfCells () const
| Get the number of cells in the array. More...
vtkIdType | GetNumberOfOffsets () const
| Get the number of elements in the offsets array. More...
vtkIdType | GetOffset (vtkIdType cellId)
| Get the offset (into the connectivity) for a specified cell id. More...
vtkIdType | GetNumberOfConnectivityIds () const
| Get the size of the connectivity array that stores the point ids. More...
vtkCellArrayIterator * | NewIterator ()
| NewIterator returns a new instance of vtkCellArrayIterator that is initialized to point at the first cell's data. More...
bool | SetData (vtkDataArray *offsets, vtkDataArray *connectivity)
| Sets the internal arrays to the supplied offsets and connectivity arrays. More...
bool | SetData (vtkIdType cellSize, vtkDataArray *connectivity)
| Sets the internal arrays to the supported connectivity array with an offsets array automatically generated given the fixed cells size. More...
bool | IsStorage64Bit () const
bool | IsStorageShareable () const
vtkIdType | IsHomogeneous ()
| Check if all cells have the same number of vertices. More...
void | InitTraversal ()
int | GetNextCell (vtkIdType &npts, vtkIdType const *&pts)
int | GetNextCell (vtkIdList *pts)
void | GetCellAtId (vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints)
| Return the point ids for the cell at cellId. More...
void | GetCellAtId (vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *ptIds)
| Return the point ids for the cell at cellId. More...
void | GetCellAtId (vtkIdType cellId, vtkIdList *pts)
| Return the point ids for the cell at cellId. More...
vtkIdType | GetCellSize (vtkIdType cellId) const
| Return the size of the cell at cellId. More...
vtkIdType | InsertNextCell (vtkCell *cell)
| Insert a cell object. More...
vtkIdType | InsertNextCell (vtkIdType npts, const vtkIdType *pts)
| Create a cell by specifying the number of points and an array of point id's. More...
vtkIdType | InsertNextCell (vtkIdList *pts)
| Create a cell by specifying a list of point ids. More...
vtkIdType | InsertNextCell (const std::initializer_list< vtkIdType > &cell)
| Overload that allows `InsertNextCell({0, 1, 2})` syntax. More...
vtkIdType | InsertNextCell (int npts)
| Create cells by specifying a count of total points to be inserted, and then adding points one at a time using method InsertCellPoint(). More...
void | InsertCellPoint (vtkIdType id)
| Used in conjunction with InsertNextCell(npts) to add another point to the list of cells. More...
void | UpdateCellCount (int npts)
| Used in conjunction with InsertNextCell(int npts) and InsertCellPoint() to update the number of points defining the cell. More...
void | ReverseCellAtId (vtkIdType cellId)
| Reverses the order of the point ids for the specified cell. More...
void | ReplaceCellPointAtId (vtkIdType cellId, vtkIdType cellPointIndex, vtkIdType newPointId)
| Replaces the pointId at cellPointIndex of a cell with newPointId. More...
void | ReplaceCellAtId (vtkIdType cellId, const std::initializer_list< vtkIdType > &cell)
| Overload that allows `ReplaceCellAtId(cellId, {0, 1, 2})` syntax. More...
int | GetMaxCellSize ()
| Returns the size of the largest cell. More...
void | DeepCopy (vtkCellArray *ca)
| Perform a deep copy (no reference counting) of the given cell array. More...
void | ShallowCopy (vtkCellArray *ca)
| Shallow copy ca into this cell array. More...
void | Append (vtkCellArray *src, vtkIdType pointOffset=0)
| Append cells from src into this. More...
void | ExportLegacyFormat (vtkIdTypeArray *data)
| Fill data with the old-style vtkCellArray data layout, e.g. More...
unsigned long | GetActualMemorySize () const
| Return the memory in kibibytes (1024 bytes) consumed by this cell array. More...
virtual void | SetNumberOfCells (vtkIdType)
| Set the number of cells in the array. More...
vtkIdType | EstimateSize (vtkIdType numCells, int maxPtsPerCell)
| Utility routines help manage memory of cell array. More...
vtkIdType | GetSize ()
| Get the size of the allocated connectivity array. More...
vtkIdType | GetNumberOfConnectivityEntries ()
| Return the size of the array that would be returned from ExportLegacyFormat(). More...
void | GetCell (vtkIdType loc, vtkIdType &npts, const vtkIdType *&pts)
| Internal method used to retrieve a cell given a legacy offset location. More...
void | GetCell (vtkIdType loc, vtkIdList *pts)
| Internal method used to retrieve a cell given a legacy offset location. More...
vtkIdType | GetInsertLocation (int npts)
| Computes the current legacy insertion location within the internal array. More...
void | ReverseCell (vtkIdType loc)
| Special method inverts ordering of cell at the specified legacy location. More...
void | ReplaceCell (vtkIdType loc, int npts, const vtkIdType pts[])
| Replace the point ids of the cell at the legacy location with a different list of point ids. More...
void | SetCells (vtkIdType ncells, vtkIdTypeArray *cells)
| Define multiple cells by providing a connectivity list. More...
vtkIdTypeArray * | GetData ()
| Return the underlying data as a data array. More...
void | SetData (vtkIdTypeArray *offsets, vtkIdTypeArray *connectivity)
| Set the internal data arrays to the supplied offsets and connectivity arrays. More...
void | SetData (vtkAOSDataArrayTemplate< int > *offsets, vtkAOSDataArrayTemplate< int > *connectivity)
| Set the internal data arrays to the supplied offsets and connectivity arrays. More...
void | SetData (vtkAOSDataArrayTemplate< long > *offsets, vtkAOSDataArrayTemplate< long > *connectivity)
| Set the internal data arrays to the supplied offsets and connectivity arrays. More...
void | SetData (vtkAOSDataArrayTemplate< long long > *offsets, vtkAOSDataArrayTemplate< long long > *connectivity)
| Set the internal data arrays to the supplied offsets and connectivity arrays. More...
void | SetData (vtkTypeInt32Array *offsets, vtkTypeInt32Array *connectivity)
| Set the internal data arrays to the supplied offsets and connectivity arrays. More...
void | SetData (vtkTypeInt64Array *offsets, vtkTypeInt64Array *connectivity)
| Set the internal data arrays to the supplied offsets and connectivity arrays. More...
void | Use32BitStorage ()
| Initialize internal data structures to use 32- or 64-bit storage. More...
void | Use64BitStorage ()
| Initialize internal data structures to use 32- or 64-bit storage. More...
void | UseDefaultStorage ()
| Initialize internal data structures to use 32- or 64-bit storage. More...
bool | CanConvertTo32BitStorage () const
| Check if the existing data can safely be converted to use 32- or 64- bit storage. More...
bool | CanConvertTo64BitStorage () const
| Check if the existing data can safely be converted to use 32- or 64- bit storage. More...
bool | CanConvertToDefaultStorage () const
| Check if the existing data can safely be converted to use 32- or 64- bit storage. More...
bool | ConvertTo32BitStorage ()
| Convert internal data structures to use 32- or 64-bit storage. More...
bool | ConvertTo64BitStorage ()
| Convert internal data structures to use 32- or 64-bit storage. More...
bool | ConvertToDefaultStorage ()
| Convert internal data structures to use 32- or 64-bit storage. More...
bool | ConvertToSmallestStorage ()
| Convert internal data structures to use 32- or 64-bit storage. More...
vtkDataArray * | GetOffsetsArray ()
| Return the array used to store cell offsets. More...
ArrayType32 * | GetOffsetsArray32 ()
| Return the array used to store cell offsets. More...
ArrayType64 * | GetOffsetsArray64 ()
| Return the array used to store cell offsets. More...
vtkDataArray * | GetConnectivityArray ()
| Return the array used to store the point ids that define the cells' connectivity. More...
ArrayType32 * | GetConnectivityArray32 ()
| Return the array used to store the point ids that define the cells' connectivity. More...
ArrayType64 * | GetConnectivityArray64 ()
| Return the array used to store the point ids that define the cells' connectivity. More...
vtkIdType | GetTraversalCellId ()
| Get/Set the current cellId for traversal. More...
void | SetTraversalCellId (vtkIdType cellId)
| Get/Set the current cellId for traversal. More...
void | ReplaceCellAtId (vtkIdType cellId, vtkIdList *list)
| Replaces the point ids for the specified cell with the supplied list. More...
void | ReplaceCellAtId (vtkIdType cellId, vtkIdType cellSize, const vtkIdType *cellPoints)
| Replaces the point ids for the specified cell with the supplied list. More...
void | ImportLegacyFormat (vtkIdTypeArray *data)
| Import an array of data with the legacy vtkCellArray layout, e.g. More...
void | ImportLegacyFormat (const vtkIdType *data, vtkIdType len)
| Import an array of data with the legacy vtkCellArray layout, e.g. More...
void | AppendLegacyFormat (vtkIdTypeArray *data, vtkIdType ptOffset=0)
| Append an array of data with the legacy vtkCellArray layout, e.g. More...
void | AppendLegacyFormat (const vtkIdType *data, vtkIdType len, vtkIdType ptOffset=0)
| Append an array of data with the legacy vtkCellArray layout, e.g. More...
template<typename Functor , typename... Args, typename = typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>
void | Visit (Functor &&functor, Args &&... args)
template<typename Functor , typename... Args, typename = typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>
void | Visit (Functor &&functor, Args &&... args) const
template<typename Functor , typename... Args, typename = typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>
GetReturnType< Functor, Args... > | Visit (Functor &&functor, Args &&... args)
template<typename Functor , typename... Args, typename = typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>
GetReturnType< Functor, Args... > | Visit (Functor &&functor, Args &&... args) const
vtkIdType | GetTraversalLocation ()
| Get/Set the current traversal legacy location. More...
vtkIdType | GetTraversalLocation (vtkIdType npts)
| Get/Set the current traversal legacy location. More...
void | SetTraversalLocation (vtkIdType loc)
| Get/Set the current traversal legacy location. More...
Public Member Functions inherited from vtkObject
| vtkBaseTypeMacro (vtkObject, vtkObjectBase)
virtual void | DebugOn ()
| Turn debugging output on. More...
virtual void | DebugOff ()
| Turn debugging output off. More...
bool | GetDebug ()
| Get the value of the debug flag. More...
void | SetDebug (bool debugFlag)
| Set the value of the debug flag. More...
virtual void | Modified ()
| Update the modification time for this object. More...
virtual vtkMTimeType | GetMTime ()
| Return this object's modified time. More...
void | RemoveObserver (unsigned long tag)
void | RemoveObservers (unsigned long event)
void | RemoveObservers (const char *event)
void | RemoveAllObservers ()
vtkTypeBool | HasObserver (unsigned long event)
vtkTypeBool | HasObserver (const char *event)
vtkTypeBool | InvokeEvent (unsigned long event)
vtkTypeBool | InvokeEvent (const char *event)
std::string | GetObjectDescription () const override
| The object description printed in messages and PrintSelf output. More...
unsigned long | AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
unsigned long | AddObserver (const char *event, vtkCommand *, float priority=0.0f)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
vtkCommand * | GetCommand (unsigned long tag)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
void | RemoveObserver (vtkCommand *)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
void | RemoveObservers (unsigned long event, vtkCommand *)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
void | RemoveObservers (const char *event, vtkCommand *)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
vtkTypeBool | HasObserver (unsigned long event, vtkCommand *)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
vtkTypeBool | HasObserver (const char *event, vtkCommand *)
| Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
template<class U , class T >
unsigned long | AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
| Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
template<class U , class T >
unsigned long | AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
| Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
template<class U , class T >
unsigned long | AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
| Allow user to set the AbortFlagOn() with the return value of the callback method. More...
vtkTypeBool | InvokeEvent (unsigned long event, void *callData)
| This method invokes an event and return whether the event was aborted or not. More...
vtkTypeBool | InvokeEvent (const char *event, void *callData)
| This method invokes an event and return whether the event was aborted or not. More...
virtual void | SetObjectName (const std::string &objectName)
| Set/get the name of this object for reporting purposes. More...
virtual std::string | GetObjectName () const
| Set/get the name of this object for reporting purposes. More...
Public Member Functions inherited from vtkObjectBase
const char * | GetClassName () const
| Return the class name as a string. More...
virtual vtkIdType | GetNumberOfGenerationsFromBase (const char *name)
| Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
virtual void | Delete ()
| Delete a VTK object. More...
virtual void | FastDelete ()
| Delete a reference to this object. More...
void | InitializeObjectBase ()
void | Print (ostream &os)
| Print an object to an ostream. More...
virtual void | Register (vtkObjectBase *o)
| Increase the reference count (mark as used by another object). More...
virtual void | UnRegister (vtkObjectBase *o)
| Decrease the reference count (release by another object). More...
int | GetReferenceCount ()
| Return the current reference count of this object. More...
void | SetReferenceCount (int)
| Sets the reference count. More...
bool | GetIsInMemkind () const
| A local state flag that remembers whether this object lives in the normal or extended memory space. More...
virtual void | PrintHeader (ostream &os, vtkIndent indent)
| Methods invoked by print to print information about the object including superclasses. More...
virtual void | PrintTrailer (ostream &os, vtkIndent indent)
| Methods invoked by print to print information about the object including superclasses. More...
virtual bool | UsesGarbageCollector () const
| Indicate whether the class uses `vtkGarbageCollector` or not. More...

## Protected Member Functions
| vtkCellArray ()
| ~vtkCellArray () override
Protected Member Functions inherited from vtkObject
| vtkObject ()
| ~vtkObject () override
void | RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
void | UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
void | InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
| These methods allow a command to exclusively grab all events. More...
void | InternalReleaseFocus ()
| These methods allow a command to exclusively grab all events. More...
Protected Member Functions inherited from vtkObjectBase
| vtkObjectBase ()
virtual | ~vtkObjectBase ()
virtual void | ReportReferences (vtkGarbageCollector *)
| vtkObjectBase (const vtkObjectBase &)
void | operator= (const vtkObjectBase &)

## Protected Attributes
Storage | Storage
vtkNew< vtkIdList > | TempCell
vtkIdType | TraversalCellId { 0 }
vtkNew< vtkIdTypeArray > | LegacyData
Protected Attributes inherited from vtkObject
bool | Debug
vtkTimeStamp | MTime
vtkSubjectHelper * | SubjectHelper
std::string | ObjectName
Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > | ReferenceCount
vtkWeakPointerBase ** | WeakPointers

## Friends
class | vtkCellArrayIterator
typedef vtkObject | Superclass
| Standard methods for instantiation, type information, and printing. More...
static vtkCellArray * | New ()
| Standard methods for instantiation, type information, and printing. More...
static vtkTypeBool | IsTypeOf (const char *type)
| Standard methods for instantiation, type information, and printing. More...
static vtkCellArray * | SafeDownCast (vtkObjectBase *o)
| Standard methods for instantiation, type information, and printing. More...
virtual vtkTypeBool | IsA (const char *type)
| Standard methods for instantiation, type information, and printing. More...
vtkCellArray * | NewInstance () const
| Standard methods for instantiation, type information, and printing. More...
void | PrintSelf (ostream &os, vtkIndent indent) override
| Standard methods for instantiation, type information, and printing. More...
void | PrintDebug (ostream &os)
| Standard methods for instantiation, type information, and printing. More...
virtual vtkObjectBase * | NewInstanceInternal () const
| Standard methods for instantiation, type information, and printing. More...

## Additional Inherited Members
Static Public Member Functions inherited from vtkObject
static vtkObject * | New ()
| Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
static void | BreakOnError ()
| This method is called when vtkErrorMacro executes. More...
static void | SetGlobalWarningDisplay (vtkTypeBool val)
| This is a global flag that controls whether any debug, warning or error messages are displayed. More...
static void | GlobalWarningDisplayOn ()
| This is a global flag that controls whether any debug, warning or error messages are displayed. More...
static void | GlobalWarningDisplayOff ()
| This is a global flag that controls whether any debug, warning or error messages are displayed. More...
static vtkTypeBool | GetGlobalWarningDisplay ()
| This is a global flag that controls whether any debug, warning or error messages are displayed. More...
Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool | IsTypeOf (const char *name)
| Return 1 if this class type is the same type of (or a subclass of) the named class. More...
static vtkIdType | GetNumberOfGenerationsFromBaseType (const char *name)
| Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
static vtkObjectBase * | New ()
| Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
static void | SetMemkindDirectory (const char *directoryname)
| The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More...
static bool | GetUsingMemkind ()
| A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More...
Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction | GetCurrentMallocFunction ()
static vtkReallocingFunction | GetCurrentReallocFunction ()
static vtkFreeingFunction | GetCurrentFreeFunction ()
static vtkFreeingFunction | GetAlternateFreeFunction ()

## Detailed Description

object to represent cell connectivity

vtkCellArray stores dataset topologies as an explicit connectivity table listing the point ids that make up each cell.

Internally, the connectivity table is represented as two arrays: Offsets and Connectivity.

Offsets is an array of [numCells+1] values indicating the index in the Connectivity array where each cell's points start. The last value is always the length of the Connectivity array.

The Connectivity array stores the lists of point ids for each cell.

Thus, for a dataset consisting of 2 triangles, a quad, and a line, the internal arrays will appear as follows:

Topology:
---------
Cell 0: Triangle | point ids: {0, 1, 2}
Cell 1: Triangle | point ids: {5, 7, 2}
Cell 2: Quad | point ids: {3, 4, 6, 7}
Cell 4: Line | point ids: {5, 8}
vtkCellArray (current):
-----------------------
Offsets: {0, 3, 6, 10, 12}
Connectivity: {0, 1, 2, 5, 7, 2, 3, 4, 6, 7, 5, 8}
vtkCellArray::vtkCellArray
vtkCellArray()
vtkX3D::point
@ point
Definition: vtkX3D.h:236

While this class provides traversal methods (the legacy InitTraversal(), GetNextCell() methods, and the newer method GetCellAtId()) these are in general not thread-safe. Whenever possible it is preferable to use a local thread-safe, vtkCellArrayIterator object, which can be obtained via:

auto iter = vtk::TakeSmartPointer(cellArray->NewIterator());
for (iter->GoToFirstCell(); !iter->IsDoneWithTraversal(); iter->GoToNextCell())
{
// do work with iter
}
vtk::TakeSmartPointer
vtkSmartPointer< T > TakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.
Definition: vtkSmartPointer.h:376

(Note however that depending on the type and structure of internal storage, a cell array iterator may be significantly slower than direct traversal over the cell array due to extra data copying. Factors of 3-4X are not uncommon. See vtkCellArrayIterator for more information. Also note that an iterator may become invalid if the internal vtkCellArray storage is modified.)

Other methods are also available for allocation and memory-related management; insertion of new cells into the vtkCellArray; and limited editing operations such as replacing one cell with a new cell of the same size.

The internal arrays may store either 32- or 64-bit values, though most of the API will prefer to use vtkIdType to refer to items in these arrays. This enables significant memory savings when vtkIdType is 64-bit, but 32 bits are sufficient to store all of the values in the connectivity table. Using 64-bit storage with a 32-bit vtkIdType is permitted, but values too large to fit in a 32-bit signed integer will be truncated when accessed through the API. (The particular internal storage type has implications on performance depending on vtkIdType. If the internal storage is equivalent to vtkIdType, then methods that return pointers to arrays of point ids can share the internal storage; otherwise a copy of internal memory must be performed.)

Methods for managing the storage type are:

- `bool IsStorage64Bit()`
- `bool IsStorageShareable() // Can pointers to internal storage be shared`
- `void Use32BitStorage()`
- `void Use64BitStorage()`
- `void UseDefaultStorage() // Depends on vtkIdType`
- `bool CanConvertTo32BitStorage()`
- `bool CanConvertTo64BitStorage()`
- `bool CanConvertToDefaultStorage() // Depends on vtkIdType`
- `bool ConvertTo32BitStorage()`
- `bool ConvertTo64BitStorage()`
- `bool ConvertToDefaultStorage() // Depends on vtkIdType`
- `bool ConvertToSmallestStorage() // Depends on current values in arrays`

Note that some legacy methods are still available that reflect the previous storage format of this data, which embedded the cell sizes into the Connectivity array:

vtkCellArray (legacy):
----------------------
Connectivity: {3, 0, 1, 2, 3, 5, 7, 2, 4, 3, 4, 6, 7, 2, 5, 8}
|--Cell 0--||--Cell 1--||----Cell 2---||--C3-|

The methods require an external lookup table to allow random access, which was historically stored in the vtkCellTypes object. The following methods in vtkCellArray still support this style of indexing for compatibility purposes, but these are slow as they must perform some complex computations to convert the old "location" into the new "offset" and should be avoided. These methods (and their modern equivalents) are:

- GetCell (Prefer GetCellAtId)
- GetInsertLocation (Prefer GetNumberOfCells)
- GetTraversalLocation (Prefer GetTraversalCellId, or better, NewIterator)
- SetTraversalLocation (Prefer SetTraversalLocation, or better, NewIterator)
- ReverseCell (Prefer ReverseCellAtId)
- ReplaceCell (Prefer ReplaceCellAtId)
- SetCells (Use ImportLegacyFormat, or SetData)
- GetData (Use ExportLegacyFormat, or Get[Offsets|Connectivity]Array[|32|64])

Some other legacy methods were completely removed, such as GetPointer() / WritePointer(), since they are cannot be effectively emulated under the current design. If external code needs to support both the old and new version of the vtkCellArray API, the VTK_CELL_ARRAY_V2 preprocessor definition may be used to detect which API is being compiled against.

See also
  vtkCellTypes vtkCellLinks

Examples:
  vtkCellArray (Examples)

Online Examples:

Tests:
  vtkCellArray (Tests)

Definition at line 184 of file vtkCellArray.h.

## Member Typedef Documentation

## ◆ ArrayType32

using vtkCellArray::ArrayType32 = vtkTypeInt32Array

Definition at line 187 of file vtkCellArray.h.

## ◆ ArrayType64

using vtkCellArray::ArrayType64 = vtkTypeInt64Array

Definition at line 188 of file vtkCellArray.h.

## ◆ Superclass

typedef vtkObject vtkCellArray::Superclass

Standard methods for instantiation, type information, and printing.

Definition at line 196 of file vtkCellArray.h.

## ◆ StorageArrayList

using vtkCellArray::StorageArrayList = vtkTypeList::Create<ArrayType32, ArrayType64>

List of possible array types used for storage.

May be used with vtkArrayDispatch::Dispatch[2]ByArray to process internal arrays. Both the Connectivity and Offset arrays are guaranteed to have the same type.

See also
  vtkCellArray::Visit() for a simpler mechanism.

Definition at line 209 of file vtkCellArray.h.

## ◆ InputArrayList

using vtkCellArray::InputArrayList = typename vtkTypeList::Unique<vtkTypeList::Create<vtkAOSDataArrayTemplate<int>, vtkAOSDataArrayTemplate<long>, vtkAOSDataArrayTemplate<long long> >>::Result

List of possible ArrayTypes that are compatible with internal storage.

Single component AOS-layout arrays holding one of these types may be passed to the method SetData to setup the cell array state.

This can be used with vtkArrayDispatch::DispatchByArray, etc to check input arrays before assigning them to a cell array.

Definition at line 219 of file vtkCellArray.h.

## Constructor & Destructor Documentation

## ◆ vtkCellArray()

vtkCellArray::vtkCellArray | ( |  | ) |
| protected

## ◆ ~vtkCellArray()

vtkCellArray::~vtkCellArray | ( |  | ) |
| overrideprotected

## Member Function Documentation

## ◆ New()

static vtkCellArray* vtkCellArray::New | ( |  | ) |
| static

Standard methods for instantiation, type information, and printing.

## ◆ IsTypeOf()

static vtkTypeBool vtkCellArray::IsTypeOf | ( | const char * | type | ) |
| static

Standard methods for instantiation, type information, and printing.

## ◆ IsA()

virtual vtkTypeBool vtkCellArray::IsA | ( | const char * | type | ) |
| virtual

Standard methods for instantiation, type information, and printing.

Reimplemented from vtkObjectBase.

## ◆ SafeDownCast()

static vtkCellArray* vtkCellArray::SafeDownCast | ( | vtkObjectBase * | o | ) |
| static

Standard methods for instantiation, type information, and printing.

## ◆ NewInstanceInternal()

virtual vtkObjectBase* vtkCellArray::NewInstanceInternal | ( |  | ) | const
| protectedvirtual

Standard methods for instantiation, type information, and printing.

## ◆ NewInstance()

vtkCellArray* vtkCellArray::NewInstance | ( |  | ) | const

Standard methods for instantiation, type information, and printing.

## ◆ PrintSelf()

void vtkCellArray::PrintSelf | ( | ostream & | os,
|  | vtkIndent | indent
| ) |  |
| overridevirtual

Standard methods for instantiation, type information, and printing.

Reimplemented from vtkObject.

## ◆ PrintDebug()

void vtkCellArray::PrintDebug | ( | ostream & | os | ) |

Standard methods for instantiation, type information, and printing.

## ◆ Allocate()

vtkTypeBool vtkCellArray::Allocate | ( | vtkIdType | sz,
|  | vtkIdType | vtkNotUsedext = `1000`
| ) |  |
| inline

Allocate memory.

This currently allocates both the offsets and connectivity arrays to sz.

Note
  It is preferable to use AllocateEstimate(numCells, maxCellSize) or AllocateExact(numCells, connectivitySize) instead.

Definition at line 231 of file vtkCellArray.h.

## ◆ AllocateEstimate()

bool vtkCellArray::AllocateEstimate | ( | vtkIdType | numCells,
|  | vtkIdType | maxCellSize
| ) |  |
| inline

Pre-allocate memory in internal data structures.

Does not change the number of cells, only the array capacities. Existing data is NOT preserved.

Parameters

  numCells | The number of expected cells in the dataset.
  maxCellSize | The number of points per cell to allocate memory for.

Returns
  True if allocation succeeds.

See also
  Squeeze AllocateExact AllocateCopy

Definition at line 245 of file vtkCellArray.h.

## ◆ AllocateExact()

bool vtkCellArray::AllocateExact | ( | vtkIdType | numCells,
|  | vtkIdType | connectivitySize
| ) |  |

Pre-allocate memory in internal data structures.

Does not change the number of cells, only the array capacities. Existing data is NOT preserved.

Parameters

  numCells | The number of expected cells in the dataset.
  connectivitySize | The total number of pointIds stored for all cells.

Returns
  True if allocation succeeds.

See also
  Squeeze AllocateEstimate AllocateCopy

## ◆ AllocateCopy()

bool vtkCellArray::AllocateCopy | ( | vtkCellArray * | other | ) |
| inline

Pre-allocate memory in internal data structures to match the used size of the input vtkCellArray.

Does not change the number of cells, only the array capacities. Existing data is NOT preserved.

Parameters

  other | The vtkCellArray to use as a reference.

Returns
  True if allocation succeeds.

See also
  Squeeze AllocateEstimate AllocateExact

Definition at line 270 of file vtkCellArray.h.

## ◆ ResizeExact()

bool vtkCellArray::ResizeExact | ( | vtkIdType | numCells,
|  | vtkIdType | connectivitySize
| ) |  |

ResizeExact() resizes the internal structures to hold numCells total cell offsets and connectivitySize total pointIds.

Old data is preserved, and newly-available memory is not initialized.

Warning
  For advanced use only. You probably want an Allocate method.

Returns
  True if allocation succeeds.

## ◆ Initialize()

void vtkCellArray::Initialize | ( |  | ) |

Free any memory and reset to an empty state.

## ◆ Reset()

void vtkCellArray::Reset | ( |  | ) |
| inline

Reuse list.

Reset to initial state without freeing memory.

Definition at line 1647 of file vtkCellArray.h.

## ◆ Squeeze()

void vtkCellArray::Squeeze | ( |  | ) |

Reclaim any extra memory while preserving data.

See also
  ConvertToSmallestStorage

## ◆ IsValid()

bool vtkCellArray::IsValid | ( |  | ) |

Check that internal storage is consistent and in a valid state.

Specifically, this function returns true if and only if:

- The offset and connectivity arrays have exactly one component.
- The offset array has at least one value and starts at 0.
- The offset array values never decrease.
- The connectivity array has as many entries as the last value in the offset array.

## ◆ GetNumberOfCells()

vtkIdType vtkCellArray::GetNumberOfCells | ( |  | ) | const
| inline

Get the number of cells in the array.

Definition at line 318 of file vtkCellArray.h.

## ◆ GetNumberOfOffsets()

vtkIdType vtkCellArray::GetNumberOfOffsets | ( |  | ) | const
| inline

Get the number of elements in the offsets array.

This will be the number of cells + 1.

Definition at line 334 of file vtkCellArray.h.

## ◆ GetOffset()

vtkIdType vtkCellArray::GetOffset | ( | vtkIdType | cellId | ) |
| inline

Get the offset (into the connectivity) for a specified cell id.

Definition at line 349 of file vtkCellArray.h.

## ◆ GetNumberOfConnectivityIds()

vtkIdType vtkCellArray::GetNumberOfConnectivityIds | ( |  | ) | const
| inline

Get the size of the connectivity array that stores the point ids.

Note
  Do not confuse this with the deprecated GetNumberOfConnectivityEntries(), which refers to the legacy memory layout.

Definition at line 367 of file vtkCellArray.h.

## ◆ NewIterator()

vtkCellArrayIterator* vtkCellArray::NewIterator | ( |  | ) |

NewIterator returns a new instance of vtkCellArrayIterator that is initialized to point at the first cell's data.

The caller is responsible for Delete()'ing the object.

## ◆ SetData() [1/8]

void vtkCellArray::SetData | ( | vtkIdTypeArray * | offsets,
|  | vtkIdTypeArray * | connectivity
| ) |  |

Set the internal data arrays to the supplied offsets and connectivity arrays.

Note that the input arrays may be copied and not used directly. To avoid copying, use vtkIdTypeArray, vtkCellArray::ArrayType32, or vtkCellArray::ArrayType64.

## ◆ SetData() [2/8]

void vtkCellArray::SetData | ( | vtkAOSDataArrayTemplate< int > * | offsets,
|  | vtkAOSDataArrayTemplate< int > * | connectivity
| ) |  |

Set the internal data arrays to the supplied offsets and connectivity arrays.

Note that the input arrays may be copied and not used directly. To avoid copying, use vtkIdTypeArray, vtkCellArray::ArrayType32, or vtkCellArray::ArrayType64.

## ◆ SetData() [3/8]

void vtkCellArray::SetData | ( | vtkAOSDataArrayTemplate< long > * | offsets,
|  | vtkAOSDataArrayTemplate< long > * | connectivity
| ) |  |

Set the internal data arrays to the supplied offsets and connectivity arrays.

Note that the input arrays may be copied and not used directly. To avoid copying, use vtkIdTypeArray, vtkCellArray::ArrayType32, or vtkCellArray::ArrayType64.

## ◆ SetData() [4/8]

void vtkCellArray::SetData | ( | vtkAOSDataArrayTemplate< long long > * | offsets,
|  | vtkAOSDataArrayTemplate< long long > * | connectivity
| ) |  |

Set the internal data arrays to the supplied offsets and connectivity arrays.

Note that the input arrays may be copied and not used directly. To avoid copying, use vtkIdTypeArray, vtkCellArray::ArrayType32, or vtkCellArray::ArrayType64.

## ◆ SetData() [5/8]

void vtkCellArray::SetData | ( | vtkTypeInt32Array * | offsets,
|  | vtkTypeInt32Array * | connectivity
| ) |  |

Set the internal data arrays to the supplied offsets and connectivity arrays.

Note that the input arrays may be copied and not used directly. To avoid copying, use vtkIdTypeArray, vtkCellArray::ArrayType32, or vtkCellArray::ArrayType64.

## ◆ SetData() [6/8]

void vtkCellArray::SetData | ( | vtkTypeInt64Array * | offsets,
|  | vtkTypeInt64Array * | connectivity
| ) |  |

Set the internal data arrays to the supplied offsets and connectivity arrays.

Note that the input arrays may be copied and not used directly. To avoid copying, use vtkIdTypeArray, vtkCellArray::ArrayType32, or vtkCellArray::ArrayType64.

## ◆ SetData() [7/8]

bool vtkCellArray::SetData | ( | vtkDataArray * | offsets,
|  | vtkDataArray * | connectivity
| ) |  |

Sets the internal arrays to the supplied offsets and connectivity arrays.

This is a convenience method, and may fail if the following conditions are not met:

- Both arrays must be of the same type.
- The array type must be one of the types in InputArrayList.

If invalid arrays are passed in, an error is logged and the function will return false.

## ◆ SetData() [8/8]

bool vtkCellArray::SetData | ( | vtkIdType | cellSize,
|  | vtkDataArray * | connectivity
| ) |  |

Sets the internal arrays to the supported connectivity array with an offsets array automatically generated given the fixed cells size.

This is a convenience method, and may fail if the following conditions are not met:

- The `connectivity` array must be one of the types in InputArrayList.
- The `connectivity` array size must be a multiple of `cellSize`.

If invalid arrays are passed in, an error is logged and the function will return false.

## ◆ IsStorage64Bit()

bool vtkCellArray::IsStorage64Bit | ( |  | ) | const
| inline

Returns
  True if the internal storage is using 64 bit arrays. If false, the storage is using 32 bit arrays.

Definition at line 438 of file vtkCellArray.h.

## ◆ IsStorageShareable()

bool vtkCellArray::IsStorageShareable | ( |  | ) | const
| inline

Returns
  True if the internal storage can be shared as a pointer to vtkIdType, i.e., the type and organization of internal storage is such that copying of data can be avoided, and instead a pointer to vtkIdType can be used.

Definition at line 446 of file vtkCellArray.h.

## ◆ Use32BitStorage()

void vtkCellArray::Use32BitStorage | ( |  | ) |

Initialize internal data structures to use 32- or 64-bit storage.

If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

All existing data is erased.

## ◆ Use64BitStorage()

void vtkCellArray::Use64BitStorage | ( |  | ) |

Initialize internal data structures to use 32- or 64-bit storage.

If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

All existing data is erased.

## ◆ UseDefaultStorage()

void vtkCellArray::UseDefaultStorage | ( |  | ) |

Initialize internal data structures to use 32- or 64-bit storage.

If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

All existing data is erased.

## ◆ CanConvertTo32BitStorage()

bool vtkCellArray::CanConvertTo32BitStorage | ( |  | ) | const

Check if the existing data can safely be converted to use 32- or 64- bit storage.

Ensures that all values can be converted to the target storage without truncating. If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

## ◆ CanConvertTo64BitStorage()

bool vtkCellArray::CanConvertTo64BitStorage | ( |  | ) | const

Check if the existing data can safely be converted to use 32- or 64- bit storage.

Ensures that all values can be converted to the target storage without truncating. If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

## ◆ CanConvertToDefaultStorage()

bool vtkCellArray::CanConvertToDefaultStorage | ( |  | ) | const

Check if the existing data can safely be converted to use 32- or 64- bit storage.

Ensures that all values can be converted to the target storage without truncating. If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

## ◆ ConvertTo32BitStorage()

bool vtkCellArray::ConvertTo32BitStorage | ( |  | ) |

Convert internal data structures to use 32- or 64-bit storage.

If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

If selecting smallest storage, the data is checked to see what the smallest safe storage for the existing data is, and then converts to it.

Existing data is preserved.

Returns
  True on success, false on failure. If this algorithm fails, the cell array will be in an unspecified state.

## ◆ ConvertTo64BitStorage()

bool vtkCellArray::ConvertTo64BitStorage | ( |  | ) |

Convert internal data structures to use 32- or 64-bit storage.

If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

If selecting smallest storage, the data is checked to see what the smallest safe storage for the existing data is, and then converts to it.

Existing data is preserved.

Returns
  True on success, false on failure. If this algorithm fails, the cell array will be in an unspecified state.

## ◆ ConvertToDefaultStorage()

bool vtkCellArray::ConvertToDefaultStorage | ( |  | ) |

Convert internal data structures to use 32- or 64-bit storage.

If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

If selecting smallest storage, the data is checked to see what the smallest safe storage for the existing data is, and then converts to it.

Existing data is preserved.

Returns
  True on success, false on failure. If this algorithm fails, the cell array will be in an unspecified state.

## ◆ ConvertToSmallestStorage()

bool vtkCellArray::ConvertToSmallestStorage | ( |  | ) |

Convert internal data structures to use 32- or 64-bit storage.

If selecting default storage, the storage depends on the VTK_USE_64BIT_IDS setting.

If selecting smallest storage, the data is checked to see what the smallest safe storage for the existing data is, and then converts to it.

Existing data is preserved.

Returns
  True on success, false on failure. If this algorithm fails, the cell array will be in an unspecified state.

## ◆ GetOffsetsArray()

vtkDataArray* vtkCellArray::GetOffsetsArray | ( |  | ) |
| inline

Return the array used to store cell offsets.

The 32/64 variants are only valid when IsStorage64Bit() returns the appropriate value.

Definition at line 511 of file vtkCellArray.h.

## ◆ GetOffsetsArray32()

ArrayType32* vtkCellArray::GetOffsetsArray32 | ( |  | ) |
| inline

Return the array used to store cell offsets.

The 32/64 variants are only valid when IsStorage64Bit() returns the appropriate value.

Definition at line 522 of file vtkCellArray.h.

## ◆ GetOffsetsArray64()

ArrayType64* vtkCellArray::GetOffsetsArray64 | ( |  | ) |
| inline

Return the array used to store cell offsets.

The 32/64 variants are only valid when IsStorage64Bit() returns the appropriate value.

Definition at line 523 of file vtkCellArray.h.

## ◆ GetConnectivityArray()

vtkDataArray* vtkCellArray::GetConnectivityArray | ( |  | ) |
| inline

Return the array used to store the point ids that define the cells' connectivity.

The 32/64 variants are only valid when IsStorage64Bit() returns the appropriate value.

Definition at line 532 of file vtkCellArray.h.

## ◆ GetConnectivityArray32()

ArrayType32* vtkCellArray::GetConnectivityArray32 | ( |  | ) |
| inline

Return the array used to store the point ids that define the cells' connectivity.

The 32/64 variants are only valid when IsStorage64Bit() returns the appropriate value.

Definition at line 543 of file vtkCellArray.h.

## ◆ GetConnectivityArray64()

ArrayType64* vtkCellArray::GetConnectivityArray64 | ( |  | ) |
| inline

Return the array used to store the point ids that define the cells' connectivity.

The 32/64 variants are only valid when IsStorage64Bit() returns the appropriate value.

Definition at line 544 of file vtkCellArray.h.

## ◆ IsHomogeneous()

vtkIdType vtkCellArray::IsHomogeneous | ( |  | ) |

Check if all cells have the same number of vertices.

The return value is coded as:

- -1 = heterogeneous
- 0 = Cell array empty
- n (positive integer) = homogeneous array of cell size n

## ◆ InitTraversal()

void vtkCellArray::InitTraversal | ( |  | ) |
| inline

Warning
  This method is not thread-safe. Consider using the NewIterator() iterator instead.

InitTraversal() initializes the traversal of the list of cells.

Note
  This method is not thread-safe and has tricky syntax to use correctly. Prefer the use of vtkCellArrayIterator (see NewIterator()).

Definition at line 1538 of file vtkCellArray.h.

## ◆ GetNextCell() [1/2]

int vtkCellArray::GetNextCell | ( | vtkIdType & | npts,
|  | vtkIdType const *& | pts
| ) |  |
| inline

Warning
  This method is not thread-safe. Consider using the NewIterator() iterator instead.

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.

Do not modify the returned pts pointer, as it may point to shared memory.

Note
  This method is not thread-safe and has tricky syntax to use correctly. Prefer the use of vtkCellArrayIterator (see NewIterator()).

Definition at line 1544 of file vtkCellArray.h.

## ◆ GetNextCell() [2/2]

int vtkCellArray::GetNextCell | ( | vtkIdList * | pts | ) |
| inline

Warning
  This method is not thread-safe. Consider using the NewIterator() iterator instead.

GetNextCell() gets the next cell in the list. If end of list is encountered, 0 is returned.

Note
  This method is not thread-safe and has tricky syntax to use correctly. Prefer the use of vtkCellArrayIterator (see NewIterator()).

Definition at line 1559 of file vtkCellArray.h.

## ◆ GetCellAtId() [1/3]

void vtkCellArray::GetCellAtId | ( | vtkIdType | cellId,
|  | vtkIdType & | cellSize,
|  | vtkIdType const *& | cellPoints
| ) |  |
| inline

Return the point ids for the cell at cellId.

Warning
  Subsequent calls to this method may invalidate previous call results if the internal storage type is not the same as vtkIdType and cannot be shared through the cellPoints pointer. In other words, the method may not be thread safe. Check if shareable (using IsStorageShareable()), or use a vtkCellArrayIterator to guarantee thread safety.

Definition at line 1578 of file vtkCellArray.h.

## ◆ GetCellAtId() [2/3]

void vtkCellArray::GetCellAtId | ( | vtkIdType | cellId,
|  | vtkIdType & | cellSize,
|  | vtkIdType const *& | cellPoints,
|  | vtkIdList * | ptIds
| ) |  |
| inline

Return the point ids for the cell at cellId.

Subsequent calls to this method may invalidate previous call results if the internal storage type is not the same as vtkIdType and cannot be shared through the cellPoints pointer. If that occurs, the method will use ptIds, which is an object that is created by each thread, to guarantee thread safety.

Definition at line 1585 of file vtkCellArray.h.

## ◆ GetCellAtId() [3/3]

void vtkCellArray::GetCellAtId | ( | vtkIdType | cellId,
|  | vtkIdList * | pts
| ) |  |
| inline

Return the point ids for the cell at cellId.

This always copies the cell ids (i.e., the list of points pts into the supplied vtkIdList). This method is thread safe.

Definition at line 1592 of file vtkCellArray.h.

## ◆ GetCellSize()

vtkIdType vtkCellArray::GetCellSize | ( | vtkIdType | cellId | ) | const
| inline

Return the size of the cell at cellId.

Definition at line 1572 of file vtkCellArray.h.

## ◆ InsertNextCell() [1/5]

vtkIdType vtkCellArray::InsertNextCell | ( | vtkCell * | cell | ) |
| inline

Insert a cell object.

Return the cell id of the cell.

Definition at line 1639 of file vtkCellArray.h.

## ◆ InsertNextCell() [2/5]

vtkIdType vtkCellArray::InsertNextCell | ( | vtkIdType | npts,
|  | const vtkIdType * | pts
| ) |  |
| inline

Create a cell by specifying the number of points and an array of point id's.

Return the cell id of the cell.

Definition at line 1598 of file vtkCellArray.h.

## ◆ InsertNextCell() [3/5]

vtkIdType vtkCellArray::InsertNextCell | ( | vtkIdList * | pts | ) |
| inline

Create a cell by specifying a list of point ids.

Return the cell id of the cell.

Definition at line 1632 of file vtkCellArray.h.

## ◆ InsertNextCell() [4/5]

vtkIdType vtkCellArray::InsertNextCell | ( | const std::initializer_list< vtkIdType > & | cell | ) |
| inline

Overload that allows `InsertNextCell({0, 1, 2})` syntax.

Warning
  This approach is useful for testing, but beware that trying to pass a single value (eg. `InsertNextCell({3})`) will call the `InsertNextCell(int)` overload instead.

Definition at line 659 of file vtkCellArray.h.

## ◆ InsertNextCell() [5/5]

vtkIdType vtkCellArray::InsertNextCell | ( | int | npts | ) |
| inline

Create cells by specifying a count of total points to be inserted, 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.

Definition at line 1605 of file vtkCellArray.h.

## ◆ InsertCellPoint()

void vtkCellArray::InsertCellPoint | ( | vtkIdType | id | ) |
| inline

Used in conjunction with InsertNextCell(npts) to add another point to the list of cells.

Definition at line 1611 of file vtkCellArray.h.

## ◆ UpdateCellCount()

void vtkCellArray::UpdateCellCount | ( | int | npts | ) |
| inline

Used in conjunction with InsertNextCell(int npts) and InsertCellPoint() to update the number of points defining the cell.

Definition at line 1626 of file vtkCellArray.h.

## ◆ GetTraversalCellId()

vtkIdType vtkCellArray::GetTraversalCellId | ( |  | ) |

Get/Set the current cellId for traversal.

Note
  This method is not thread-safe and has tricky syntax to use correctly. Prefer the use of vtkCellArrayIterator (see NewIterator()).

## ◆ SetTraversalCellId()

void vtkCellArray::SetTraversalCellId | ( | vtkIdType | cellId | ) |

Get/Set the current cellId for traversal.

Note
  This method is not thread-safe and has tricky syntax to use correctly. Prefer the use of vtkCellArrayIterator (see NewIterator()).

## ◆ ReverseCellAtId()

void vtkCellArray::ReverseCellAtId | ( | vtkIdType | cellId | ) |

Reverses the order of the point ids for the specified cell.

## ◆ ReplaceCellAtId() [1/3]

void vtkCellArray::ReplaceCellAtId | ( | vtkIdType | cellId,
|  | vtkIdList * | list
| ) |  |

Replaces the point ids for the specified cell with the supplied list.

Warning
  This can ONLY replace the cell if the size does not change. Attempting to change cell size through this method will have undefined results.

## ◆ ReplaceCellAtId() [2/3]

void vtkCellArray::ReplaceCellAtId | ( | vtkIdType | cellId,
|  | vtkIdType | cellSize,
|  | const vtkIdType * | cellPoints
| ) |  |

Replaces the point ids for the specified cell with the supplied list.

Warning
  This can ONLY replace the cell if the size does not change. Attempting to change cell size through this method will have undefined results.

## ◆ ReplaceCellPointAtId()

void vtkCellArray::ReplaceCellPointAtId | ( | vtkIdType | cellId,
|  | vtkIdType | cellPointIndex,
|  | vtkIdType | newPointId
| ) |  |

Replaces the pointId at cellPointIndex of a cell with newPointId.

Warning
  This can ONLY replace the cell if the size does not change. Attempting to change cell size through this method will have undefined results.

## ◆ ReplaceCellAtId() [3/3]

void vtkCellArray::ReplaceCellAtId | ( | vtkIdType | cellId,
|  | const std::initializer_list< vtkIdType > & | cell
| ) |  |
| inline

Overload that allows `ReplaceCellAtId(cellId, {0, 1, 2})` syntax.

Warning
  This can ONLY replace the cell if the size does not change. Attempting to change cell size through this method will have undefined results.

Definition at line 729 of file vtkCellArray.h.

## ◆ GetMaxCellSize()

int vtkCellArray::GetMaxCellSize | ( |  | ) |

Returns the size of the largest cell.

The size is the number of points defining the cell.

## ◆ DeepCopy()

void vtkCellArray::DeepCopy | ( | vtkCellArray * | ca | ) |

Perform a deep copy (no reference counting) of the given cell array.

## ◆ ShallowCopy()

void vtkCellArray::ShallowCopy | ( | vtkCellArray * | ca | ) |

Shallow copy ca into this cell array.

## ◆ Append()

void vtkCellArray::Append | ( | vtkCellArray * | src,
|  | vtkIdType | pointOffset = `0`
| ) |  |

Append cells from src into this.

Point ids are offset by pointOffset.

## ◆ ExportLegacyFormat()

void vtkCellArray::ExportLegacyFormat | ( | vtkIdTypeArray * | data | ) |

Fill data with the old-style vtkCellArray data layout, e.g.

{ n0, p0_0, p0_1, ..., p0_n, n1, p1_0, p1_1, ..., p1_n, ... }

where `n0` is the number of points in cell 0, and `pX_Y` is the Y'th point in cell X.

## ◆ ImportLegacyFormat() [1/2]

void vtkCellArray::ImportLegacyFormat | ( | vtkIdTypeArray * | data | ) |

Import an array of data with the legacy vtkCellArray layout, e.g.

:

{ n0, p0_0, p0_1, ..., p0_n, n1, p1_0, p1_1, ..., p1_n, ... }

where `n0` is the number of points in cell 0, and `pX_Y` is the Y'th point in cell X.

## ◆ ImportLegacyFormat() [2/2]

void vtkCellArray::ImportLegacyFormat | ( | const vtkIdType * | data,
|  | vtkIdType | len
| ) |  |

Import an array of data with the legacy vtkCellArray layout, e.g.

:

{ n0, p0_0, p0_1, ..., p0_n, n1, p1_0, p1_1, ..., p1_n, ... }

where `n0` is the number of points in cell 0, and `pX_Y` is the Y'th point in cell X.

## ◆ AppendLegacyFormat() [1/2]

void vtkCellArray::AppendLegacyFormat | ( | vtkIdTypeArray * | data,
|  | vtkIdType | ptOffset = `0`
| ) |  |

Append an array of data with the legacy vtkCellArray layout, e.g.

:

{ n0, p0_0, p0_1, ..., p0_n, n1, p1_0, p1_1, ..., p1_n, ... }

where `n0` is the number of points in cell 0, and `pX_Y` is the Y'th point in cell X.

## ◆ AppendLegacyFormat() [2/2]

void vtkCellArray::AppendLegacyFormat | ( | const vtkIdType * | data,
|  | vtkIdType | len,
|  | vtkIdType | ptOffset = `0`
| ) |  |

Append an array of data with the legacy vtkCellArray layout, e.g.

:

{ n0, p0_0, p0_1, ..., p0_n, n1, p1_0, p1_1, ..., p1_n, ... }

where `n0` is the number of points in cell 0, and `pX_Y` is the Y'th point in cell X.

## ◆ GetActualMemorySize()

unsigned long vtkCellArray::GetActualMemorySize | ( |  | ) | const

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.

## ◆ Visit() [1/4]

template<typename Functor , typename... Args, typename = typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>

void vtkCellArray::Visit | ( | Functor && | functor,
|  | Args &&... | args
| ) |  |
| inline

Warning
  Advanced use only.

The Visit methods allow efficient bulk modification of the vtkCellArray internal arrays by dispatching a functor with the current storage arrays. The simplest functor is of the form:

// Functor definition:
struct Worker
{
template <typename CellStateT>
void operator()(CellStateT &state)
{
// Do work on state object
}
};
// Functor usage:
vtkCellArray *cellArray = ...;
cellArray->Visit(Worker{});
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:185
vtkCellArray::Visit
void Visit(Functor &&functor, Args &&... args)
Definition: vtkCellArray.h:977

where `state` is an instance of the vtkCellArray::VisitState<ArrayT> class, instantiated for the current storage type of the cell array. See that class for usage details.

The functor may also:

- Return a value from `operator()`
- Pass additional arguments to `operator()`
- Hold state.

A more advanced functor that does these things is shown below, along with its usage. This functor scans a range of cells and returns the largest cell's id:

struct FindLargestCellInRange
{
template <typename CellStateT>
vtkIdType operator()(CellStateT &state,
vtkIdType rangeBegin,
vtkIdType rangeEnd)
{
vtkIdType largest = rangeBegin;
vtkIdType largestSize = state.GetCellSize(rangeBegin);
++rangeBegin;
for (; rangeBegin < rangeEnd; ++rangeBegin)
{
const vtkIdType curSize = state.GetCellSize(rangeBegin);
if (curSize > largestSize)
{
largest = rangeBegin;
largestSize = curSize;
}
}
return largest;
}
};
// Usage:
// Scan cells in range [128, 1024) and return the id of the largest.
vtkCellArray cellArray = ...;
vtkIdType largest = cellArray->Visit(FindLargestCellInRange{},
128, 1024);
vtkIdType
int vtkIdType
Definition: vtkType.h:315

Definition at line 977 of file vtkCellArray.h.

## ◆ Visit() [2/4]

template<typename Functor , typename... Args, typename = typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>

void vtkCellArray::Visit | ( | Functor && | functor,
|  | Args &&... | args
| ) |  | const
| inline

Warning
  Advanced use only.

The Visit methods allow efficient bulk modification of the vtkCellArray internal arrays by dispatching a functor with the current storage arrays. The simplest functor is of the form:

// Functor definition:
struct Worker
{
template <typename CellStateT>
void operator()(CellStateT &state)
{
// Do work on state object
}
};
// Functor usage:
vtkCellArray *cellArray = ...;
cellArray->Visit(Worker{});

where `state` is an instance of the vtkCellArray::VisitState<ArrayT> class, instantiated for the current storage type of the cell array. See that class for usage details.

The functor may also:

- Return a value from `operator()`
- Pass additional arguments to `operator()`
- Hold state.

A more advanced functor that does these things is shown below, along with its usage. This functor scans a range of cells and returns the largest cell's id:

struct FindLargestCellInRange
{
template <typename CellStateT>
vtkIdType operator()(CellStateT &state,
vtkIdType rangeBegin,
vtkIdType rangeEnd)
{
vtkIdType largest = rangeBegin;
vtkIdType largestSize = state.GetCellSize(rangeBegin);
++rangeBegin;
for (; rangeBegin < rangeEnd; ++rangeBegin)
{
const vtkIdType curSize = state.GetCellSize(rangeBegin);
if (curSize > largestSize)
{
largest = rangeBegin;
largestSize = curSize;
}
}
return largest;
}
};
// Usage:
// Scan cells in range [128, 1024) and return the id of the largest.
vtkCellArray cellArray = ...;
vtkIdType largest = cellArray->Visit(FindLargestCellInRange{},
128, 1024);

Definition at line 997 of file vtkCellArray.h.

## ◆ Visit() [3/4]

template<typename Functor , typename... Args, typename = typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>

GetReturnType<Functor, Args...> vtkCellArray::Visit | ( | Functor && | functor,
|  | Args &&... | args
| ) |  |
| inline

Warning
  Advanced use only.

The Visit methods allow efficient bulk modification of the vtkCellArray internal arrays by dispatching a functor with the current storage arrays. The simplest functor is of the form:

// Functor definition:
struct Worker
{
template <typename CellStateT>
void operator()(CellStateT &state)
{
// Do work on state object
}
};
// Functor usage:
vtkCellArray *cellArray = ...;
cellArray->Visit(Worker{});

where `state` is an instance of the vtkCellArray::VisitState<ArrayT> class, instantiated for the current storage type of the cell array. See that class for usage details.

The functor may also:

- Return a value from `operator()`
- Pass additional arguments to `operator()`
- Hold state.

A more advanced functor that does these things is shown below, along with its usage. This functor scans a range of cells and returns the largest cell's id:

struct FindLargestCellInRange
{
template <typename CellStateT>
vtkIdType operator()(CellStateT &state,
vtkIdType rangeBegin,
vtkIdType rangeEnd)
{
vtkIdType largest = rangeBegin;
vtkIdType largestSize = state.GetCellSize(rangeBegin);
++rangeBegin;
for (; rangeBegin < rangeEnd; ++rangeBegin)
{
const vtkIdType curSize = state.GetCellSize(rangeBegin);
if (curSize > largestSize)
{
largest = rangeBegin;
largestSize = curSize;
}
}
return largest;
}
};
// Usage:
// Scan cells in range [128, 1024) and return the id of the largest.
vtkCellArray cellArray = ...;
vtkIdType largest = cellArray->Visit(FindLargestCellInRange{},
128, 1024);

Definition at line 1017 of file vtkCellArray.h.

## ◆ Visit() [4/4]

template<typename Functor , typename... Args, typename = typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>

GetReturnType<Functor, Args...> vtkCellArray::Visit | ( | Functor && | functor,
|  | Args &&... | args
| ) |  | const
| inline

Warning
  Advanced use only.

The Visit methods allow efficient bulk modification of the vtkCellArray internal arrays by dispatching a functor with the current storage arrays. The simplest functor is of the form:

// Functor definition:
struct Worker
{
template <typename CellStateT>
void operator()(CellStateT &state)
{
// Do work on state object
}
};
// Functor usage:
vtkCellArray *cellArray = ...;
cellArray->Visit(Worker{});

where `state` is an instance of the vtkCellArray::VisitState<ArrayT> class, instantiated for the current storage type of the cell array. See that class for usage details.

The functor may also:

- Return a value from `operator()`
- Pass additional arguments to `operator()`
- Hold state.

A more advanced functor that does these things is shown below, along with its usage. This functor scans a range of cells and returns the largest cell's id:

struct FindLargestCellInRange
{
template <typename CellStateT>
vtkIdType operator()(CellStateT &state,
vtkIdType rangeBegin,
vtkIdType rangeEnd)
{
vtkIdType largest = rangeBegin;
vtkIdType largestSize = state.GetCellSize(rangeBegin);
++rangeBegin;
for (; rangeBegin < rangeEnd; ++rangeBegin)
{
const vtkIdType curSize = state.GetCellSize(rangeBegin);
if (curSize > largestSize)
{
largest = rangeBegin;
largestSize = curSize;
}
}
return largest;
}
};
// Usage:
// Scan cells in range [128, 1024) and return the id of the largest.
vtkCellArray cellArray = ...;
vtkIdType largest = cellArray->Visit(FindLargestCellInRange{},
128, 1024);

Definition at line 1036 of file vtkCellArray.h.

## ◆ SetNumberOfCells()

virtual void vtkCellArray::SetNumberOfCells | ( | vtkIdType |  | ) |
| virtual

Set the number of cells in the array.

DO NOT do any kind of allocation, advanced use only.

Note
  This call has no effect.

## ◆ EstimateSize()

vtkIdType vtkCellArray::EstimateSize | ( | vtkIdType | numCells,
|  | int | maxPtsPerCell
| ) |  |

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.)

Note
  This method was often misused (e.g. called alone and then discarding the result). Use AllocateEstimate directly instead.

## ◆ GetSize()

vtkIdType vtkCellArray::GetSize | ( |  | ) |

Get the size of the allocated connectivity array.

Warning
  This returns the allocated capacity of the internal arrays as a number of elements, NOT the number of elements in use.

Note
  Method incompatible with current internal storage.

## ◆ GetNumberOfConnectivityEntries()

vtkIdType vtkCellArray::GetNumberOfConnectivityEntries | ( |  | ) |

Return the size of the array that would be returned from ExportLegacyFormat().

Note
  Method incompatible with current internal storage.

## ◆ GetCell() [1/2]

void vtkCellArray::GetCell | ( | vtkIdType | loc,
|  | vtkIdType & | npts,
|  | const vtkIdType *& | pts
| ) |  |

Internal method used to retrieve a cell given a legacy offset location.

Warning
  Subsequent calls to this method may invalidate previous call results.

Note
  The location-based API is now a super-slow compatibility layer. Prefer GetCellAtId.

## ◆ GetCell() [2/2]

void vtkCellArray::GetCell | ( | vtkIdType | loc,
|  | vtkIdList * | pts
| ) |  |

Internal method used to retrieve a cell given a legacy offset location.

Note
  The location-based API is now a super-slow compatibility layer. Prefer GetCellAtId.

## ◆ GetInsertLocation()

vtkIdType vtkCellArray::GetInsertLocation | ( | int | npts | ) |

Computes the current legacy insertion location within the internal array.

Used in conjunction with GetCell(int loc,...).

Note
  The location-based API is now a super-slow compatibility layer.

## ◆ GetTraversalLocation() [1/2]

vtkIdType vtkCellArray::GetTraversalLocation | ( |  | ) |

Get/Set the current traversal legacy location.

Note
  The location-based API is now a super-slow compatibility layer. Prefer Get/SetTraversalCellId.

## ◆ GetTraversalLocation() [2/2]

vtkIdType vtkCellArray::GetTraversalLocation | ( | vtkIdType | npts | ) |

Get/Set the current traversal legacy location.

Note
  The location-based API is now a super-slow compatibility layer. Prefer Get/SetTraversalCellId.

## ◆ SetTraversalLocation()

void vtkCellArray::SetTraversalLocation | ( | vtkIdType | loc | ) |

Get/Set the current traversal legacy location.

Note
  The location-based API is now a super-slow compatibility layer. Prefer Get/SetTraversalCellId.

## ◆ ReverseCell()

void vtkCellArray::ReverseCell | ( | vtkIdType | loc | ) |

Special method inverts ordering of cell at the specified legacy location.

Must be called carefully or the cell topology may be corrupted.

Note
  The location-based API is now a super-slow compatibility layer. Prefer ReverseCellAtId;

## ◆ ReplaceCell()

void vtkCellArray::ReplaceCell | ( | vtkIdType | loc,
|  | int | npts,
|  | const vtkIdType | pts[]
| ) |  |

Replace the point ids of the cell at the legacy location 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. This call does not support changing the number of points in the cell – the caller must ensure that the target cell has npts points.

Note
  The location-based API is now a super-slow compatibility layer. Prefer ReplaceCellAtId.

## ◆ SetCells()

void vtkCellArray::SetCells | ( | vtkIdType | ncells,
|  | vtkIdTypeArray * | cells
| ) |  |

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.

Warning
  The vtkCellArray will not hold a reference to `cells`. This function merely calls ImportLegacyFormat.

Note
  Use ImportLegacyFormat or SetData instead.

## ◆ GetData()

vtkIdTypeArray* vtkCellArray::GetData | ( |  | ) |

Return the underlying data as a data array.

Warning
  The returned array is not the actual internal representation used by vtkCellArray. Modifications to the returned array will not change the vtkCellArray's topology.

Note
  Use ExportLegacyFormat, or GetOffsetsArray/GetConnectivityArray instead.

## Friends And Related Function Documentation

## ◆ vtkCellArrayIterator

friend class vtkCellArrayIterator
| friend

Definition at line 1194 of file vtkCellArray.h.

## Member Data Documentation

## ◆ Storage

Storage vtkCellArray::Storage
| protected

Definition at line 1340 of file vtkCellArray.h.

## ◆ TempCell

vtkNew<vtkIdList> vtkCellArray::TempCell
| protected

Definition at line 1341 of file vtkCellArray.h.

## ◆ TraversalCellId

vtkIdType vtkCellArray::TraversalCellId { 0 }
| protected

Definition at line 1342 of file vtkCellArray.h.

## ◆ LegacyData

vtkNew<vtkIdTypeArray> vtkCellArray::LegacyData
| protected

Definition at line 1344 of file vtkCellArray.h.

The documentation for this class was generated from the following file:

- Common/DataModel/vtkCellArray.h