 |
VTK
9.1.0
|
Go to the documentation of this file.
244 #ifndef vtkCellArray_h
245 #define vtkCellArray_h
247 #include "vtkCommonDataModelModule.h"
253 #include "vtkFeatures.h"
255 #include "vtkTypeInt32Array.h"
256 #include "vtkTypeInt64Array.h"
260 #include <initializer_list>
261 #include <type_traits>
284 #define VTK_CELL_ARRAY_V2
338 return this->AllocateExact(sz, sz) ? 1 : 0;
352 return this->AllocateExact(numCells, numCells * maxCellSize);
476 #ifndef __VTK_WRAP__ // The wrappers have issues with some of these templates
487 void SetData(vtkTypeInt32Array* offsets, vtkTypeInt32Array* connectivity);
488 void SetData(vtkTypeInt64Array* offsets, vtkTypeInt64Array* connectivity);
495 #endif // __VTK_WRAP__
607 return this->GetOffsetsArray64();
611 return this->GetOffsetsArray32();
628 return this->GetConnectivityArray64();
632 return this->GetConnectivityArray32();
658 void InitTraversal();
707 VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells());
740 return this->InsertNextCell(
static_cast<vtkIdType>(cell.size()), cell.begin());
761 void UpdateCellCount(
int npts);
801 return this->ReplaceCellAtId(cellId,
static_cast<vtkIdType>(cell.size()), cell.begin());
876 unsigned long GetActualMemorySize() const;
884 template <
typename ArrayT>
889 using CellRangeType = decltype(vtk::DataArrayValueRange<1>(std::declval<ArrayType>()));
922 this->Offsets->InsertNextValue(0);
925 this->IsInMemkind =
true;
929 void*
operator new(
size_t nSize)
932 #ifdef VTK_USE_MEMKIND
939 void operator delete(
void* p)
941 #ifdef VTK_USE_MEMKIND
962 bool IsInMemkind =
false;
966 template <
typename Functor,
typename... Args>
967 using GetReturnType = decltype(
970 template <
typename Functor,
typename... Args>
971 struct ReturnsVoid : std::is_same<GetReturnType<Functor, Args...>, void>
1045 template <
typename Functor,
typename... Args,
1046 typename =
typename std::enable_if<ReturnsVoid<Functor, Args...>
::value>
::type>
1047 void Visit(Functor&& functor, Args&&... args)
1065 template <
typename Functor,
typename... Args,
1066 typename =
typename std::enable_if<ReturnsVoid<Functor, Args...>
::value>
::type>
1067 void Visit(Functor&& functor, Args&&... args)
const
1085 template <
typename Functor,
typename... Args,
1086 typename =
typename std::enable_if<!ReturnsVoid<Functor, Args...>
::value>
::type>
1087 GetReturnType<Functor, Args...>
Visit(Functor&& functor, Args&&... args)
1104 template <
typename Functor,
typename... Args,
1105 typename =
typename std::enable_if<!ReturnsVoid<Functor, Args...>
::value>
::type>
1106 GetReturnType<Functor, Args...>
Visit(Functor&& functor, Args&&... args)
const
1126 #endif // __VTK_WRAP__
1189 VTK_EXPECTS(0 <= loc && loc < GetNumberOfConnectivityEntries());
1284 #ifdef VTK_USE_MEMKIND
1292 #ifdef VTK_USE_64BIT_IDS
1295 this->StorageIs64Bit =
true;
1297 #else // VTK_USE_64BIT_IDS
1300 this->StorageIs64Bit =
false;
1302 #endif // VTK_USE_64BIT_IDS
1303 #ifdef VTK_USE_MEMKIND
1306 this->IsInMemkind =
true;
1309 (void)this->IsInMemkind;
1315 if (this->StorageIs64Bit)
1317 this->Arrays->Int64->~VisitState();
1318 delete this->Arrays->Int64;
1322 this->Arrays->Int32->~VisitState();
1323 delete this->Arrays->Int32;
1325 #ifdef VTK_USE_MEMKIND
1326 if (this->IsInMemkind)
1335 delete this->Arrays;
1343 if (!this->StorageIs64Bit)
1348 this->Arrays->Int64->~VisitState();
1349 delete this->Arrays->Int64;
1351 this->StorageIs64Bit =
false;
1360 if (this->StorageIs64Bit)
1365 this->Arrays->Int32->~VisitState();
1366 delete this->Arrays->Int32;
1368 this->StorageIs64Bit =
true;
1374 bool Is64Bit()
const {
return this->StorageIs64Bit; }
1379 assert(!this->StorageIs64Bit);
1380 return *this->Arrays->Int32;
1385 assert(!this->StorageIs64Bit);
1386 return *this->Arrays->Int32;
1392 assert(this->StorageIs64Bit);
1393 return *this->Arrays->Int64;
1398 assert(this->StorageIs64Bit);
1399 return *this->Arrays->Int64;
1405 ArraySwitch* Arrays;
1406 bool StorageIs64Bit;
1407 bool IsInMemkind =
false;
1421 template <
typename ArrayT>
1424 return this->Offsets->GetNumberOfValues() - 1;
1427 template <
typename ArrayT>
1430 return static_cast<vtkIdType>(this->Offsets->GetValue(cellId));
1433 template <
typename ArrayT>
1436 return static_cast<vtkIdType>(this->Offsets->GetValue(cellId + 1));
1439 template <
typename ArrayT>
1442 return this->GetEndOffset(cellId) - this->GetBeginOffset(cellId);
1445 template <
typename ArrayT>
1449 return vtk::DataArrayValueRange<1>(
1450 this->
GetConnectivity(), this->GetBeginOffset(cellId), this->GetEndOffset(cellId));
1459 template <
typename CellStateT>
1462 using ValueType =
typename CellStateT::ValueType;
1463 auto* conn = state.GetConnectivity();
1464 auto* offsets = state.GetOffsets();
1466 const vtkIdType cellId = offsets->GetNumberOfValues() - 1;
1468 offsets->InsertNextValue(
static_cast<ValueType
>(conn->GetNumberOfValues() + npts));
1472 conn->InsertNextValue(
static_cast<ValueType
>(pts[i]));
1479 template <
typename CellStateT>
1482 using ValueType =
typename CellStateT::ValueType;
1483 auto* conn = state.GetConnectivity();
1484 auto* offsets = state.GetOffsets();
1486 const vtkIdType cellId = offsets->GetNumberOfValues() - 1;
1488 offsets->InsertNextValue(
static_cast<ValueType
>(conn->GetNumberOfValues() + npts));
1497 template <
typename CellStateT>
1500 using ValueType =
typename CellStateT::ValueType;
1502 auto* offsets = state.GetOffsets();
1503 const ValueType cellBegin = offsets->GetValue(offsets->GetMaxId() - 1);
1504 offsets->SetValue(offsets->GetMaxId(),
static_cast<ValueType
>(cellBegin + npts));
1510 template <
typename CellStateT>
1513 return state.GetCellSize(cellId);
1519 template <
typename CellStateT>
1522 using ValueType =
typename CellStateT::ValueType;
1524 const auto cellPts = state.GetCellRange(cellId);
1529 for (ValueType ptId : cellPts)
1531 *idPtr++ =
static_cast<vtkIdType>(ptId);
1537 template <
typename CellStateT>
1541 using ValueType =
typename CellStateT::ValueType;
1542 using ArrayType =
typename CellStateT::ArrayType;
1544 static constexpr
bool ValueTypeCompat = CellStateT::ValueTypeIsSameAsIdType;
1548 static constexpr
bool value = ValueTypeCompat && ArrayTypeCompat;
1551 template <
typename CellStateT>
1556 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1557 const vtkIdType endOffset = state.GetEndOffset(cellId);
1558 cellSize = endOffset - beginOffset;
1560 cellPoints =
reinterpret_cast<vtkIdType*
>(state.GetConnectivity()->GetPointer(beginOffset));
1563 template <
typename CellStateT>
1568 using ValueType =
typename CellStateT::ValueType;
1570 const auto cellPts = state.GetCellRange(cellId);
1571 cellSize = cellPts.size();
1577 for (ValueType ptId : cellPts)
1579 *tempPtr++ =
static_cast<vtkIdType>(ptId);
1588 template <
typename CellStateT>
1591 state.GetOffsets()->Reset();
1592 state.GetConnectivity()->Reset();
1593 state.GetOffsets()->InsertNextValue(0);
1608 if (this->TraversalCellId < this->GetNumberOfCells())
1610 this->GetCellAtId(this->TraversalCellId, npts, pts);
1611 ++this->TraversalCellId;
1670 using ValueType =
typename ArrayType64::ValueType;
1675 using ValueType =
typename ArrayType32::ValueType;
1707 #endif // vtkCellArray.h
static vtkFreeingFunction GetAlternateFreeFunction()
vtkIdType GetNumberOfConnectivityEntries()
Return the size of the array that would be returned from ExportLegacyFormat().
void AppendLegacyFormat(vtkIdTypeArray *data, vtkIdType ptOffset=0)
Append an array of data with the legacy vtkCellArray layout, e.g.
void Initialize()
Free any memory and reset to an empty state.
void Use32BitStorage()
Initialize internal data structures to use 32- or 64-bit storage.
int GetMaxCellSize()
Returns the size of the largest cell.
void operator()(CellStateT &state, const vtkIdType cellId, vtkIdList *ids)
ArrayType64 * GetConnectivityArray64()
Return the array used to store the point ids that define the cells' connectivity.
void UpdateCellCount(int npts)
Used in conjunction with InsertNextCell(int npts) and InsertCellPoint() to update the number of point...
vtkTypeInt64Array ArrayType64
std::enable_if< CanShareConnPtr< CellStateT >::value, void >::type operator()(CellStateT &state, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *vtkNotUsed(temp))
vtkIdType GetBeginOffset(vtkIdType cellId) const
void ReplaceCellAtId(vtkIdType cellId, vtkIdList *list)
Replaces the point ids for the specified cell with the supplied list.
bool SetData(vtkDataArray *offsets, vtkDataArray *connectivity)
Sets the internal arrays to the supplied offsets and connectivity arrays.
void SetData(vtkAOSDataArrayTemplate< long long > *offsets, vtkAOSDataArrayTemplate< long long > *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
vtkTypeBool Allocate(vtkIdType sz, vtkIdType vtkNotUsed(ext)=1000)
Allocate memory.
STL-compatible iterable ranges that provide access to vtkDataArray elements.
ArrayType * GetConnectivity()
bool SetData(vtkIdType cellSize, vtkDataArray *connectivity)
Sets the internal arrays to the supported connectivity array with an offsets array automatically gene...
vtkSmartPointer< ArrayType > Connectivity
vtkTypeInt32Array ArrayType32
GetReturnType< Functor, Args... > Visit(Functor &&functor, Args &&... args) const
VisitState< ArrayType64 > & GetArrays64()
void ReplaceCellAtId(vtkIdType cellId, vtkIdType cellSize, const vtkIdType *cellPoints)
Replaces the point ids for the specified cell with the supplied list.
abstract base class for most VTK objects
vtkIdType InsertNextCell(const std::initializer_list< vtkIdType > &cell)
Overload that allows InsertNextCell({0, 1, 2}) syntax.
std::enable_if<!CanShareConnPtr< CellStateT >::value, void >::type operator()(CellStateT &state, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *temp)
bool CanConvertToDefaultStorage() const
Check if the existing data can safely be converted to use 32- or 64- bit storage.
void SetData(vtkIdTypeArray *offsets, vtkIdTypeArray *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
vtkIdType GetCellSize(const vtkIdType cellId) const
Return the size of the cell at cellId.
typename vtkTypeList::Unique< vtkTypeList::Create< vtkAOSDataArrayTemplate< int >, vtkAOSDataArrayTemplate< long >, vtkAOSDataArrayTemplate< long long > >>::Result InputArrayList
List of possible ArrayTypes that are compatible with internal storage.
abstract superclass for arrays of numeric data
static constexpr bool ValueTypeIsSameAsIdType
ArrayType64 * GetOffsetsArray64()
Return the array used to store cell offsets.
vtkIdType GetNumberOfCells() const
Get the number of cells in the array.
vtkIdType GetCellSize(vtkIdType cellId) const
ArrayType32 * GetOffsetsArray32()
Return the array used to store cell offsets.
vtkIdType operator()(CellStateT &state, const vtkIdType npts, const vtkIdType pts[])
static vtkMallocingFunction GetCurrentMallocFunction()
CellRangeType GetCellRange(vtkIdType cellId)
VisitState< ArrayType32 > & GetArrays32()
vtkIdType GetNumberOfConnectivityIds() const
Get the size of the connectivity array that stores the point ids.
vtkSmartPointer< vtkCellArray > GetConnectivity(Ioss::GroupingEntity *group_entity, int &vtk_topology_type, Cache *cache=nullptr)
Read connectivity information from the group_entity.
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints)
Return the point ids for the cell at cellId.
bool IsValid()
Check that internal storage is consistent and in a valid state.
Encapsulate traversal logic for vtkCellArray.
vtkIdType IsHomogeneous()
Check if all cells have the same number of vertices.
vtkCellArrayIterator * NewIterator()
NewIterator returns a new instance of vtkCellArrayIterator that is initialized to point at the first ...
bool ConvertTo32BitStorage()
Convert internal data structures to use 32- or 64-bit storage.
#define VTK_SIZEHINT(...)
void ShallowCopy(vtkCellArray *ca)
Shallow copy ca into this cell array.
void SetData(vtkTypeInt32Array *offsets, vtkTypeInt32Array *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
int GetNextCell(vtkIdType &npts, vtkIdType const *&pts)
void Append(vtkCellArray *src, vtkIdType pointOffset=0)
Append cells from src into this.
vtkIdList * GetPointIds()
Return the list of point ids defining the cell.
void ImportLegacyFormat(vtkIdTypeArray *data)
Import an array of data with the legacy vtkCellArray layout, e.g.
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
vtkIdType EstimateSize(vtkIdType numCells, int maxPtsPerCell)
Utility routines help manage memory of cell array.
abstract class to specify cell behavior
bool IsStorageShareable() const
void SetData(vtkTypeInt64Array *offsets, vtkTypeInt64Array *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
void Squeeze()
Reclaim any extra memory while preserving data.
bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize)
Pre-allocate memory in internal data structures.
bool ConvertToDefaultStorage()
Convert internal data structures to use 32- or 64-bit storage.
void ImportLegacyFormat(const vtkIdType *data, vtkIdType len)
Import an array of data with the legacy vtkCellArray layout, e.g.
a simple class to control print indentation
const VisitState< ArrayType64 > & GetArrays64() const
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, type information, and printing.
object to represent cell connectivity
Remove all duplicate types from TypeList TList, storing the new list in Result.
vtkIdType GetEndOffset(vtkIdType cellId) const
void UseDefaultStorage()
Initialize internal data structures to use 32- or 64-bit storage.
vtkIdType operator()(CellStateT &state, const vtkIdType npts)
void InsertCellPoint(vtkIdType id)
Used in conjunction with InsertNextCell(npts) to add another point to the list of cells.
void SetTraversalCellId(vtkIdType cellId)
Get/Set the current cellId for traversal.
list of point or cell ids
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
bool IsStorage64Bit() const
bool ResizeExact(vtkIdType numCells, vtkIdType connectivitySize)
ResizeExact() resizes the internal structures to hold numCells total cell offsets and connectivitySiz...
vtkIdType operator()(CellStateT &state, const vtkIdType cellId)
bool ConvertTo64BitStorage()
Convert internal data structures to use 32- or 64-bit storage.
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
void operator()(CellStateT &state)
vtkNew< vtkIdTypeArray > LegacyData
void Visit(Functor &&functor, Args &&... args)
vtkIdType GetNumberOfOffsets() const
Get the number of elements in the offsets array.
const ArrayType * GetConnectivity() const
void operator()(CellStateT &state, const vtkIdType npts)
void SetData(vtkAOSDataArrayTemplate< long > *offsets, vtkAOSDataArrayTemplate< long > *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
dynamic, self-adjusting array of vtkIdType
vtkIdType GetSize()
Get the size of the allocated connectivity array.
static vtkCellArray * New()
Standard methods for instantiation, type information, and printing.
void ExportLegacyFormat(vtkIdTypeArray *data)
Fill data with the old-style vtkCellArray data layout, e.g.
virtual void SetNumberOfCells(vtkIdType)
Set the number of cells in the array.
void Visit(Functor &&functor, Args &&... args) const
const ArrayType * GetOffsets() const
vtkTypeList::Create< ArrayType32, ArrayType64 > StorageArrayList
List of possible array types used for storage.
void AppendLegacyFormat(const vtkIdType *data, vtkIdType len, vtkIdType ptOffset=0)
Append an array of data with the legacy vtkCellArray layout, e.g.
vtkIdType InsertNextCell(vtkCell *cell)
Insert a cell object.
const VisitState< ArrayType32 > & GetArrays32() const
decltype(vtk::DataArrayValueRange< 1 >(std::declval< ArrayType >())) CellRangeType
vtkDataArray * GetOffsetsArray()
Return the array used to store cell offsets.
static bool GetUsingMemkind()
A global state flag that controls whether vtkObjects are constructed in the usual way (the default) o...
vtkIdType * GetPointer(const vtkIdType i)
Get a pointer to a particular data index.
void DeepCopy(vtkCellArray *ca)
Perform a deep copy (no reference counting) of the given cell array.
bool CanConvertTo64BitStorage() const
Check if the existing data can safely be converted to use 32- or 64- bit storage.
void SetNumberOfIds(const vtkIdType number)
Specify the number of ids for this object to hold.
bool CanConvertTo32BitStorage() const
Check if the existing data can safely be converted to use 32- or 64- bit storage.
void Use64BitStorage()
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.
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
vtkIdType TraversalCellId
ArrayType32 * GetConnectivityArray32()
Return the array used to store the point ids that define the cells' connectivity.
typename ArrayType::ValueType ValueType
void SetData(vtkAOSDataArrayTemplate< int > *offsets, vtkAOSDataArrayTemplate< int > *connectivity)
Set the internal data arrays to the supplied offsets and connectivity arrays.
void PrintDebug(ostream &os)
Standard methods for instantiation, type information, and printing.
VisitState< ArrayType64 > * Int64
vtkDataArray * GetConnectivityArray()
Return the array used to store the point ids that define the cells' connectivity.
void ReverseCellAtId(vtkIdType cellId)
Reverses the order of the point ids for the specified cell.
GetReturnType< Functor, Args... > Visit(Functor &&functor, Args &&... args)
vtkIdType GetNumberOfCells() const
VisitState< ArrayType32 > * Int32
void GetCell(vtkIdType loc, vtkIdType &npts, const vtkIdType *&pts)
Internal method used to retrieve a cell given a legacy offset location.
void Reset()
Reset to an empty state but retain previously allocated memory.
bool ConvertToSmallestStorage()
Convert internal data structures to use 32- or 64-bit storage.
vtkSmartPointer< ArrayType > Offsets
vtkNew< vtkIdList > TempCell
vtkIdType GetTraversalCellId()
Get/Set the current cellId for traversal.