129 #ifndef vtkCellArray_h
130 #define vtkCellArray_h
132 #include "vtkCommonDataModelModule.h"
138 #include "vtkFeatures.h"
140 #include "vtkTypeInt32Array.h"
141 #include "vtkTypeInt64Array.h"
145 #include <initializer_list>
146 #include <type_traits>
169 #define VTK_CELL_ARRAY_V2
171 VTK_ABI_NAMESPACE_BEGIN
189 void PrintDebug(ostream& os);
224 return this->AllocateExact(sz, sz) ? 1 : 0;
238 return this->AllocateExact(numCells, numCells * maxCellSize);
392 void SetData(vtkTypeInt32Array* offsets, vtkTypeInt32Array* connectivity);
393 void SetData(vtkTypeInt64Array* offsets, vtkTypeInt64Array* connectivity);
457 void Use32BitStorage();
458 void Use64BitStorage();
459 void UseDefaultStorage();
470 bool CanConvertTo32BitStorage()
const;
471 bool CanConvertTo64BitStorage()
const;
472 bool CanConvertToDefaultStorage()
const;
491 bool ConvertTo32BitStorage();
492 bool ConvertTo64BitStorage();
493 bool ConvertToDefaultStorage();
494 bool ConvertToSmallestStorage();
506 return this->GetOffsetsArray64();
510 return this->GetOffsetsArray32();
527 return this->GetConnectivityArray64();
531 return this->GetConnectivityArray32();
557 void InitTraversal();
619 VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells());
652 return this->InsertNextCell(static_cast<vtkIdType>(cell.size()), cell.begin());
673 void UpdateCellCount(
int npts);
683 void SetTraversalCellId(
vtkIdType cellId);
722 return this->ReplaceCellAtId(cellId, static_cast<vtkIdType>(cell.size()), cell.begin());
729 int GetMaxCellSize();
797 unsigned long GetActualMemorySize() const;
805 template <
typename ArrayT>
810 using CellRangeType = decltype(vtk::DataArrayValueRange<1>(std::declval<ArrayType>()));
834 CellRangeType GetCellRange(
vtkIdType cellId);
843 this->Offsets->InsertNextValue(0);
846 this->IsInMemkind =
true;
850 void*
operator new(
size_t nSize)
853 #ifdef VTK_USE_MEMKIND
860 void operator delete(
void* p)
862 #ifdef VTK_USE_MEMKIND
883 bool IsInMemkind =
false;
887 template <
typename Functor,
typename... Args>
888 using GetReturnType = decltype(
891 template <
typename Functor,
typename... Args>
892 struct ReturnsVoid : std::is_same<GetReturnType<Functor, Args...>, void>
966 template <
typename Functor,
typename... Args,
967 typename =
typename std::enable_if<ReturnsVoid<Functor, Args...>
::value>
::type>
968 void Visit(Functor&& functor, Args&&... args)
986 template <
typename Functor,
typename... Args,
987 typename =
typename std::enable_if<ReturnsVoid<Functor, Args...>
::value>
::type>
988 void Visit(Functor&& functor, Args&&... args)
const
1006 template <
typename Functor,
typename... Args,
1007 typename =
typename std::enable_if<!ReturnsVoid<Functor, Args...>
::value>
::type>
1008 GetReturnType<Functor, Args...>
Visit(Functor&& functor, Args&&... args)
1025 template <
typename Functor,
typename... Args,
1026 typename =
typename std::enable_if<!ReturnsVoid<Functor, Args...>
::value>
::type>
1027 GetReturnType<Functor, Args...>
Visit(Functor&& functor, Args&&... args)
const
1047 #endif // __VTK_WRAP__
1058 virtual void SetNumberOfCells(
vtkIdType);
1089 vtkIdType GetNumberOfConnectivityEntries();
1110 VTK_EXPECTS(0 <= loc && loc < GetNumberOfConnectivityEntries());
1129 void SetTraversalLocation(
vtkIdType loc);
1139 void ReverseCell(
vtkIdType loc)
VTK_EXPECTS(0 <= loc && loc < GetNumberOfConnectivityEntries());
1189 ~vtkCellArray() override;
1205 #ifdef VTK_USE_MEMKIND
1213 #ifdef VTK_USE_64BIT_IDS
1216 this->StorageIs64Bit =
true;
1218 #else // VTK_USE_64BIT_IDS
1221 this->StorageIs64Bit =
false;
1223 #endif // VTK_USE_64BIT_IDS
1224 #ifdef VTK_USE_MEMKIND
1227 this->IsInMemkind =
true;
1230 (void)this->IsInMemkind;
1236 if (this->StorageIs64Bit)
1238 this->Arrays->Int64->~VisitState();
1239 delete this->Arrays->Int64;
1243 this->Arrays->Int32->~VisitState();
1244 delete this->Arrays->Int32;
1246 #ifdef VTK_USE_MEMKIND
1247 if (this->IsInMemkind)
1256 delete this->Arrays;
1264 if (!this->StorageIs64Bit)
1269 this->Arrays->Int64->~VisitState();
1270 delete this->Arrays->Int64;
1272 this->StorageIs64Bit =
false;
1281 if (this->StorageIs64Bit)
1286 this->Arrays->Int32->~VisitState();
1287 delete this->Arrays->Int32;
1289 this->StorageIs64Bit =
true;
1295 bool Is64Bit()
const {
return this->StorageIs64Bit; }
1300 assert(!this->StorageIs64Bit);
1301 return *this->Arrays->Int32;
1306 assert(!this->StorageIs64Bit);
1307 return *this->Arrays->Int32;
1313 assert(this->StorageIs64Bit);
1314 return *this->Arrays->Int64;
1319 assert(this->StorageIs64Bit);
1320 return *this->Arrays->Int64;
1326 ArraySwitch* Arrays;
1327 bool StorageIs64Bit;
1328 bool IsInMemkind =
false;
1342 template <
typename ArrayT>
1345 return this->Offsets->GetNumberOfValues() - 1;
1348 template <
typename ArrayT>
1351 return static_cast<vtkIdType>(this->Offsets->GetValue(cellId));
1354 template <
typename ArrayT>
1357 return static_cast<vtkIdType>(this->Offsets->GetValue(cellId + 1));
1360 template <
typename ArrayT>
1363 return this->GetEndOffset(cellId) - this->GetBeginOffset(cellId);
1366 template <
typename ArrayT>
1370 return vtk::DataArrayValueRange<1>(
1371 this->
GetConnectivity(), this->GetBeginOffset(cellId), this->GetEndOffset(cellId));
1373 VTK_ABI_NAMESPACE_END
1377 VTK_ABI_NAMESPACE_BEGIN
1382 template <
typename CellStateT>
1385 using ValueType =
typename CellStateT::ValueType;
1386 auto* conn = state.GetConnectivity();
1387 auto* offsets = state.GetOffsets();
1389 const vtkIdType cellId = offsets->GetNumberOfValues() - 1;
1391 offsets->InsertNextValue(static_cast<ValueType>(conn->GetNumberOfValues() + npts));
1395 conn->InsertNextValue(static_cast<ValueType>(pts[i]));
1402 template <
typename CellStateT>
1405 using ValueType =
typename CellStateT::ValueType;
1406 auto* conn = state.GetConnectivity();
1407 auto* offsets = state.GetOffsets();
1409 const vtkIdType cellId = offsets->GetNumberOfValues() - 1;
1411 offsets->InsertNextValue(static_cast<ValueType>(conn->GetNumberOfValues() + npts));
1420 template <
typename CellStateT>
1423 using ValueType =
typename CellStateT::ValueType;
1425 auto* offsets = state.GetOffsets();
1426 const ValueType cellBegin = offsets->GetValue(offsets->GetMaxId() - 1);
1427 offsets->SetValue(offsets->GetMaxId(),
static_cast<ValueType
>(cellBegin + npts));
1433 template <
typename CellStateT>
1436 return state.GetCellSize(cellId);
1442 template <
typename CellStateT>
1445 using ValueType =
typename CellStateT::ValueType;
1447 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1448 const vtkIdType endOffset = state.GetEndOffset(cellId);
1449 const vtkIdType cellSize = endOffset - beginOffset;
1450 const auto cellConnectivity = state.GetConnectivity()->GetPointer(beginOffset);
1455 for (ValueType i = 0; i < cellSize; ++i)
1457 idPtr[i] =
static_cast<vtkIdType>(cellConnectivity[i]);
1463 template <
typename CellStateT>
1467 using ValueType =
typename CellStateT::ValueType;
1468 using ArrayType =
typename CellStateT::ArrayType;
1470 static constexpr
bool ValueTypeCompat = CellStateT::ValueTypeIsSameAsIdType;
1474 static constexpr
bool value = ValueTypeCompat && ArrayTypeCompat;
1477 template <
typename CellStateT>
1482 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1483 const vtkIdType endOffset = state.GetEndOffset(cellId);
1484 cellSize = endOffset - beginOffset;
1486 cellPoints =
reinterpret_cast<vtkIdType*
>(state.GetConnectivity()->GetPointer(beginOffset));
1489 template <
typename CellStateT>
1494 using ValueType =
typename CellStateT::ValueType;
1496 const vtkIdType beginOffset = state.GetBeginOffset(cellId);
1497 const vtkIdType endOffset = state.GetEndOffset(cellId);
1498 cellSize = endOffset - beginOffset;
1499 const ValueType* cellConnectivity = state.GetConnectivity()->GetPointer(beginOffset);
1504 for (
vtkIdType i = 0; i < cellSize; ++i)
1506 tempPtr[i] =
static_cast<vtkIdType>(cellConnectivity[i]);
1515 template <
typename CellStateT>
1518 state.GetOffsets()->Reset();
1519 state.GetConnectivity()->Reset();
1520 state.GetOffsets()->InsertNextValue(0);
1524 VTK_ABI_NAMESPACE_END
1527 VTK_ABI_NAMESPACE_BEGIN
1537 if (this->TraversalCellId < this->GetNumberOfCells())
1539 this->GetCellAtId(this->TraversalCellId, npts, pts);
1540 ++this->TraversalCellId;
1606 using ValueType =
typename ArrayType64::ValueType;
1611 using ValueType =
typename ArrayType32::ValueType;
1643 VTK_ABI_NAMESPACE_END
1644 #endif // vtkCellArray.h
ArrayType64 * GetConnectivityArray64()
Return the array used to store the point ids that define the cells' connectivity. ...
vtkIdType GetCellSize(vtkIdType cellId) const
Return the size of the cell at cellId.
vtkTypeBool Allocate(vtkIdType sz, vtkIdType vtkNotUsed(ext)=1000)
Allocate memory.
ArrayType32 * GetConnectivityArray32()
Return the array used to store the point ids that define the cells' connectivity. ...
vtkIdType operator()(CellStateT &state, const vtkIdType npts)
vtkDataArray * GetConnectivityArray()
Return the array used to store the point ids that define the cells' connectivity. ...
static vtkFreeingFunction GetAlternateFreeFunction()
ArrayType * GetConnectivity()
abstract base class for most VTK objects
Remove all duplicate types from TypeList TList, storing the new list in Result.
decltype(vtk::DataArrayValueRange< 1 >(std::declval< ArrayType >())) CellRangeType
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIdType GetNumberOfCells() const
void InsertCellPoint(vtkIdType id)
Used in conjunction with InsertNextCell(npts) to add another point to the list of cells...
bool IsStorageShareable() const
void operator()(CellStateT &state)
GetReturnType< Functor, Args... > Visit(Functor &&functor, Args &&...args)
vtkNew< vtkIdTypeArray > LegacyData
vtkIdType GetNumberOfCells() const
Get the number of cells in the array.
void Reset()
Reset to an empty state but retain previously allocated memory.
vtkSmartPointer< ArrayType > Connectivity
const ArrayType * GetOffsets() const
vtkTypeList::Create< ArrayType32, ArrayType64 > StorageArrayList
List of possible array types used for storage.
ArrayType32 * GetOffsetsArray32()
Return the array used to store cell offsets.
dynamic, self-adjusting array of vtkIdType
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
vtkIdType TraversalCellId
const ArrayType * GetConnectivity() const
typename vtkTypeList::detail::CreateImpl< Ts... >::type Create
bool AllocateCopy(vtkCellArray *other)
Pre-allocate memory in internal data structures to match the used size of the input vtkCellArray...
vtkNew< vtkIdList > TempCell
abstract class to specify cell behavior
void operator()(CellStateT &state, const vtkIdType npts)
a simple class to control print indentation
void operator()(CellStateT &state, const vtkIdType cellId, vtkIdList *ids)
static bool GetUsingMemkind()
A global state flag that controls whether vtkObjects are constructed in the usual way (the default) o...
list of point or cell ids
vtkIdType GetOffset(vtkIdType cellId)
Get the offset (into the connectivity) for a specified cell id.
abstract superclass for arrays of numeric data
typename vtkTypeList::Unique< vtkTypeList::Create< vtkAOSDataArrayTemplate< int >, vtkAOSDataArrayTemplate< long >, vtkAOSDataArrayTemplate< long long >>>::Result InputArrayList
List of possible ArrayTypes that are compatible with internal storage.
vtkIdType GetNumberOfConnectivityIds() const
Get the size of the connectivity array that stores the point ids.
vtkTypeInt64Array ArrayType64
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
vtkIdType GetEndOffset(vtkIdType cellId) const
#define VTK_SIZEHINT(...)
bool IsStorage64Bit() const
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.
void UpdateCellCount(int npts)
Used in conjunction with InsertNextCell(int npts) and InsertCellPoint() to update the number of point...
CellRangeType GetCellRange(vtkIdType cellId)
vtkIdType operator()(CellStateT &state, vtkIdType cellId)
vtkIdType InsertNextCell(vtkCell *cell)
Insert a cell object.
vtkSmartPointer< vtkCellArray > GetConnectivity(Ioss::GroupingEntity *group_entity, int &vtk_topology_type, Cache *cache=nullptr)
Read connectivity information from the group_entity.
std::enable_if< CanShareConnPtr< CellStateT >::value, void >::type operator()(CellStateT &state, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *vtkNotUsed(temp))
vtkSmartPointer< ArrayType > Offsets
void Visit(Functor &&functor, Args &&...args)
VisitState< ArrayType64 > & GetArrays64()
vtkDataArray * GetOffsetsArray()
Return the array used to store cell offsets.
object to represent cell connectivity
vtkTypeInt32Array ArrayType32
typename ArrayType::ValueType ValueType
vtkIdType GetCellSize(vtkIdType cellId) const
std::enable_if<!CanShareConnPtr< CellStateT >::value, void >::type operator()(CellStateT &state, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *temp)
ArrayType64 * GetOffsetsArray64()
Return the array used to store cell offsets.
vtkIdList * GetPointIds()
Return the list of point ids defining the cell.
VisitState< ArrayType32 > * Int32
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints)
Return the point ids for the cell at cellId.
GetReturnType< Functor, Args... > Visit(Functor &&functor, Args &&...args) const
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
VisitState< ArrayType32 > & GetArrays32()
static vtkMallocingFunction GetCurrentMallocFunction()
VisitState< ArrayType64 > * Int64
vtkIdType operator()(CellStateT &state, const vtkIdType npts, const vtkIdType pts[])
vtkIdType GetBeginOffset(vtkIdType cellId) const
const VisitState< ArrayType32 > & GetArrays32() const
void SetNumberOfIds(vtkIdType number)
Specify the number of ids for this object to hold.
Encapsulate traversal logic for vtkCellArray.
void Visit(Functor &&functor, Args &&...args) const
vtkIdType GetNumberOfOffsets() const
Get the number of elements in the offsets array.
STL-compatible iterable ranges that provide access to vtkDataArray elements.
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
int GetNextCell(vtkIdType &npts, vtkIdType const *&pts)
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
const VisitState< ArrayType64 > & GetArrays64() const