129#ifndef vtkCellArray_h
130#define vtkCellArray_h
133#include "vtkCommonDataModelModule.h"
139#include "vtkFeatures.h"
141#include "vtkTypeInt32Array.h"
142#include "vtkTypeInt64Array.h"
146#include <initializer_list>
147#include <type_traits>
170#define VTK_CELL_ARRAY_V2
172VTK_ABI_NAMESPACE_BEGIN
239 return this->
AllocateExact(numCells, numCells * maxCellSize);
393 void SetData(vtkTypeInt32Array* offsets, vtkTypeInt32Array* connectivity);
394 void SetData(vtkTypeInt64Array* offsets, vtkTypeInt64Array* connectivity);
672 void UpdateCellCount(
int npts);
804 template <
typename ArrayT>
842 this->
Offsets->InsertNextValue(0);
845 this->IsInMemkind =
true;
849 void*
operator new(
size_t nSize)
852#ifdef VTK_USE_MEMKIND
859 void operator delete(
void* p)
861#ifdef VTK_USE_MEMKIND
882 bool IsInMemkind =
false;
886 template <
typename Functor,
typename... Args>
887 using GetReturnType =
decltype(std::declval<Functor>()(
888 std::declval<VisitState<ArrayType32>&>(), std::declval<Args>()...));
890 template <
typename Functor,
typename... Args>
891 struct ReturnsVoid : std::is_same<GetReturnType<Functor, Args...>, void>
965 template <
typename Functor,
typename... Args,
966 typename =
typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>
967 void Visit(Functor&& functor, Args&&... args)
985 template <
typename Functor,
typename... Args,
986 typename =
typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>
987 void Visit(Functor&& functor, Args&&... args)
const
1005 template <
typename Functor,
typename... Args,
1006 typename =
typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>
1007 GetReturnType<Functor, Args...>
Visit(Functor&& functor, Args&&... args)
1024 template <
typename Functor,
typename... Args,
1025 typename =
typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>
1026 GetReturnType<Functor, Args...>
Visit(Functor&& functor, Args&&... args)
const
1215#ifdef VTK_USE_MEMKIND
1226 this->StorageIs64Bit =
true;
1231 this->StorageIs64Bit =
false;
1234#ifdef VTK_USE_MEMKIND
1237 this->IsInMemkind =
true;
1240 (void)this->IsInMemkind;
1246 if (this->StorageIs64Bit)
1248 this->Arrays->Int64->~VisitState();
1249 delete this->Arrays->Int64;
1253 this->Arrays->Int32->~VisitState();
1254 delete this->Arrays->Int32;
1256#ifdef VTK_USE_MEMKIND
1257 if (this->IsInMemkind)
1266 delete this->Arrays;
1274 if (!this->StorageIs64Bit)
1279 this->Arrays->Int64->~VisitState();
1280 delete this->Arrays->Int64;
1282 this->StorageIs64Bit =
false;
1291 if (this->StorageIs64Bit)
1296 this->Arrays->Int32->~VisitState();
1297 delete this->Arrays->Int32;
1299 this->StorageIs64Bit =
true;
1305 bool Is64Bit()
const {
return this->StorageIs64Bit; }
1310 assert(!this->StorageIs64Bit);
1311 return *this->Arrays->Int32;
1316 assert(!this->StorageIs64Bit);
1317 return *this->Arrays->Int32;
1323 assert(this->StorageIs64Bit);
1324 return *this->Arrays->Int64;
1329 assert(this->StorageIs64Bit);
1330 return *this->Arrays->Int64;
1336 ArraySwitch* Arrays;
1337 bool StorageIs64Bit;
1338 bool IsInMemkind =
false;
1353template <
typename ArrayT>
1356 return this->
Offsets->GetNumberOfValues() - 1;
1359template <
typename ArrayT>
1365template <
typename ArrayT>
1371template <
typename ArrayT>
1377template <
typename ArrayT>
1384VTK_ABI_NAMESPACE_END
1388VTK_ABI_NAMESPACE_BEGIN
1393 template <
typename CellStateT>
1396 using ValueType =
typename CellStateT::ValueType;
1397 auto* conn = state.GetConnectivity();
1398 auto* offsets = state.GetOffsets();
1400 const vtkIdType cellId = offsets->GetNumberOfValues() - 1;
1402 offsets->InsertNextValue(
static_cast<ValueType
>(conn->GetNumberOfValues() + npts));
1406 conn->InsertNextValue(
static_cast<ValueType
>(pts[i]));
1413 template <
typename CellStateT>
1416 using ValueType =
typename CellStateT::ValueType;
1417 auto* conn = state.GetConnectivity();
1418 auto* offsets = state.GetOffsets();
1420 const vtkIdType cellId = offsets->GetNumberOfValues() - 1;
1422 offsets->InsertNextValue(
static_cast<ValueType
>(conn->GetNumberOfValues() + npts));
1431 template <
typename CellStateT>
1434 using ValueType =
typename CellStateT::ValueType;
1436 auto* offsets = state.GetOffsets();
1437 const ValueType cellBegin = offsets->GetValue(offsets->GetMaxId() - 1);
1438 offsets->SetValue(offsets->GetMaxId(),
static_cast<ValueType
>(cellBegin + npts));
1444 template <
typename CellStateT>
1447 return state.GetCellSize(cellId);
1453 template <
typename CellStateT>
1456 using ValueType =
typename CellStateT::ValueType;
1458 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1459 const vtkIdType endOffset = state.GetEndOffset(cellId);
1460 const vtkIdType cellSize = endOffset - beginOffset;
1461 const auto cellConnectivity = state.GetConnectivity()->GetPointer(beginOffset);
1466 for (ValueType i = 0; i < cellSize; ++i)
1468 idPtr[i] =
static_cast<vtkIdType>(cellConnectivity[i]);
1472 template <
typename CellStateT>
1476 using ValueType =
typename CellStateT::ValueType;
1478 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1479 const vtkIdType endOffset = state.GetEndOffset(cellId);
1480 cellSize = endOffset - beginOffset;
1481 const ValueType* cellConnectivity = state.GetConnectivity()->GetPointer(beginOffset);
1484 for (
vtkIdType i = 0; i < cellSize; ++i)
1486 cellPoints[i] =
static_cast<vtkIdType>(cellConnectivity[i]);
1492 template <
typename CellStateT>
1496 using ValueType =
typename CellStateT::ValueType;
1497 using ArrayType =
typename CellStateT::ArrayType;
1499 static constexpr bool ValueTypeCompat = CellStateT::ValueTypeIsSameAsIdType;
1500 static constexpr bool ArrayTypeCompat = std::is_base_of<AOSArrayType, ArrayType>::value;
1503 static constexpr bool value = ValueTypeCompat && ArrayTypeCompat;
1506 template <
typename CellStateT>
1507 typename std::enable_if<CanShareConnPtr<CellStateT>::value,
void>::type
operator()(
1511 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1512 const vtkIdType endOffset = state.GetEndOffset(cellId);
1513 cellSize = endOffset - beginOffset;
1515 cellPoints =
reinterpret_cast<vtkIdType*
>(state.GetConnectivity()->GetPointer(beginOffset));
1518 template <
typename CellStateT>
1519 typename std::enable_if<!CanShareConnPtr<CellStateT>::value,
void>::type
operator()(
1523 using ValueType =
typename CellStateT::ValueType;
1525 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1526 const vtkIdType endOffset = state.GetEndOffset(cellId);
1527 cellSize = endOffset - beginOffset;
1528 const ValueType* cellConnectivity = state.GetConnectivity()->GetPointer(beginOffset);
1533 for (
vtkIdType i = 0; i < cellSize; ++i)
1535 tempPtr[i] =
static_cast<vtkIdType>(cellConnectivity[i]);
1544 template <
typename CellStateT>
1547 state.GetOffsets()->Reset();
1548 state.GetConnectivity()->Reset();
1549 state.GetOffsets()->InsertNextValue(0);
1553VTK_ABI_NAMESPACE_END
1556VTK_ABI_NAMESPACE_BEGIN
1634 using ValueType =
typename ArrayType64::ValueType;
1639 using ValueType =
typename ArrayType32::ValueType;
1671VTK_ABI_NAMESPACE_END
Array-Of-Structs implementation of vtkGenericDataArray.
virtual vtkIdType GetNumberOfCells() const =0
Get the number of cells in the array.
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints)
Return the point ids for the cell at cellId.
virtual vtkIdType GetCellSize(vtkIdType cellId) const =0
Return the size of the cell at cellId.
Encapsulate traversal logic for vtkCellArray.
vtkIdType GetCellSize(vtkIdType cellId) const override
Return the size of the cell at cellId.
void SetData(vtkAOSDataArrayTemplate< int > *offsets, vtkAOSDataArrayTemplate< int > *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
int GetNextCell(vtkIdType &npts, vtkIdType const *&pts)
vtkIdTypeArray * GetData()
Return the underlying data as a data array.
vtkIdType IsHomogeneous() override
Check if all cells have the same number of vertices.
vtkIdType GetOffset(vtkIdType cellId) override
Get the offset (into the connectivity) for a specified cell id.
vtkIdType GetNumberOfConnectivityEntries()
Return the size of the array that would be returned from ExportLegacyFormat().
void SetData(vtkTypeInt32Array *offsets, vtkTypeInt32Array *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
vtkTypeBool Allocate(vtkIdType sz, vtkIdType vtkNotUsed(ext)=1000)
Allocate memory.
void UseDefaultStorage()
Initialize internal data structures to use 32- or 64-bit storage.
bool AllocateCopy(vtkCellArray *other)
Pre-allocate memory in internal data structures to match the used size of the input vtkCellArray.
void AppendLegacyFormat(vtkIdTypeArray *data, vtkIdType ptOffset=0)
Append an array of data with the legacy vtkCellArray layout, e.g.:
static void SetDefaultStorageIs64Bit(bool val)
Control the default internal storage size.
void DeepCopy(vtkAbstractCellArray *ca) override
Perform a deep copy (no reference counting) of the given cell array.
bool IsValid()
Check that internal storage is consistent and in a valid state.
void AppendLegacyFormat(const vtkIdType *data, vtkIdType len, vtkIdType ptOffset=0)
Append an array of data with the legacy vtkCellArray layout, e.g.:
friend class vtkCellArrayIterator
GetReturnType< Functor, Args... > Visit(Functor &&functor, Args &&... args) const
bool SetData(vtkIdType cellSize, vtkDataArray *connectivity)
Sets the internal arrays to the supported connectivity array with an offsets array automatically gene...
void ShallowCopy(vtkAbstractCellArray *ca) override
Shallow copy ca into this cell array.
vtkIdType GetNumberOfOffsets() const override
Get the number of elements in the offsets array.
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.
vtkIdType GetTraversalCellId()
Get/Set the current cellId for traversal.
void Visit(Functor &&functor, Args &&... args)
vtkTypeInt32Array ArrayType32
vtkIdType GetNumberOfCells() const override
Get the number of cells in the array.
ArrayType64 * GetConnectivityArray64()
Return the array used to store the point ids that define the cells' connectivity.
vtkIdType GetNumberOfConnectivityIds() const override
Get the size of the connectivity array that stores the point ids.
vtkIdType GetTraversalLocation()
Get/Set the current traversal legacy location.
typename vtkTypeList::Unique< vtkTypeList::Create< vtkAOSDataArrayTemplate< int >, vtkAOSDataArrayTemplate< long >, vtkAOSDataArrayTemplate< long long > > >::Result InputArrayList
List of possible ArrayTypes that are compatible with internal storage.
ArrayType32 * GetConnectivityArray32()
Return the array used to store the point ids that define the cells' connectivity.
void SetData(vtkAOSDataArrayTemplate< long long > *offsets, vtkAOSDataArrayTemplate< long long > *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize)
Pre-allocate memory in internal data structures.
bool ResizeExact(vtkIdType numCells, vtkIdType connectivitySize)
ResizeExact() resizes the internal structures to hold numCells total cell offsets and connectivitySiz...
vtkIdType EstimateSize(vtkIdType numCells, int maxPtsPerCell)
Utility routines help manage memory of cell array.
ArrayType32 * GetOffsetsArray32()
Return the array used to store cell offsets.
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
void ReverseCell(vtkIdType loc)
Special method inverts ordering of cell at the specified legacy location.
vtkTypeInt64Array ArrayType64
vtkIdType TraversalCellId
bool IsStorageShareable() const override
void Use64BitStorage()
Initialize internal data structures to use 32- or 64-bit storage.
bool ConvertToDefaultStorage()
Convert internal data structures to use 32- or 64-bit storage.
bool CanConvertToDefaultStorage() const
Check if the existing data can safely be converted to use 32- or 64- bit storage.
static bool DefaultStorageIs64Bit
void GetCell(vtkIdType loc, vtkIdType &npts, const vtkIdType *&pts)
Internal method used to retrieve a cell given a legacy offset location.
bool CanConvertTo32BitStorage() const
Check if the existing data can safely be converted to use 32- or 64- bit storage.
vtkDataArray * GetConnectivityArray()
Return the array used to store the point ids that define the cells' connectivity.
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *ptIds) override
Return the point ids for the cell at cellId.
void InsertCellPoint(vtkIdType id)
Used in conjunction with InsertNextCell(npts) to add another point to the list of cells.
unsigned long GetActualMemorySize() const
Return the memory in kibibytes (1024 bytes) consumed by this cell array.
vtkCellArrayIterator * NewIterator()
NewIterator returns a new instance of vtkCellArrayIterator that is initialized to point at the first ...
void SetTraversalLocation(vtkIdType loc)
Get/Set the current traversal legacy location.
void ReplaceCellAtId(vtkIdType cellId, vtkIdList *list)
Replaces the point ids for the specified cell with the supplied list.
void ReverseCellAtId(vtkIdType cellId)
Reverses the order of the point ids for the specified cell.
bool SetData(vtkDataArray *offsets, vtkDataArray *connectivity)
Sets the internal arrays to the supplied offsets and connectivity arrays.
void Initialize() override
Free any memory and reset to an empty state.
void Squeeze()
Reclaim any extra memory while preserving data.
void SetData(vtkIdTypeArray *offsets, vtkIdTypeArray *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
bool ConvertTo32BitStorage()
Convert internal data structures to use 32- or 64-bit storage.
void Visit(Functor &&functor, Args &&... args) const
ArrayType64 * GetOffsetsArray64()
Return the array used to store cell offsets.
bool ConvertToSmallestStorage()
Convert internal data structures to use 32- or 64-bit storage.
void ExportLegacyFormat(vtkIdTypeArray *data)
Fill data with the old-style vtkCellArray data layout, e.g.
bool ConvertTo64BitStorage()
Convert internal data structures to use 32- or 64-bit storage.
void SetData(vtkAOSDataArrayTemplate< long > *offsets, vtkAOSDataArrayTemplate< long > *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
void ImportLegacyFormat(const vtkIdType *data, vtkIdType len)
Import an array of data with the legacy vtkCellArray layout, e.g.:
void ImportLegacyFormat(vtkIdTypeArray *data)
Import an array of data with the legacy vtkCellArray layout, e.g.:
void Use32BitStorage()
Initialize internal data structures to use 32- or 64-bit storage.
void SetTraversalCellId(vtkIdType cellId)
Get/Set the current cellId for traversal.
void SetData(vtkTypeInt64Array *offsets, vtkTypeInt64Array *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
static bool GetDefaultStorageIs64Bit()
Control the default internal storage size.
int GetMaxCellSize() override
Returns the size of the largest cell.
vtkIdType InsertNextCell(vtkCell *cell)
Insert a cell object.
virtual void SetNumberOfCells(vtkIdType)
Set the number of cells in the array.
vtkDataArray * GetOffsetsArray()
Return the array used to store cell offsets.
vtkNew< vtkIdTypeArray > LegacyData
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, type information, and printing.
void PrintDebug(ostream &os)
Standard methods for instantiation, type information, and printing.
vtkIdType GetInsertLocation(int npts)
Computes the current legacy insertion location within the internal array.
void UpdateCellCount(int npts)
Used in conjunction with InsertNextCell(int npts) and InsertCellPoint() to update the number of point...
GetReturnType< Functor, Args... > Visit(Functor &&functor, Args &&... args)
void SetCells(vtkIdType ncells, vtkIdTypeArray *cells)
Define multiple cells by providing a connectivity list.
static vtkCellArray * New()
Standard methods for instantiation, type information, and printing.
void ReplaceCellPointAtId(vtkIdType cellId, vtkIdType cellPointIndex, vtkIdType newPointId)
Replaces the pointId at cellPointIndex of a cell with newPointId.
vtkIdType GetSize()
Get the size of the allocated connectivity array.
vtkTypeList::Create< ArrayType32, ArrayType64 > StorageArrayList
List of possible array types used for storage.
vtkIdType InsertNextCell(const std::initializer_list< vtkIdType > &cell)
Overload that allows InsertNextCell({0, 1, 2}) syntax.
void Append(vtkCellArray *src, vtkIdType pointOffset=0)
Append cells from src into this.
bool IsStorage64Bit() const
void ReplaceCellAtId(vtkIdType cellId, vtkIdType cellSize, const vtkIdType *cellPoints)
Replaces the point ids for the specified cell with the supplied list.
bool CanConvertTo64BitStorage() const
Check if the existing data can safely be converted to use 32- or 64- bit storage.
abstract class to specify cell behavior
vtkIdList * GetPointIds()
Return the list of point ids defining the cell.
list of point or cell ids
void SetNumberOfIds(vtkIdType number)
Specify the number of ids for this object to hold.
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
void Reset()
Reset to an empty state but retain previously allocated memory.
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Allocate and hold a VTK object.
static vtkMallocingFunction GetCurrentMallocFunction()
static vtkFreeingFunction GetAlternateFreeFunction()
static bool GetUsingMemkind()
A global state flag that controls whether vtkObjects are constructed in the usual way (the default) o...
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
VTK_ITER_INLINE auto DataArrayValueRange(const ArrayTypePtr &array, ValueIdType start=-1, ValueIdType end=-1) -> typename detail::SelectValueRange< ArrayTypePtr, TupleSize, ForceValueTypeForVtkDataArray >::type
Generate an stl and for-range compatible range of flat AOS iterators from a vtkDataArray.
VisitState< ArrayType64 > & GetArrays64()
const VisitState< ArrayType64 > & GetArrays64() const
const VisitState< ArrayType32 > & GetArrays32() const
VisitState< ArrayType32 > & GetArrays32()
vtkIdType GetNumberOfCells() const
friend class vtkCellArray
vtkIdType GetEndOffset(vtkIdType cellId) const
vtkSmartPointer< ArrayType > Offsets
vtkSmartPointer< ArrayType > Connectivity
static constexpr bool ValueTypeIsSameAsIdType
const ArrayType * GetOffsets() const
decltype(vtk::DataArrayValueRange< 1 >(std::declval< ArrayType >())) CellRangeType
CellRangeType GetCellRange(vtkIdType cellId)
vtkIdType GetBeginOffset(vtkIdType cellId) const
vtkIdType GetCellSize(vtkIdType cellId) const
const ArrayType * GetConnectivity() const
typename ArrayType::ValueType ValueType
ArrayType * GetConnectivity()
static constexpr bool value
std::enable_if<!CanShareConnPtr< CellStateT >::value, void >::type operator()(CellStateT &state, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *temp)
std::enable_if< CanShareConnPtr< CellStateT >::value, void >::type operator()(CellStateT &state, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *vtkNotUsed(temp))
void operator()(CellStateT &state, const vtkIdType cellId, vtkIdList *ids)
void operator()(CellStateT &state, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType *cellPoints)
vtkIdType operator()(CellStateT &state, vtkIdType cellId)
vtkIdType operator()(CellStateT &state, const vtkIdType npts, const vtkIdType pts[])
vtkIdType operator()(CellStateT &state, const vtkIdType npts)
void operator()(CellStateT &state)
void operator()(CellStateT &state, const vtkIdType npts)
Remove all duplicate types from TypeList TList, storing the new list in Result.
VisitState< ArrayType32 > * Int32
VisitState< ArrayType64 > * Int64
STL-compatible iterable ranges that provide access to vtkDataArray elements.
#define VTK_SIZEHINT(...)
#define VTK_MARSHALMANUAL