VTK
Classes | Public Types | Public Member Functions | Static 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

typedef vtkObject Superclass
 
using ArrayType32 = vtkTypeInt32Array
 
using ArrayType64 = vtkTypeInt64Array
 
using StorageArrayList = vtkTypeList_Create_2(ArrayType32, ArrayType64)
 List of possible array types used for storage. More...
 
using InputArrayList = typename vtkTypeList::Unique< vtkTypeList_Create_3(vtkAOSDataArrayTemplate< int >, vtkAOSDataArrayTemplate< long >, vtkAOSDataArrayTemplate< long long >)>::Result
 List of possible ArrayTypes that are compatible with internal storage. More...
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkCellArrayNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
void PrintDebug (ostream &os)
 
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 GetNumberOfConnectivityIds () const
 Get the size of the connectivity array that stores the point ids. More...
 
vtkCellArrayIteratorNewIterator ()
 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 IsStorage64Bit () 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, vtkIdList *pts)
 Return the point ids for the cell at cellId. More...
 
vtkIdType GetCellSize (const 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 count, and then adding points one at a time using method InsertCellPoint(). More...
 
void InsertCellPoint (vtkIdType id)
 Used in conjunction with InsertNextCell(int 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 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 ()
 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...
 
vtkIdTypeArrayGetData ()
 Return the underlying data as a data array. 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 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 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...
 
vtkDataArrayGetOffsetsArray ()
 Return the array used to store cell offsets. More...
 
ArrayType32GetOffsetsArray32 ()
 Return the array used to store cell offsets. More...
 
ArrayType64GetOffsetsArray64 ()
 Return the array used to store cell offsets. More...
 
vtkDataArrayGetConnectivityArray ()
 Return the array used to store the point ids that define the cells' connectivity. More...
 
ArrayType32GetConnectivityArray32 ()
 Return the array used to store the point ids that define the cells' connectivity. More...
 
ArrayType64GetConnectivityArray64 ()
 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...
 
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)
 
vtkCommandGetCommand (unsigned long tag)
 
void RemoveObserver (vtkCommand *)
 
void RemoveObservers (unsigned long event, vtkCommand *)
 
void RemoveObservers (const char *event, vtkCommand *)
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 
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)
 
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)
 
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...
 
int InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
int InvokeEvent (const char *event, void *callData)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. 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 PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
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...
 
void PrintRevisions (ostream &)
 Legacy. More...
 

Static Public Member Functions

static vtkTypeBool IsTypeOf (const char *type)
 
static vtkCellArraySafeDownCast (vtkObjectBase *o)
 
static vtkCellArrayNew ()
 Instantiate cell array (connectivity list). More...
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 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 (int val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static int GetGlobalWarningDisplay ()
 
- 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 vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 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 ()
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void CollectRevisions (ostream &)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Protected Attributes

Storage Storage
 
vtkNew< vtkIdListTempCell
 
vtkIdType TraversalCellId {0}
 
vtkNew< vtkIdTypeArrayLegacyData
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Friends

class vtkCellArrayIterator
 

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}

While this class provides traversal methods (InitTraversal, GetNextCell), these are not thread-safe and are a bit difficult to use correctly as they do not use the typical VTK iterator API. Prefer to use a local vtkCellArrayIterator object, which can be obtained via:

auto iter = vtk::TakeSmartPointer(cellArray->NewIterator());
for (iter->GoToFirstCell(); !iter->IsDoneWithTraversal(); iter->GoToNextCell())
{
// do work with iter
}

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.

Methods for managing the storage type are:

Note that some 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:

Some other methods were completely removed, such as GetPointer / WritePointer, since they are simply not able to be 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)
Tests:
vtkCellArray (Tests)

Definition at line 169 of file vtkCellArray.h.

Member Typedef Documentation

◆ Superclass

Definition at line 172 of file vtkCellArray.h.

◆ ArrayType32

using vtkCellArray::ArrayType32 = vtkTypeInt32Array

Definition at line 176 of file vtkCellArray.h.

◆ ArrayType64

using vtkCellArray::ArrayType64 = vtkTypeInt64Array

Definition at line 177 of file vtkCellArray.h.

◆ StorageArrayList

using vtkCellArray::StorageArrayList = vtkTypeList_Create_2(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 187 of file vtkCellArray.h.

◆ InputArrayList

List of possible ArrayTypes that are compatible with internal storage.

Single component AoS-layout arrays holding one of these types may be passed to 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 200 of file vtkCellArray.h.

Constructor & Destructor Documentation

◆ vtkCellArray()

vtkCellArray::vtkCellArray ( )
protected

◆ ~vtkCellArray()

vtkCellArray::~vtkCellArray ( )
overrideprotected

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

virtual vtkTypeBool vtkCellArray::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class.

Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase* vtkCellArray::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkCellArray* vtkCellArray::NewInstance ( ) const

◆ PrintSelf()

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

Methods invoked by print to print information about the object including superclasses.

Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

◆ PrintDebug()

void vtkCellArray::PrintDebug ( ostream &  os)

◆ New()

static vtkCellArray* vtkCellArray::New ( )
static

Instantiate cell array (connectivity list).

◆ Allocate()

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

Allocate memory.

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

Note
The internal storage no longer makes sense with this method. Use AllocateEstimate(numCells, maxCellSize) or AllocateExact(numCells, connectivitySize) instead.

Definition at line 216 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
numCellsThe number of expected cells in the dataset.
maxCellSizeThe number of points per cell to allocate memory for.
Returns
True if allocation succeeds.
See also
Squeeze AllocateExact AllocateCopy

Definition at line 230 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
numCellsThe number of expected cells in the dataset.
connectivitySizeThe 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
otherThe vtkCellArray to use as a reference.
Returns
True if allocation succeeds.
See also
Squeeze AllocateEstimate AllocateExact

Definition at line 256 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 condition without freeing memory.

Definition at line 1550 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 305 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 321 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 an outdated memory layout.

Definition at line 338 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/7]

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() [2/7]

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() [3/7]

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() [4/7]

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() [5/7]

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() [6/7]

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() [7/7]

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.

◆ 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 398 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 456 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 467 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 471 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 483 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 494 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 498 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 1435 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 1441 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 1457 of file vtkCellArray.h.

◆ GetCellAtId() [1/2]

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.

Definition at line 1478 of file vtkCellArray.h.

◆ GetCellAtId() [2/2]

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

Return the point ids for the cell at cellId.

Definition at line 1490 of file vtkCellArray.h.

◆ GetCellSize()

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

Return the size of the cell at cellId.

Definition at line 1470 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 1541 of file vtkCellArray.h.

◆ InsertNextCell() [2/5]

vtkIdType vtkCellArray::InsertNextCell ( vtkIdType  npts,
const vtkIdType pts 
)

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

Return the cell id of the cell.

◆ 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 1533 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 601 of file vtkCellArray.h.

◆ InsertNextCell() [5/5]

vtkIdType vtkCellArray::InsertNextCell ( int  npts)
inline

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.

Definition at line 1504 of file vtkCellArray.h.

◆ InsertCellPoint()

void vtkCellArray::InsertCellPoint ( vtkIdType  id)
inline

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

Definition at line 1510 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 1527 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.

◆ 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 666 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 ( )

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{});

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 890 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 911 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 932 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 952 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 1113 of file vtkCellArray.h.

Member Data Documentation

◆ Storage

Definition at line 1229 of file vtkCellArray.h.

◆ TempCell

vtkNew<vtkIdList> vtkCellArray::TempCell
protected

Definition at line 1230 of file vtkCellArray.h.

◆ TraversalCellId

vtkIdType vtkCellArray::TraversalCellId {0}
protected

Definition at line 1231 of file vtkCellArray.h.

◆ LegacyData

vtkNew<vtkIdTypeArray> vtkCellArray::LegacyData
protected

Definition at line 1233 of file vtkCellArray.h.


The documentation for this class was generated from the following file:
vtkCellArray::vtkCellArray
vtkCellArray()
vtkIdType
int vtkIdType
Definition: vtkType.h:349
vtkX3D::point
Definition: vtkX3D.h:236
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:169
vtkCellArray::Visit
void Visit(Functor &&functor, Args &&... args)
Definition: vtkCellArray.h:890
vtk::TakeSmartPointer
vtkSmartPointer< T > TakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.
Definition: vtkSmartPointer.h:365