From 9926e161e7e43df438c271564f9927c7617b7a5f Mon Sep 17 00:00:00 2001
From: Spiros Tsalikis <spiros.tsalikis@kitware.com>
Date: Fri, 7 Feb 2025 17:58:04 -0500
Subject: [PATCH] vtkTypedDataArray & vtkTypedDataArrayIterator: Deprecate

---
 ...onfigure_windows_vs2022_debug_mpi_qt.cmake |  2 +-
 Common/Core/CMakeLists.txt                    |  4 +-
 .../Testing/Cxx/TestDataArrayIterators.cxx    | 65 +++++--------------
 .../Testing/Cxx/TestDataArrayValueRange.cxx   |  1 -
 .../vtkCreateArrayDispatchArrayList.cmake     |  4 +-
 Common/Core/vtkTypedDataArray.h               |  5 +-
 .../Core/vtkTypedDataArrayInstantiate.cxx.in  |  3 +
 Common/Core/vtkTypedDataArrayIterator.h       |  4 +-
 .../docs/build_instructions/build_settings.md |  2 +-
 9 files changed, 33 insertions(+), 57 deletions(-)

diff --git a/.gitlab/ci/configure_windows_vs2022_debug_mpi_qt.cmake b/.gitlab/ci/configure_windows_vs2022_debug_mpi_qt.cmake
index 4ffec477eed..8362b3e9d8e 100644
--- a/.gitlab/ci/configure_windows_vs2022_debug_mpi_qt.cmake
+++ b/.gitlab/ci/configure_windows_vs2022_debug_mpi_qt.cmake
@@ -17,7 +17,7 @@ set(VTK_DISPATCH_STRUCTURED_POINT_ARRAYS ON CACHE BOOL "")
 # way. Until this is fixed (#19213), disable dispatching even though the
 # template instantiation logic is more important for this CI configuration
 # because `VTK::TestingCore` needs `VTK::FiltersHyperTree`.
-set(VTK_DISPATCH_TYPED_ARRAYS OFF CACHE BOOL "")
+set(VTK_DISPATCH_TYPED_ARRAYS OFF CACHE BOOL "") # VTK_DEPRECATED_IN_9_5_0
 
 # Disable VTK-m as the artifacts are too large.
 set(VTK_MODULE_ENABLE_VTK_vtkvtkm NO CACHE STRING "")
diff --git a/Common/Core/CMakeLists.txt b/Common/Core/CMakeLists.txt
index b78cd8a21b3..128b9eff0dc 100644
--- a/Common/Core/CMakeLists.txt
+++ b/Common/Core/CMakeLists.txt
@@ -139,7 +139,7 @@ configure_file(vtkTypeListMacros.h.in vtkTypeListMacros.h)
 # And the ArrayDispatch array list header:
 option(VTK_DISPATCH_AOS_ARRAYS "Include array-of-structs vtkDataArray subclasses in dispatcher." ON)
 option(VTK_DISPATCH_SOA_ARRAYS "Include struct-of-arrays vtkDataArray subclasses in dispatcher." OFF)
-option(VTK_DISPATCH_TYPED_ARRAYS "Include vtkTypedDataArray subclasses (e.g. old mapped arrays) in dispatcher." OFF)
+option(VTK_DISPATCH_TYPED_ARRAYS "Include vtkTypedDataArray subclasses (e.g. old mapped arrays) in dispatcher." OFF) # VTK_DEPRECATED_IN_9_5_0
 
 option(VTK_DISPATCH_AFFINE_ARRAYS "Include implicit vtkDataArray subclasses based on an affine function backend in dispatcher" OFF)
 option(VTK_DISPATCH_CONSTANT_ARRAYS "Include implicit vtkDataArray subclasses based on a constant backend in dispatcher" OFF)
@@ -151,7 +151,7 @@ option(VTK_WARN_ON_DISPATCH_FAILURE "If enabled, vtkArrayDispatch will print a w
 mark_as_advanced(
   VTK_DISPATCH_AOS_ARRAYS
   VTK_DISPATCH_SOA_ARRAYS
-  VTK_DISPATCH_TYPED_ARRAYS
+  VTK_DISPATCH_TYPED_ARRAYS # VTK_DEPRECATED_IN_9_5_0
 
   VTK_DISPATCH_AFFINE_ARRAYS
   VTK_DISPATCH_CONSTANT_ARRAYS
diff --git a/Common/Core/Testing/Cxx/TestDataArrayIterators.cxx b/Common/Core/Testing/Cxx/TestDataArrayIterators.cxx
index 8dd0727715c..c92ead664b7 100644
--- a/Common/Core/Testing/Cxx/TestDataArrayIterators.cxx
+++ b/Common/Core/Testing/Cxx/TestDataArrayIterators.cxx
@@ -1,11 +1,12 @@
 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
 // SPDX-License-Identifier: BSD-3-Clause
 
+// VTK_DEPRECATED_IN_9_5_0()
+#define VTK_DEPRECATION_LEVEL 0
+
 #include "vtkFloatArray.h"
 #include "vtkNew.h"
 #include "vtkTimerLog.h"
-#include "vtkTypedDataArray.h"
-#include "vtkTypedDataArrayIterator.h"
 
 #include <cassert>
 #include <iostream>
@@ -13,40 +14,6 @@
 // undefine this to print benchmark results:
 #define SILENT
 
-// Create a subclass of vtkTypedDataArray:
-namespace
-{
-class MyArray : public vtkTypedDataArray<float>
-{
-  vtkFloatArray* Data;
-
-public:
-  static MyArray* New() { VTK_STANDARD_NEW_BODY(MyArray); }
-  void Init(vtkFloatArray* array)
-  {
-    this->Data = array;
-    this->NumberOfComponents = array->GetNumberOfComponents();
-    this->MaxId = array->GetMaxId();
-  }
-  ValueType& GetValueReference(vtkIdType idx) override { return *this->Data->GetPointer(idx); }
-
-  // These pure virtuals are no-op -- all we care about is GetValueReference
-  // to test the iterator.
-  void SetTypedTuple(vtkIdType, const ValueType*) override {}
-  void InsertTypedTuple(vtkIdType, const ValueType*) override {}
-  vtkIdType InsertNextTypedTuple(const ValueType*) override { return 0; }
-  vtkIdType LookupTypedValue(ValueType) override { return 0; }
-  void LookupTypedValue(ValueType, vtkIdList*) override {}
-  ValueType GetValue(vtkIdType) const override { return 0; }
-  void SetValue(vtkIdType, ValueType) override {}
-  void GetTypedTuple(vtkIdType, ValueType*) const override {}
-  vtkIdType InsertNextValue(ValueType) override { return 0; }
-  void InsertValue(vtkIdType, ValueType) override {}
-  vtkTypeBool Allocate(vtkIdType, vtkIdType) override { return 0; }
-  vtkTypeBool Resize(vtkIdType) override { return 0; }
-};
-}
-
 int TestDataArrayIterators(int, char*[])
 {
   vtkIdType numComps = 4;
@@ -64,10 +31,11 @@ int TestDataArrayIterators(int, char*[])
     array->SetValue(i, i % 97);
   }
 
-  // Create the vtkTypedDataArray testing implementation:
-  vtkNew<MyArray> tdaContainer;
-  MyArray* tda = tdaContainer;
-  tda->Init(array);
+  // Create the vtkAOSDataArrayTemplate testing implementation:
+  vtkNew<vtkAOSDataArrayTemplate<float>> tdaContainer;
+  vtkAOSDataArrayTemplate<float>* tda = tdaContainer;
+  tda->SetNumberOfComponents(numComps);
+  tda->SetArray(arrayContainer->GetPointer(0), numValues, 1);
 
   // should be vtkAOSDataArrayTemplate<float>::Iterator (float*):
   vtkFloatArray::Iterator datBegin = array->Begin();
@@ -79,13 +47,14 @@ int TestDataArrayIterators(int, char*[])
   }
 
   // should be vtkTypedDataArrayIterator<float>:
-  vtkTypedDataArray<float>::Iterator tdaBegin =
-    vtkTypedDataArray<float>::FastDownCast(tda)->Begin();
-  vtkTypedDataArray<float>::Iterator tdaIter = vtkTypedDataArray<float>::FastDownCast(tda)->Begin();
-  if (typeid(tdaBegin) != typeid(vtkTypedDataArrayIterator<float>))
+  vtkAOSDataArrayTemplate<float>::Iterator tdaBegin =
+    vtkAOSDataArrayTemplate<float>::FastDownCast(tda)->Begin();
+  vtkAOSDataArrayTemplate<float>::Iterator tdaIter =
+    vtkAOSDataArrayTemplate<float>::FastDownCast(tda)->Begin();
+  if (typeid(tdaBegin) != typeid(float*))
   {
-    std::cerr << "Error: vtkTypedDataArray<float>::Iterator is not a "
-                 "vtkTypedDataArrayIterator<float>.";
+    std::cerr << "Error: vtkAOSDataArrayTemplate<float>::Iterator is not a "
+                 "float*.";
     return EXIT_FAILURE;
   }
 
@@ -131,8 +100,8 @@ int TestDataArrayIterators(int, char*[])
   timer->StopTimer();
   double datTime = timer->GetElapsedTime();
 
-  // vtkTypedDataArrayIterator:
-  vtkTypedDataArray<float>::Iterator tdaEnd = tda->End();
+  // vtkAOSDataArrayTemplate<float>::Iterator:
+  vtkAOSDataArrayTemplate<float>::Iterator tdaEnd = tda->End();
   float tdaSum = 0.f;
   timer->StartTimer();
   while (tdaBegin != tdaEnd)
diff --git a/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx b/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx
index 2caf6fd2d3c..d4cb71528d4 100644
--- a/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx
+++ b/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx
@@ -9,7 +9,6 @@
 #include "vtkSOADataArrayTemplate.h"
 #include "vtkSmartPointer.h"
 #include "vtkTypeInt32Array.h"
-#include "vtkTypedDataArray.h"
 #ifdef VTK_USE_SCALED_SOA_ARRAYS
 #include "vtkScaledSOADataArrayTemplate.h"
 #endif
diff --git a/Common/Core/vtkCreateArrayDispatchArrayList.cmake b/Common/Core/vtkCreateArrayDispatchArrayList.cmake
index 36f22b570e4..de39222fd2e 100644
--- a/Common/Core/vtkCreateArrayDispatchArrayList.cmake
+++ b/Common/Core/vtkCreateArrayDispatchArrayList.cmake
@@ -11,7 +11,7 @@
 # - VTK_DISPATCH_SOA_ARRAYS (default: OFF)
 #   Include vtkSOADataArrayTemplate<ValueType> for the basic types supported
 #   by VTK.
-# - VTK_DISPATCH_TYPED_ARRAYS (default: OFF)
+# - VTK_DISPATCH_TYPED_ARRAYS (default: OFF) VTK_DEPRECATED_IN_9_5_0
 #   Include vtkTypedDataArray<ValueType> for the basic types supported
 #   by VTK. This enables the old-style in-situ vtkMappedDataArray subclasses
 #   to be used.
@@ -163,7 +163,7 @@ _vtkCreateArrayDispatch(_dispatch_scaled_soa_arrays "vtkScaledSOADataArrayTempla
   "${vtk_numeric_types}")
 
 _vtkCreateArrayDispatch(VTK_DISPATCH_TYPED_ARRAYS "vtkTypedDataArray"
-  "${vtk_numeric_types}")
+  "${vtk_numeric_types}") # VTK_DEPRECATED_IN_9_5_0
 
 macro(_vtkCreateArrayDispatchImplicit var class types)
   if (${var})
diff --git a/Common/Core/vtkTypedDataArray.h b/Common/Core/vtkTypedDataArray.h
index b5c6bf59a34..f3589cca767 100644
--- a/Common/Core/vtkTypedDataArray.h
+++ b/Common/Core/vtkTypedDataArray.h
@@ -27,6 +27,7 @@
 #include "vtkGenericDataArray.h"
 
 #include "vtkCommonCoreModule.h" // For export macro
+#include "vtkDeprecation.h"      // For VTK_DEPRECATED_IN_9_5_0
 #include "vtkTypeTraits.h"       // For type metadata
 
 VTK_ABI_NAMESPACE_BEGIN
@@ -34,7 +35,9 @@ template <class Scalar>
 class vtkTypedDataArrayIterator;
 
 template <class Scalar>
-class vtkTypedDataArray : public vtkGenericDataArray<vtkTypedDataArray<Scalar>, Scalar>
+class VTK_DEPRECATED_IN_9_5_0(
+  "This class has been made obsolete by the newer vtkGenericDataArray.") vtkTypedDataArray
+  : public vtkGenericDataArray<vtkTypedDataArray<Scalar>, Scalar>
 {
   typedef vtkGenericDataArray<vtkTypedDataArray<Scalar>, Scalar> GenericDataArrayType;
 
diff --git a/Common/Core/vtkTypedDataArrayInstantiate.cxx.in b/Common/Core/vtkTypedDataArrayInstantiate.cxx.in
index 158f575cd7d..837bec7642c 100644
--- a/Common/Core/vtkTypedDataArrayInstantiate.cxx.in
+++ b/Common/Core/vtkTypedDataArrayInstantiate.cxx.in
@@ -1,6 +1,9 @@
 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
 // SPDX-License-Identifier: BSD-3-Clause
 
+// VTK_DEPRECATED_IN_9_5_0()
+#define VTK_DEPRECATION_LEVEL 0
+
 #include "vtkDataArrayPrivate.txx"
 
 #define VTK_TYPED_VALUERANGE_INSTANTIATING
diff --git a/Common/Core/vtkTypedDataArrayIterator.h b/Common/Core/vtkTypedDataArrayIterator.h
index 73e4074b6f0..75e9a4fe5be 100644
--- a/Common/Core/vtkTypedDataArrayIterator.h
+++ b/Common/Core/vtkTypedDataArrayIterator.h
@@ -23,11 +23,13 @@
 
 #include <iterator> // For iterator traits
 
+#include "vtkDeprecation.h"    // For VTK_DEPRECATED_IN_9_5_0
 #include "vtkTypedDataArray.h" // For vtkTypedDataArray
 
 VTK_ABI_NAMESPACE_BEGIN
 template <class Scalar>
-class vtkTypedDataArrayIterator
+class VTK_DEPRECATED_IN_9_5_0(
+  "This iterator is deprecated because vtkTypedDataArray is deprecated.") vtkTypedDataArrayIterator
 {
 public:
   typedef std::random_access_iterator_tag iterator_category;
diff --git a/Documentation/docs/build_instructions/build_settings.md b/Documentation/docs/build_instructions/build_settings.md
index 62a71de5db0..a31dd0cfe90 100644
--- a/Documentation/docs/build_instructions/build_settings.md
+++ b/Documentation/docs/build_instructions/build_settings.md
@@ -276,7 +276,7 @@ currently exist for use with the VTK dispatch mechanism:
   * `VTK_DISPATCH_SOA_ARRAYS` (default `OFF`): includes dispatching for "structure-of-array"
     ordered arrays derived from `vtkSOADataArrayTemplate`
   * `VTK_DISPATCH_TYPED_ARRAYS` (default `OFF`): includes dispatching for arrays derived
-    from `vtkTypedDataArray`
+    from `vtkTypedDataArray` (VTK_DEPRECATED_IN_9_5_0).
   * `VTK_DISPATCH_AFFINE_ARRAYS` (default `OFF`): includes dispatching for linearly varying
     `vtkAffineArray`s as part of the implicit array framework
   * `VTK_DISPATCH_CONSTANT_ARRAYS` (default `OFF`): includes dispatching for constant arrays
-- 
GitLab