VTK  9.7.1
vtkCellArray.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
127 #ifndef vtkCellArray_h
128 #define vtkCellArray_h
129 
130 #include "vtkAbstractCellArray.h"
131 #include "vtkCommonDataModelModule.h" // For export macro
132 #include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
133 
134 #include "vtkAOSDataArrayTemplate.h" // Needed for inline methods
135 #include "vtkAffineArray.h" // Needed for inline methods
136 #include "vtkCell.h" // Needed for inline methods
137 #include "vtkDataArrayAccessor.h" // Needed for inline methods
138 #include "vtkDataArrayRange.h" // Needed for inline methods
139 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_6_0
140 #include "vtkFeatures.h" // for VTK_USE_MEMKIND
141 #include "vtkSmartPointer.h" // For vtkSmartPointer
142 #include "vtkTypeInt32Array.h" // Needed for inline methods
143 #include "vtkTypeInt64Array.h" // Needed for inline methods
144 #include "vtkTypeList.h" // Needed for ArrayList definition
145 
146 #include <cassert> // Needed for assert
147 #include <initializer_list> // Needed for API
148 #include <type_traits> // Needed for std::is_same
149 #include <utility> // Needed for std::forward
150 
171 #define VTK_CELL_ARRAY_V2
172 
173 VTK_ABI_NAMESPACE_BEGIN
175 class vtkIdTypeArray;
176 
177 class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkCellArray : public vtkAbstractCellArray
178 {
179 public:
180  using ArrayType32 VTK_DEPRECATED_IN_9_6_0("Use AOSArray32 instead.") = vtkTypeInt32Array;
181  using ArrayType64 VTK_DEPRECATED_IN_9_6_0("Use AOSArray64 instead.") = vtkTypeInt64Array;
186 
188 
192  static vtkCellArray* New();
194  void PrintSelf(ostream& os, vtkIndent indent) override;
195  void PrintDebug(ostream& os);
197 
199 
208  "Use vtkArrayDispatch::OffsetsArrays/ConnectivityArrays instead.") =
211 
213 
225 
234  VTK_DEPRECATED_IN_9_6_0("Use AllocateEstimate or AllocateExact instead.")
235  vtkTypeBool Allocate(vtkIdType sz, vtkIdType vtkNotUsed(ext) = 1000)
236  {
237  return this->AllocateExact(sz, sz) ? 1 : 0;
238  }
239 
249  bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
250  {
251  return this->AllocateExact(numCells, numCells * maxCellSize);
252  }
253 
263  bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
264 
275  {
276  return this->AllocateExact(other->GetNumberOfCells(), other->GetNumberOfConnectivityIds());
277  }
278 
288  bool ResizeExact(vtkIdType numCells, vtkIdType connectivitySize);
289 
293  void Initialize() override;
294 
298  void Reset();
299 
305  void Squeeze();
306 
317  bool IsValid();
318 
322  vtkIdType GetNumberOfCells() const override { return this->Offsets->GetNumberOfValues() - 1; }
323 
328  vtkIdType GetNumberOfOffsets() const override { return this->Offsets->GetNumberOfValues(); }
329 
333  vtkIdType GetOffset(vtkIdType cellId) override
334  {
335  return static_cast<vtkIdType>(this->Offsets->GetComponent(cellId, 0));
336  }
337 
342  {
343  this->Offsets->SetComponent(cellId, 0, static_cast<double>(offset));
344  }
345 
350  {
351  return this->Connectivity->GetNumberOfValues();
352  }
353 
359  VTK_NEWINSTANCE vtkCellArrayIterator* NewIterator();
360 
362 
375  void SetData(AOSArray32*, AOSArray32* connectivity);
376  void SetData(AOSArray64*, AOSArray64* connectivity);
377  void SetData(AffineArray32*, AOSArray32* connectivity);
378  void SetData(AffineArray64*, AOSArray64* connectivity);
380 
395  bool SetData(vtkDataArray* offsets, vtkDataArray* connectivity);
396 
414  bool SetData(vtkIdType cellSize, vtkDataArray* connectivity);
415 
417  {
423  };
424 
428  StorageTypes GetStorageType() const noexcept { return this->StorageType; }
429 
433  bool IsStorage64Bit() const { return this->StorageType == StorageTypes::Int64; }
434 
438  bool IsStorage32Bit() const { return this->StorageType == StorageTypes::Int32; }
439 
443  bool IsStorageFixedSize64Bit() const { return this->StorageType == StorageTypes::FixedSizeInt64; }
444 
448  bool IsStorageFixedSize32Bit() const { return this->StorageType == StorageTypes::FixedSizeInt32; }
449 
453  bool IsStorageFixedSize() const
454  {
455  return this->IsStorageFixedSize32Bit() || this->IsStorageFixedSize64Bit();
456  }
457 
461  bool IsStorageGeneric() const { return this->StorageType == StorageTypes::Generic; }
462 
469  bool IsStorageShareable() const override
470  {
471  switch (this->StorageType)
472  {
473  case StorageTypes::Int32:
474  case StorageTypes::FixedSizeInt32:
475  return std::is_same_v<vtkTypeInt32, vtkIdType>;
476  case StorageTypes::Int64:
477  case StorageTypes::FixedSizeInt64:
478  return std::is_same_v<vtkTypeInt64, vtkIdType>;
479  case StorageTypes::Generic:
480  default:
481  return false;
482  }
483  }
484 
493  void Use32BitStorage();
494  void Use64BitStorage();
495  void UseDefaultStorage();
496  void UseFixedSize32BitStorage(vtkIdType cellSize);
497  void UseFixedSize64BitStorage(vtkIdType cellSize);
498  void UseFixedSizeDefaultStorage(vtkIdType cellSize);
509  bool CanConvertTo32BitStorage() const;
510  bool CanConvertTo64BitStorage() const;
511  bool CanConvertToDefaultStorage() const;
512  bool CanConvertToFixedSize32BitStorage() const;
513  bool CanConvertToFixedSize64BitStorage() const;
514  bool CanConvertToFixedSizeDefaultStorage() const;
516  {
517  switch (type)
518  {
519  case StorageTypes::Int32:
520  return this->CanConvertTo32BitStorage();
521  case StorageTypes::Int64:
522  return this->CanConvertTo64BitStorage();
523  case StorageTypes::FixedSizeInt32:
524  return this->CanConvertToFixedSize32BitStorage();
525  case StorageTypes::FixedSizeInt64:
526  return this->CanConvertToFixedSize64BitStorage();
527  case StorageTypes::Generic:
528  default:
529  return true;
530  }
531  }
550  bool ConvertTo32BitStorage();
551  bool ConvertTo64BitStorage();
552  bool ConvertToDefaultStorage();
553  bool ConvertToFixedSize32BitStorage();
554  bool ConvertToFixedSize64BitStorage();
555  bool ConvertToFixedSizeDefaultStorage();
556  bool ConvertToSmallestStorage();
558  {
559  switch (type)
560  {
561  case StorageTypes::Int32:
562  return this->ConvertTo32BitStorage();
563  case StorageTypes::Int64:
564  return this->ConvertTo64BitStorage();
565  case StorageTypes::FixedSizeInt32:
566  return this->ConvertToFixedSize32BitStorage();
567  case StorageTypes::FixedSizeInt64:
568  return this->ConvertToFixedSize64BitStorage();
569  case StorageTypes::Generic:
570  default:
571  return true;
572  }
573  }
581  vtkDataArray* GetOffsetsArray() const { return this->Offsets; }
582  VTK_DEPRECATED_IN_9_6_0("Use GetOffsetsAOSArray32() instead.")
583  vtkTypeInt32Array* GetOffsetsArray32() const
584  {
585  return vtkTypeInt32Array::FastDownCast(this->Offsets);
586  }
587  AOSArray32* GetOffsetsAOSArray32() const { return AOSArray32::FastDownCast(this->Offsets); }
588  VTK_DEPRECATED_IN_9_6_0("Use GetOffsetsAOSArray64() instead.")
589  vtkTypeInt64Array* GetOffsetsArray64() const
590  {
591  return vtkTypeInt64Array::FastDownCast(this->Offsets);
592  }
593  AOSArray64* GetOffsetsAOSArray64() const { return AOSArray64::FastDownCast(this->Offsets); }
595  {
596  return AffineArray32::FastDownCast(this->Offsets);
597  }
599  {
600  return AffineArray64::FastDownCast(this->Offsets);
601  }
610  vtkDataArray* GetConnectivityArray() const { return this->Connectivity; }
611  VTK_DEPRECATED_IN_9_6_0("Use GetConnectivityAOSArray32() instead.")
612  vtkTypeInt32Array* GetConnectivityArray32() const
613  {
614  return vtkTypeInt32Array::FastDownCast(this->Connectivity);
615  }
617  {
618  return AOSArray32::FastDownCast(this->Connectivity);
619  }
620  VTK_DEPRECATED_IN_9_6_0("Use GetConnectivityAOSArray64() instead.")
621  vtkTypeInt64Array* GetConnectivityArray64() const
622  {
623  return vtkTypeInt64Array::FastDownCast(this->Connectivity);
624  }
626  {
627  return AOSArray64::FastDownCast(this->Connectivity);
628  }
639  vtkIdType IsHomogeneous() const override;
640 
650  void InitTraversal();
651 
666  int GetNextCell(vtkIdType& npts, vtkIdType const*& pts) VTK_SIZEHINT(pts, npts);
667 
678  int GetNextCell(vtkIdList* pts);
679 
690  inline void GetCellAtId(vtkIdType cellId, vtkIdType& cellSize, vtkIdType const*& cellPoints,
691  vtkIdList* ptIds) VTK_SIZEHINT(cellPoints, cellSize)
692  VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells()) override;
693 
699  inline void GetCellAtId(vtkIdType cellId, vtkIdList* pts)
700  VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells()) override;
701 
709  inline void GetCellAtId(vtkIdType cellId, vtkIdType& cellSize, vtkIdType* cellPoints)
710  VTK_SIZEHINT(cellPoints, cellSize)
711  VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells()) override;
712 
716  vtkIdType GetCellPointAtId(vtkIdType cellId, vtkIdType cellPointIndex) const
717  VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells())
718  VTK_EXPECTS(0 <= cellPointIndex && cellPointIndex < this->GetCellSize(cellId));
719 
723  vtkIdType GetCellSize(vtkIdType cellId) const override;
724 
728  inline vtkIdType InsertNextCell(vtkCell* cell);
729 
734  inline vtkIdType InsertNextCell(vtkIdType npts, const vtkIdType* pts) VTK_SIZEHINT(pts, npts);
735 
740  inline vtkIdType InsertNextCell(vtkIdList* pts);
741 
749  vtkIdType InsertNextCell(const std::initializer_list<vtkIdType>& cell)
750  {
751  return this->InsertNextCell(static_cast<vtkIdType>(cell.size()), cell.begin());
752  }
753 
760  inline vtkIdType InsertNextCell(int npts);
761 
766  void InsertCellPoint(vtkIdType id);
767 
772  void UpdateCellCount(int npts);
773 
781  vtkIdType GetTraversalCellId();
782  void SetTraversalCellId(vtkIdType cellId);
788  void ReverseCellAtId(vtkIdType cellId) VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells());
789 
798  void ReplaceCellAtId(vtkIdType cellId, vtkIdList* list);
799  void ReplaceCellAtId(vtkIdType cellId, vtkIdType cellSize, const vtkIdType* cellPoints)
800  VTK_EXPECTS(0 <= cellId && cellId < GetNumberOfCells()) VTK_SIZEHINT(cellPoints, cellSize);
810  void ReplaceCellPointAtId(vtkIdType cellId, vtkIdType cellPointIndex, vtkIdType newPointId);
811 
819  void ReplaceCellAtId(vtkIdType cellId, const std::initializer_list<vtkIdType>& cell)
820  {
821  this->ReplaceCellAtId(cellId, static_cast<vtkIdType>(cell.size()), cell.begin());
822  }
823 
828  int GetMaxCellSize() override;
829 
833  void DeepCopy(vtkAbstractCellArray* ca) override;
834 
838  void ShallowCopy(vtkAbstractCellArray* ca) override;
839 
843  void Append(vtkCellArray* src, vtkIdType pointOffset = 0);
844 
855  void ExportLegacyFormat(vtkIdTypeArray* data);
856 
868  void ImportLegacyFormat(vtkIdTypeArray* data);
869  void ImportLegacyFormat(const vtkIdType* data, vtkIdType len) VTK_SIZEHINT(data, len);
883  void AppendLegacyFormat(vtkIdTypeArray* data, vtkIdType ptOffset = 0);
884  void AppendLegacyFormat(const vtkIdType* data, vtkIdType len, vtkIdType ptOffset = 0)
885  VTK_SIZEHINT(data, len);
896  unsigned long GetActualMemorySize() const;
897 
898  // The following code is used to support
899 
900  // The wrappers get understandably confused by some of the template code below
901 #ifndef __VTK_WRAP__
902  /*
903  * Utilities class that every dispatch functor used with Dispatch() must inherit
904  * or optionally use its static methods.
905  */
907  {
908  template <class ArrayT>
910 
911  template <class OffsetsT>
912  vtkIdType GetNumberOfCells(OffsetsT* offsets)
913  {
914  return offsets->GetNumberOfValues() - 1;
915  }
916 
917  template <class ArrayT>
918  static decltype(vtk::DataArrayValueRange<1, vtkIdType>(std::declval<ArrayT>())) GetRange(
919  ArrayT* array)
920  {
921  return vtk::DataArrayValueRange<1, vtkIdType>(array);
922  }
923 
924  template <class OffsetsT>
925  static vtkIdType GetBeginOffset(OffsetsT* offsets, vtkIdType cellId)
926  {
927  return static_cast<vtkIdType>(GetRange(offsets)[cellId]);
928  }
929 
930  template <class OffsetsT>
931  static vtkIdType GetEndOffset(OffsetsT* offsets, vtkIdType cellId)
932  {
933  return static_cast<vtkIdType>(GetRange(offsets)[cellId + 1]);
934  }
935 
936  template <class OffsetsT>
937  static vtkIdType GetCellSize(OffsetsT* offsets, vtkIdType cellId)
938  {
939  auto offsetsRange = GetRange(offsets);
940  return static_cast<vtkIdType>(offsetsRange[cellId + 1] - offsetsRange[cellId]);
941  }
942 
943  template <class OffsetsT, class ConnectivityT>
944  static decltype(vtk::DataArrayValueRange<1, vtkIdType>(std::declval<ConnectivityT>()))
945  GetCellRange(OffsetsT* offsets, ConnectivityT* conn, vtkIdType cellId)
946  {
947  auto offsetsRange = GetRange(offsets);
948  return vtk::DataArrayValueRange<1, vtkIdType>(
949  conn, offsetsRange[cellId], offsetsRange[cellId + 1]);
950  }
951  };
952 
954 
1017  template <typename Functor, typename... Args>
1018  void Dispatch(Functor&& functor, Args&&... args)
1019  {
1020  switch (this->StorageType)
1021  {
1022  case StorageTypes::Int32:
1023  functor(static_cast<AOSArray32*>(this->Offsets.Get()),
1024  static_cast<AOSArray32*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1025  break;
1026  case StorageTypes::Int64:
1027  functor(static_cast<AOSArray64*>(this->Offsets.Get()),
1028  static_cast<AOSArray64*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1029  break;
1030  case StorageTypes::FixedSizeInt32:
1031  functor(static_cast<AffineArray32*>(this->Offsets.Get()),
1032  static_cast<AOSArray32*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1033  break;
1034  case StorageTypes::FixedSizeInt64:
1035  functor(static_cast<AffineArray64*>(this->Offsets.Get()),
1036  static_cast<AOSArray64*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1037  break;
1038  case StorageTypes::Generic:
1039  default:
1040  functor(this->Offsets.Get(), this->Connectivity.Get(), std::forward<Args>(args)...);
1041  break;
1042  }
1043  }
1044  template <typename Functor, typename... Args>
1045  void Dispatch(Functor&& functor, Args&&... args) const
1046  {
1047  switch (this->StorageType)
1048  {
1049  case StorageTypes::Int32:
1050  functor(static_cast<AOSArray32*>(this->Offsets.Get()),
1051  static_cast<AOSArray32*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1052  break;
1053  case StorageTypes::Int64:
1054  functor(static_cast<AOSArray64*>(this->Offsets.Get()),
1055  static_cast<AOSArray64*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1056  break;
1057  case StorageTypes::FixedSizeInt32:
1058  functor(static_cast<AffineArray32*>(this->Offsets.Get()),
1059  static_cast<AOSArray32*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1060  break;
1061  case StorageTypes::FixedSizeInt64:
1062  functor(static_cast<AffineArray64*>(this->Offsets.Get()),
1063  static_cast<AOSArray64*>(this->Connectivity.Get()), std::forward<Args>(args)...);
1064  break;
1065  case StorageTypes::Generic:
1066  default:
1067  functor(this->Offsets.Get(), this->Connectivity.Get(), std::forward<Args>(args)...);
1068  break;
1069  }
1070  }
1072 
1073  // Holds connectivity and offset arrays of the given ArrayType.
1074  // VTK_DEPRECATED_IN_9_6_0("Use DispatchUtilities")
1075  template <typename ArrayT>
1076  struct VisitState
1077  {
1078  using ArrayType = ArrayT;
1079  using ValueType = typename ArrayType::ValueType;
1080  using CellRangeType = decltype(vtk::DataArrayValueRange<1>(std::declval<ArrayType>()));
1081 
1082  // We can't just use is_same here, since binary compatible representations
1083  // (e.g. int and long) are distinct types. Instead, ensure that ValueType
1084  // is a signed integer the same size as vtkIdType.
1085  // If this value is true, ValueType pointers may be safely converted to
1086  // vtkIdType pointers via reinterpret cast.
1087  static constexpr bool ValueTypeIsSameAsIdType = std::is_integral<ValueType>::value &&
1088  std::is_signed<ValueType>::value && (sizeof(ValueType) == sizeof(vtkIdType));
1089 
1090  ArrayType* GetOffsets() { return this->Offsets; }
1091  const ArrayType* GetOffsets() const { return this->Offsets; }
1092 
1093  ArrayType* GetConnectivity() { return this->Connectivity; }
1094  const ArrayType* GetConnectivity() const { return this->Connectivity; }
1095 
1096  vtkIdType GetNumberOfCells() const;
1097 
1098  vtkIdType GetBeginOffset(vtkIdType cellId) const;
1099 
1100  vtkIdType GetEndOffset(vtkIdType cellId) const;
1101 
1102  vtkIdType GetCellSize(vtkIdType cellId) const;
1103 
1104  CellRangeType GetCellRange(vtkIdType cellId);
1105 
1106  friend class vtkCellArray;
1107 
1108  protected:
1110  {
1113  this->Offsets->InsertNextValue(0);
1115  {
1116  this->IsInMemkind = true;
1117  }
1118  }
1119  ~VisitState() = default;
1120  void* operator new(size_t nSize)
1121  {
1122  void* r;
1123 #ifdef VTK_USE_MEMKIND
1125 #else
1126  r = malloc(nSize);
1127 #endif
1128  return r;
1129  }
1130  void operator delete(void* p)
1131  {
1132 #ifdef VTK_USE_MEMKIND
1133  VisitState* a = static_cast<VisitState*>(p);
1134  if (a->IsInMemkind)
1135  {
1137  }
1138  else
1139  {
1140  free(p);
1141  }
1142 #else
1143  free(p);
1144 #endif
1145  }
1146 
1149 
1150  private:
1151  VisitState(const VisitState&) = delete;
1152  VisitState& operator=(const VisitState&) = delete;
1153  bool IsInMemkind = false;
1154  };
1155 
1156 private: // Helpers that allow Visit to return a value:
1157  template <typename Functor, typename... Args>
1158  using GetReturnType = decltype(std::declval<Functor>()(
1159  std::declval<VisitState<AOSArray32>&>(), std::declval<Args>()...));
1160 
1161  template <typename Functor, typename... Args>
1162  struct ReturnsVoid : std::is_same<GetReturnType<Functor, Args...>, void>
1163  {
1164  };
1165 
1166 public:
1236  template <typename Functor, typename... Args,
1237  typename = typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>
1238  VTK_DEPRECATED_IN_9_6_0("Use Dispatch instead")
1239  void Visit(Functor&& functor, Args&&... args)
1240  {
1241  switch (this->StorageType)
1242  {
1243  case StorageTypes::Int32:
1244  {
1245  VisitState<AOSArray32> state;
1246  state.Offsets = AOSArray32::FastDownCast(this->Offsets);
1247  state.Connectivity = AOSArray32::FastDownCast(this->Connectivity);
1248  functor(state, std::forward<Args>(args)...);
1249  break;
1250  }
1251  case StorageTypes::Int64:
1252  {
1253  VisitState<AOSArray64> state;
1254  state.Offsets = AOSArray64::FastDownCast(this->Offsets);
1255  state.Connectivity = AOSArray64::FastDownCast(this->Connectivity);
1256  functor(state, std::forward<Args>(args)...);
1257  break;
1258  }
1259  case StorageTypes::FixedSizeInt32:
1260  case StorageTypes::FixedSizeInt64:
1261  case StorageTypes::Generic:
1262  default:
1263  {
1264  vtkWarningMacro("Use Dispatch");
1265  break;
1266  }
1267  }
1268  }
1269 
1270  template <typename Functor, typename... Args,
1271  typename = typename std::enable_if<ReturnsVoid<Functor, Args...>::value>::type>
1272  VTK_DEPRECATED_IN_9_6_0("Use Dispatch instead")
1273  void Visit(Functor&& functor, Args&&... args) const
1274  {
1275  switch (this->StorageType)
1276  {
1277  case StorageTypes::Int32:
1278  {
1279  VisitState<AOSArray32> state;
1280  state.Offsets = AOSArray32::FastDownCast(this->Offsets);
1281  state.Connectivity = AOSArray32::FastDownCast(this->Connectivity);
1282  functor(state, std::forward<Args>(args)...);
1283  break;
1284  }
1285  case StorageTypes::Int64:
1286  {
1287  VisitState<AOSArray64> state;
1288  state.Offsets = AOSArray64::FastDownCast(this->Offsets);
1289  state.Connectivity = AOSArray64::FastDownCast(this->Connectivity);
1290  functor(state, std::forward<Args>(args)...);
1291  break;
1292  }
1293  case StorageTypes::FixedSizeInt32:
1294  case StorageTypes::FixedSizeInt64:
1295  case StorageTypes::Generic:
1296  default:
1297  {
1298  vtkWarningMacro("Use Dispatch");
1299  break;
1300  }
1301  }
1302  }
1303 
1304  template <typename Functor, typename... Args,
1305  typename = typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>
1306  VTK_DEPRECATED_IN_9_6_0("Use Dispatch instead")
1307  GetReturnType<Functor, Args...> Visit(Functor&& functor, Args&&... args)
1308  {
1309  switch (this->StorageType)
1310  {
1311  case StorageTypes::Int32:
1312  {
1313  VisitState<AOSArray32> state;
1314  state.Offsets = AOSArray32::FastDownCast(this->Offsets);
1315  state.Connectivity = AOSArray32::FastDownCast(this->Connectivity);
1316  return functor(state, std::forward<Args>(args)...);
1317  }
1318  case StorageTypes::Int64:
1319  {
1320  VisitState<AOSArray64> state;
1321  state.Offsets = AOSArray64::FastDownCast(this->Offsets);
1322  state.Connectivity = AOSArray64::FastDownCast(this->Connectivity);
1323  return functor(state, std::forward<Args>(args)...);
1324  }
1325  case StorageTypes::FixedSizeInt32:
1326  case StorageTypes::FixedSizeInt64:
1327  case StorageTypes::Generic:
1328  default:
1329  {
1330  vtkWarningMacro("Use Dispatch");
1331  return GetReturnType<Functor, Args...>();
1332  }
1333  }
1334  }
1335  template <typename Functor, typename... Args,
1336  typename = typename std::enable_if<!ReturnsVoid<Functor, Args...>::value>::type>
1337  VTK_DEPRECATED_IN_9_6_0("Use Dispatch instead")
1338  GetReturnType<Functor, Args...> Visit(Functor&& functor, Args&&... args) const
1339  {
1340  switch (this->StorageType)
1341  {
1342  case StorageTypes::Int32:
1343  {
1344  VisitState<AOSArray32> state;
1345  state.Offsets = AOSArray32::FastDownCast(this->Offsets);
1346  state.Connectivity = AOSArray32::FastDownCast(this->Connectivity);
1347  return functor(state, std::forward<Args>(args)...);
1348  }
1349  case StorageTypes::Int64:
1350  {
1351  VisitState<AOSArray64> state;
1352  state.Offsets = AOSArray64::FastDownCast(this->Offsets);
1353  state.Connectivity = AOSArray64::FastDownCast(this->Connectivity);
1354  return functor(state, std::forward<Args>(args)...);
1355  }
1356  case StorageTypes::FixedSizeInt32:
1357  case StorageTypes::FixedSizeInt64:
1358  case StorageTypes::Generic:
1359  default:
1360  {
1361  vtkWarningMacro("Use Dispatch");
1362  return GetReturnType<Functor, Args...>();
1363  }
1364  }
1365  }
1366 
1367 #endif // __VTK_WRAP__
1368 
1381  //=================== Begin Legacy Methods ===================================
1382  // These should be deprecated at some point as they are confusing or very slow
1383 
1390  VTK_DEPRECATED_IN_9_6_0("This call has no effect.")
1391  virtual void SetNumberOfCells(vtkIdType);
1392 
1404  VTK_DEPRECATED_IN_9_6_0("Use AllocateEstimate directly instead.")
1405  vtkIdType EstimateSize(vtkIdType numCells, int maxPtsPerCell);
1406 
1415  VTK_DEPRECATED_IN_9_6_0("Method incompatible with current internal storage.")
1416  vtkIdType GetSize();
1417 
1424  VTK_DEPRECATED_IN_9_6_0("Method incompatible with current internal storage.")
1425  vtkIdType GetNumberOfConnectivityEntries();
1426 
1436  VTK_DEPRECATED_IN_9_6_0("Use GetCellAtId.")
1437  void GetCell(vtkIdType loc, vtkIdType& npts, const vtkIdType*& pts)
1438  VTK_EXPECTS(0 <= loc && loc < GetNumberOfConnectivityEntries()) VTK_SIZEHINT(pts, npts);
1439 
1446  VTK_DEPRECATED_IN_9_6_0("Use GetCellAtId.")
1447  void GetCell(vtkIdType loc, vtkIdList* pts)
1448  VTK_EXPECTS(0 <= loc && loc < GetNumberOfConnectivityEntries());
1449 
1456  VTK_DEPRECATED_IN_9_6_0("Use GetNumberOfCells.")
1457  vtkIdType GetInsertLocation(int npts);
1458 
1466  VTK_DEPRECATED_IN_9_6_0("Use GetTraversalCellId.")
1467  vtkIdType GetTraversalLocation();
1468  VTK_DEPRECATED_IN_9_6_0("Use GetTraversalCellId.")
1469  vtkIdType GetTraversalLocation(vtkIdType npts);
1470  VTK_DEPRECATED_IN_9_6_0("Use SetTraversalCellId.")
1471  void SetTraversalLocation(vtkIdType loc);
1481  VTK_DEPRECATED_IN_9_6_0("Use ReverseCellAtId.")
1482  void ReverseCell(vtkIdType loc) VTK_EXPECTS(0 <= loc && loc < GetNumberOfConnectivityEntries());
1483 
1495  VTK_DEPRECATED_IN_9_6_0("Use ReplaceCellAtId.")
1496  void ReplaceCell(vtkIdType loc, int npts, const vtkIdType pts[])
1497  VTK_EXPECTS(0 <= loc && loc < GetNumberOfConnectivityEntries()) VTK_SIZEHINT(pts, npts);
1498 
1513  VTK_DEPRECATED_IN_9_6_0("Use ImportLegacyFormat or SetData instead.")
1514  void SetCells(vtkIdType ncells, vtkIdTypeArray* cells);
1515 
1527  "Use ExportLegacyFormat, or GetOffsetsArray/GetConnectivityArray instead.")
1529 
1530  //=================== End Legacy Methods =====================================
1531 
1532  friend class vtkCellArrayIterator;
1533 
1534 protected:
1535  vtkCellArray();
1536  ~vtkCellArray() override;
1537 
1540  StorageTypes StorageType;
1541  vtkIdType TraversalCellId{ 0 };
1542 
1544 
1546 
1547 private:
1548  vtkCellArray(const vtkCellArray&) = delete;
1549  void operator=(const vtkCellArray&) = delete;
1550 };
1551 
1552 template <typename ArrayT>
1554 {
1555  return this->Offsets->GetNumberOfValues() - 1;
1556 }
1557 
1558 template <typename ArrayT>
1560 {
1561  return static_cast<vtkIdType>(this->Offsets->GetValue(cellId));
1562 }
1563 
1564 template <typename ArrayT>
1566 {
1567  return static_cast<vtkIdType>(this->Offsets->GetValue(cellId + 1));
1568 }
1569 
1570 template <typename ArrayT>
1572 {
1573  return this->GetEndOffset(cellId) - this->GetBeginOffset(cellId);
1574 }
1575 
1576 template <typename ArrayT>
1579 {
1580  return vtk::DataArrayValueRange<1>(
1581  this->GetConnectivity(), this->GetBeginOffset(cellId), this->GetEndOffset(cellId));
1582 }
1583 VTK_ABI_NAMESPACE_END
1584 
1586 {
1587 VTK_ABI_NAMESPACE_BEGIN
1588 
1590 {
1591  // Insert full cell
1592  template <class OffsetsT, class ConnectivityT>
1593  void operator()(OffsetsT* offsets, ConnectivityT* conn, const vtkIdType npts,
1594  const vtkIdType pts[], vtkIdType& cellId)
1595  {
1596  using ValueType = GetAPIType<OffsetsT>;
1597  using OffsetsAccessorType = vtkDataArrayAccessor<OffsetsT>;
1598  using ConnectivityAccessorType = vtkDataArrayAccessor<ConnectivityT>;
1599  OffsetsAccessorType offsetsAccesor(offsets);
1600  ConnectivityAccessorType connAccesor(conn);
1601 
1602  cellId = offsets->GetNumberOfValues() - 1;
1603 
1604  offsetsAccesor.InsertNext(static_cast<ValueType>(conn->GetNumberOfValues() + npts));
1605 
1606  for (vtkIdType i = 0; i < npts; ++i)
1607  {
1608  connAccesor.InsertNext(static_cast<ValueType>(pts[i]));
1609  }
1610  }
1611 
1612  // Just update offset table (for incremental API)
1613  template <class OffsetsT, class ConnectivityT>
1614  void operator()(OffsetsT* offsets, ConnectivityT* conn, const vtkIdType npts, vtkIdType& cellId)
1615  {
1616  using ValueType = GetAPIType<OffsetsT>;
1617  using AccessorType = vtkDataArrayAccessor<OffsetsT>;
1618  AccessorType offsetsAccesor(offsets);
1619 
1620  cellId = offsets->GetNumberOfValues() - 1;
1621 
1622  offsetsAccesor.InsertNext(static_cast<ValueType>(conn->GetNumberOfValues() + npts));
1623  }
1624 };
1625 
1626 // for incremental API:
1628 {
1629  template <class OffsetsT, class ConnectivityT>
1630  void operator()(OffsetsT* offsets, ConnectivityT* vtkNotUsed(conn), const vtkIdType npts)
1631  {
1632  using ValueType = GetAPIType<OffsetsT>;
1633 
1634  auto offsetsRange = GetRange(offsets);
1635  const ValueType cellBegin = offsetsRange[offsets->GetMaxId() - 1];
1636  offsetsRange[offsets->GetMaxId()] = static_cast<ValueType>(cellBegin + npts);
1637  }
1638 };
1639 
1641 {
1642  template <class OffsetsT, class ConnectivityT>
1644  OffsetsT* offsets, ConnectivityT* vtkNotUsed(conn), vtkIdType cellId, vtkIdType& cellSize)
1645  {
1646  cellSize = GetCellSize(offsets, cellId);
1647  }
1648 };
1649 
1651 {
1652  template <class OffsetsT, class ConnectivityT>
1653  void operator()(OffsetsT* offsets, ConnectivityT* conn, const vtkIdType cellId, vtkIdList* ids)
1654  {
1655  auto offsetsRange = GetRange(offsets);
1656  const auto& beginOffset = offsetsRange[cellId];
1657  const auto& endOffset = offsetsRange[cellId + 1];
1658  const vtkIdType cellSize = static_cast<vtkIdType>(endOffset - beginOffset);
1659  const auto cellConnectivity = GetRange(conn).begin() + beginOffset;
1660 
1661  // ValueType differs from vtkIdType, so we have to copy into a temporary buffer:
1662  ids->SetNumberOfIds(cellSize);
1663  vtkIdType* idPtr = ids->GetPointer(0);
1664  for (vtkIdType i = 0; i < cellSize; ++i)
1665  {
1666  idPtr[i] = static_cast<vtkIdType>(cellConnectivity[i]);
1667  }
1668  }
1669 
1670  template <class OffsetsT, class ConnectivityT>
1671  void operator()(OffsetsT* offsets, ConnectivityT* conn, const vtkIdType cellId,
1672  vtkIdType& cellSize, vtkIdType* cellPoints)
1673  {
1674  auto offsetsRange = GetRange(offsets);
1675  const auto& beginOffset = offsetsRange[cellId];
1676  const auto& endOffset = offsetsRange[cellId + 1];
1677  cellSize = static_cast<vtkIdType>(endOffset - beginOffset);
1678  const auto cellConnectivity = GetRange(conn).begin() + beginOffset;
1679 
1680  // ValueType differs from vtkIdType, so we have to copy into a temporary buffer:
1681  for (vtkIdType i = 0; i < cellSize; ++i)
1682  {
1683  cellPoints[i] = static_cast<vtkIdType>(cellConnectivity[i]);
1684  }
1685  }
1686 
1687  // SFINAE helper to check if a Functors's connectivity array's memory can be used as a vtkIdType*.
1688  template <typename ConnectivityT>
1690  {
1691  static constexpr bool value =
1692  std::is_base_of_v<vtkAOSDataArrayTemplate<vtkIdType>, ConnectivityT>;
1693  };
1694 
1695  template <class OffsetsT, class ConnectivityT>
1697  OffsetsT* offsets, ConnectivityT* conn, const vtkIdType cellId, vtkIdType& cellSize,
1698  vtkIdType const*& cellPoints, vtkIdList* vtkNotUsed(temp))
1699  {
1700  auto offsetsRange = GetRange(offsets);
1701  const auto& beginOffset = offsetsRange[cellId];
1702  const auto& endOffset = offsetsRange[cellId + 1];
1703  cellSize = static_cast<vtkIdType>(endOffset - beginOffset);
1704  // This is safe, see CanShareConnPtr helper above.
1705  cellPoints = conn->GetPointer(beginOffset);
1706  }
1707 
1708  template <class OffsetsT, class ConnectivityT>
1710  OffsetsT* offsets, ConnectivityT* conn, const vtkIdType cellId, vtkIdType& cellSize,
1711  vtkIdType const*& cellPoints, vtkIdList* temp)
1712  {
1713  auto offsetsRange = GetRange(offsets);
1714  const auto& beginOffset = offsetsRange[cellId];
1715  const auto& endOffset = offsetsRange[cellId + 1];
1716  cellSize = static_cast<vtkIdType>(endOffset - beginOffset);
1717  const auto cellConnectivity = GetRange(conn).begin() + beginOffset;
1718 
1719  temp->SetNumberOfIds(cellSize);
1720  vtkIdType* tempPtr = temp->GetPointer(0);
1721  for (vtkIdType i = 0; i < cellSize; ++i)
1722  {
1723  tempPtr[i] = static_cast<vtkIdType>(cellConnectivity[i]);
1724  }
1725 
1726  cellPoints = tempPtr;
1727  }
1728 };
1729 
1731 {
1732  template <class OffsetsT, class ConnectivityT>
1733  void operator()(OffsetsT* offsets, ConnectivityT* conn, vtkIdType cellId,
1734  vtkIdType cellPointIndex, vtkIdType& pointId)
1735  {
1736  pointId =
1737  static_cast<vtkIdType>(GetRange(conn)[GetBeginOffset(offsets, cellId) + cellPointIndex]);
1738  }
1739 };
1740 
1742 {
1743  template <class OffsetsT, class ConnectivityT>
1744  void operator()(OffsetsT* offsets, ConnectivityT* conn)
1745  {
1746  using ValueType = GetAPIType<OffsetsT>;
1747  using AccessorType = vtkDataArrayAccessor<OffsetsT>;
1748  offsets->Reset();
1749  conn->Reset();
1750  AccessorType accessor(offsets);
1751  ValueType firstOffset = 0;
1752  accessor.InsertNext(firstOffset);
1753  }
1754 };
1755 
1757 {
1758  template <class OffsetsT, class ConnectivityT>
1759  void operator()(OffsetsT* vtkNotUsed(offsets), ConnectivityT* conn, vtkIdType id)
1760  {
1761  using ValueType = GetAPIType<ConnectivityT>;
1762  using AccessorType = vtkDataArrayAccessor<ConnectivityT>;
1763  AccessorType accessor(conn);
1764  accessor.InsertNext(static_cast<ValueType>(id));
1765  }
1766 };
1767 
1768 VTK_ABI_NAMESPACE_END
1769 } // end namespace vtkCellArray_detail
1770 
1771 VTK_ABI_NAMESPACE_BEGIN
1772 //----------------------------------------------------------------------------
1774 {
1775  this->TraversalCellId = 0;
1776 }
1777 
1778 //----------------------------------------------------------------------------
1779 inline int vtkCellArray::GetNextCell(vtkIdType& npts, vtkIdType const*& pts) VTK_SIZEHINT(pts, npts)
1780 {
1781  if (this->TraversalCellId < this->GetNumberOfCells())
1782  {
1783  this->GetCellAtId(this->TraversalCellId, npts, pts);
1784  ++this->TraversalCellId;
1785  return 1;
1786  }
1787 
1788  npts = 0;
1789  pts = nullptr;
1790  return 0;
1791 }
1792 
1793 //----------------------------------------------------------------------------
1795 {
1796  if (this->TraversalCellId < this->GetNumberOfCells())
1797  {
1798  this->GetCellAtId(this->TraversalCellId, pts);
1799  ++this->TraversalCellId;
1800  return 1;
1801  }
1802 
1803  pts->Reset();
1804  return 0;
1805 }
1806 //----------------------------------------------------------------------------
1808 {
1809  vtkIdType cellSize;
1810  this->Dispatch(vtkCellArray_detail::GetCellSizeImpl{}, cellId, cellSize);
1811  return cellSize;
1812 }
1813 
1814 //----------------------------------------------------------------------------
1815 void vtkCellArray::GetCellAtId(vtkIdType cellId, vtkIdType& cellSize, vtkIdType const*& cellPoints,
1816  vtkIdList* ptIds) VTK_SIZEHINT(cellPoints, cellSize)
1817 {
1818  this->Dispatch(vtkCellArray_detail::GetCellAtIdImpl{}, cellId, cellSize, cellPoints, ptIds);
1819 }
1820 
1821 //----------------------------------------------------------------------------
1823 {
1824  this->Dispatch(vtkCellArray_detail::GetCellAtIdImpl{}, cellId, pts);
1825 }
1826 
1827 //----------------------------------------------------------------------------
1828 void vtkCellArray::GetCellAtId(vtkIdType cellId, vtkIdType& cellSize, vtkIdType* cellPoints)
1829 {
1830  this->Dispatch(vtkCellArray_detail::GetCellAtIdImpl{}, cellId, cellSize, cellPoints);
1831 }
1832 
1833 //----------------------------------------------------------------------------
1834 inline vtkIdType vtkCellArray::GetCellPointAtId(vtkIdType cellId, vtkIdType cellPointIndex) const
1835 {
1836  vtkIdType pointId;
1837  this->Dispatch(vtkCellArray_detail::CellPointAtIdImpl{}, cellId, cellPointIndex, pointId);
1838  return pointId;
1839 }
1840 
1841 //----------------------------------------------------------------------------
1843 {
1844  vtkIdType cellId;
1845  this->Dispatch(vtkCellArray_detail::InsertNextCellImpl{}, npts, pts, cellId);
1846  return cellId;
1847 }
1848 
1849 //----------------------------------------------------------------------------
1851 {
1852  vtkIdType cellId;
1853  this->Dispatch(vtkCellArray_detail::InsertNextCellImpl{}, npts, cellId);
1854  return cellId;
1855 }
1856 
1857 //----------------------------------------------------------------------------
1859 {
1861 }
1862 
1863 //----------------------------------------------------------------------------
1864 inline void vtkCellArray::UpdateCellCount(int npts)
1865 {
1867 }
1868 
1869 //----------------------------------------------------------------------------
1871 {
1872  vtkIdType cellId;
1873  this->Dispatch(
1875  return cellId;
1876 }
1877 
1878 //----------------------------------------------------------------------------
1880 {
1881  vtkIdList* pts = cell->GetPointIds();
1882  vtkIdType cellId;
1883  this->Dispatch(
1885  return cellId;
1886 }
1887 
1888 //----------------------------------------------------------------------------
1889 inline void vtkCellArray::Reset()
1890 {
1892 }
1893 
1894 VTK_ABI_NAMESPACE_END
1895 #endif // vtkCellArray.h
AffineArray32 * GetOffsetsAffineArray32() const
Return the array used to store cell offsets.
Definition: vtkCellArray.h:594
void operator()(OffsetsT *offsets, ConnectivityT *conn, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType *cellPoints)
vtkIdType GetNumberOfOffsets() const override
Get the number of elements in the offsets array.
Definition: vtkCellArray.h:328
void operator()(OffsetsT *offsets, ConnectivityT *conn, vtkIdType cellId, vtkIdType &cellSize)
AOSArray64 * GetConnectivityAOSArray64() const
Return the array used to store the point ids that define the cells' connectivity. ...
Definition: vtkCellArray.h:625
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *ptIds) override
Return the point ids for the cell at cellId.
static vtkFreeingFunction GetAlternateFreeFunction()
ArrayType * GetConnectivity()
vtkIdType GetNumberOfCells() const override
Get the number of cells in the array.
Definition: vtkCellArray.h:322
Remove all duplicate types from TypeList TList, storing the new list in Result.
Definition: vtkTypeList.h:117
decltype(vtk::DataArrayValueRange< 1 >(std::declval< ArrayType >())) CellRangeType
std::enable_if_t< CanShareConnPtr< ConnectivityT >::value, void > operator()(OffsetsT *offsets, ConnectivityT *conn, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *temp)
vtkIdType GetCellPointAtId(vtkIdType cellId, vtkIdType cellPointIndex) const
Return the point id at cellPointIndex for the cell at cellId.
vtkIdType GetNumberOfCells(OffsetsT *offsets)
Definition: vtkCellArray.h:912
vtkDataArray * GetOffsetsArray() const
Return the array used to store cell offsets.
Definition: vtkCellArray.h:581
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 override
Definition: vtkCellArray.h:469
AOSArray32 * GetOffsetsAOSArray32() const
Return the array used to store cell offsets.
Definition: vtkCellArray.h:587
void operator()(OffsetsT *offsets, ConnectivityT *conn)
typename detail::GetAPITypeImpl< ArrayType, ForceValueTypeForVtkDataArray >::APIType GetAPIType
abstract object to represent cell connectivity
AOSArray32 * GetConnectivityAOSArray32() const
Return the array used to store the point ids that define the cells' connectivity. ...
Definition: vtkCellArray.h:616
void operator()(OffsetsT *offsets, ConnectivityT *conn, vtkIdType cellId, vtkIdType cellPointIndex, vtkIdType &pointId)
vtkNew< vtkIdTypeArray > LegacyData
void Reset()
Reset to an empty state but retain previously allocated memory.
Definition: vtkIdList.h:186
virtual void ShallowCopy(vtkAbstractCellArray *ca)=0
Shallow copy ca into this cell array.
vtkSmartPointer< vtkDataArray > Offsets
vtkIdType GetCellSize(vtkIdType cellId) const override
Return the size of the cell at cellId.
bool ConvertToStorageType(StorageTypes type)
Convert internal data structures to use 32- or 64-bit storage.
Definition: vtkCellArray.h:557
virtual int GetMaxCellSize()=0
Returns the size of the largest cell.
void InitTraversal()
vtkSmartPointer< ArrayType > Connectivity
const ArrayType * GetOffsets() const
static vtkIdType GetEndOffset(OffsetsT *offsets, vtkIdType cellId)
Definition: vtkCellArray.h:931
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
static bool GetDefaultStorageIs64Bit()
Control the default internal storage size.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
static vtkIdType GetCellSize(OffsetsT *offsets, vtkIdType cellId)
Definition: vtkCellArray.h:937
vtkIdType TraversalCellId
virtual void DeepCopy(vtkAbstractCellArray *ca)=0
Perform a deep copy (no reference counting) of the given cell array.
static vtkIdType GetBeginOffset(OffsetsT *offsets, vtkIdType cellId)
Definition: vtkCellArray.h:925
const ArrayType * GetConnectivity() const
StorageTypes GetStorageType() const noexcept
Definition: vtkCellArray.h:428
typename vtkTypeList::detail::CreateImpl< Ts... >::type Create
Definition: vtkTypeList.h:171
bool IsStorageFixedSize64Bit() const
Definition: vtkCellArray.h:443
vtkIdType GetNumberOfConnectivityIds() const override
Get the size of the connectivity array that stores the point ids.
Definition: vtkCellArray.h:349
bool AllocateCopy(vtkCellArray *other)
Pre-allocate memory in internal data structures to match the used size of the input vtkCellArray...
Definition: vtkCellArray.h:274
int vtkTypeBool
Definition: vtkABI.h:64
vtkTypeList::Create< vtkTypeInt32Array, vtkTypeInt64Array > StorageArrayList
List of possible array types used for storage.
Definition: vtkCellArray.h:209
abstract class to specify cell behavior
Definition: vtkCell.h:50
void operator()(OffsetsT *offsets, ConnectivityT *conn, const vtkIdType npts)
static void SetDefaultStorageIs64Bit(bool val)
Control the default internal storage size.
#define VTK_DEPRECATED_IN_9_6_0(reason)
void Reset()
Reuse list.
#define VTK_MARSHALMANUAL
a simple class to control print indentation
Definition: vtkIndent.h:28
void Dispatch(Functor &&functor, Args &&...args) const
static bool GetUsingMemkind()
A global state flag that controls whether vtkObjects are constructed in the usual way (the default) o...
void operator()(OffsetsT *offsets, ConnectivityT *conn, const vtkIdType npts, vtkIdType &cellId)
Array-Of-Structs implementation of vtkGenericDataArray.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
list of point or cell ids
Definition: vtkIdList.h:25
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
vtkTypeList::Unique< vtkTypeList::Create< vtkAOSDataArrayTemplate< int >, vtkAOSDataArrayTemplate< long >, vtkAOSDataArrayTemplate< long long >>>::Result InputArrayList
List of possible ArrayTypes that are compatible with internal storage.
Definition: vtkCellArray.h:223
vtkTypeInt64Array ArrayType64
Definition: vtkCellArray.h:181
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition: vtkIdList.h:76
vtkIdType GetEndOffset(vtkIdType cellId) const
#define VTK_SIZEHINT(...)
void Dispatch(Functor &&functor, Args &&...args)
void operator()(OffsetsT *offsets, ConnectivityT *conn, const vtkIdType npts, const vtkIdType pts[], vtkIdType &cellId)
bool IsStorage64Bit() const
Definition: vtkCellArray.h:433
AffineArray64 * GetOffsetsAffineArray64() const
Return the array used to store cell offsets.
Definition: vtkCellArray.h:598
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...
#define VTK_NEWINSTANCE
CellRangeType GetCellRange(vtkIdType cellId)
vtkIdType InsertNextCell(vtkCell *cell)
Insert a cell object.
bool IsStorageFixedSize32Bit() const
Definition: vtkCellArray.h:448
static bool DefaultStorageIs64Bit
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints)
Return the point ids for the cell at cellId.
vtkSmartPointer< ArrayType > Offsets
std::enable_if_t<!CanShareConnPtr< ConnectivityT >::value, void > operator()(OffsetsT *offsets, ConnectivityT *conn, const vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *temp)
object to represent cell connectivity
Definition: vtkCellArray.h:177
vtkTypeInt32Array ArrayType32
Definition: vtkCellArray.h:180
virtual vtkIdType GetNumberOfCells() const =0
Get the number of cells in the array.
virtual void Initialize()=0
Free any memory and reset to an empty state.
A utility array for wrapping affine functions in implicit arrays.
typename ArrayType::ValueType ValueType
vtkIdType GetCellSize(vtkIdType cellId) const
vtk::GetAPIType< ArrayT, vtkIdType > GetAPIType
Definition: vtkCellArray.h:909
void operator()(OffsetsT *offsets, ConnectivityT *conn, vtkIdType id)
vtkIdList * GetPointIds()
Return the list of point ids defining the cell.
Definition: vtkCell.h:144
void operator()(OffsetsT *offsets, ConnectivityT *conn, const vtkIdType cellId, vtkIdList *ids)
vtkDataArray * GetConnectivityArray() const
Return the array used to store the point ids that define the cells' connectivity. ...
Definition: vtkCellArray.h:610
virtual vtkIdType IsHomogeneous() const =0
Check if all cells have the same number of vertices.
bool CanConvertToStorageType(StorageTypes type) const
Check if the existing data can safely be converted to use 32- or 64- bit storage. ...
Definition: vtkCellArray.h:515
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkSmartPointer< vtkDataArray > Connectivity
AOSArray64 * GetOffsetsAOSArray64() const
Return the array used to store cell offsets.
Definition: vtkCellArray.h:593
static vtkMallocingFunction GetCurrentMallocFunction()
bool GetConnectivity(const Ioss::GroupingEntity *group_entity, vtkCellGrid *grid, vtkDGCell *meta, int ioss_cell_points, int spec_index=-1, const std::string &group_name=std::string(), vtkIOSSUtilities::Cache *cache=nullptr)
Read connectivity and possibly ghost-node markings into meta.
bool IsStorage32Bit() const
Definition: vtkCellArray.h:438
#define VTK_EXPECTS(x)
bool IsStorageFixedSize() const
Definition: vtkCellArray.h:453
vtkIdType GetBeginOffset(vtkIdType cellId) const
Efficient templated access to vtkDataArray.
void SetNumberOfIds(vtkIdType number)
Specify the number of ids for this object to hold.
vtkIdType GetOffset(vtkIdType cellId) override
Get the offset (into the connectivity) for a specified cell id.
Definition: vtkCellArray.h:333
Encapsulate traversal logic for vtkCellArray.
bool IsStorageGeneric() const
Definition: vtkCellArray.h:461
void SetOffset(vtkIdType cellId, vtkIdType offset)
Set the offset (into the connectivity) for a specified cell id.
Definition: vtkCellArray.h:341
STL-compatible iterable ranges that provide access to vtkDataArray elements.
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
Definition: vtkCellArray.h:249
int GetNextCell(vtkIdType &npts, vtkIdType const *&pts)
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
Definition: vtkIdList.h:150