Skip to content
Snippets Groups Projects
Commit 603753ec authored by Spiros Tsalikis's avatar Spiros Tsalikis
Browse files

Remove Dispatching for Composite and Indexed arrays

This is removed because a recursive include of backends
occurs which can not be solved.
parent 37301a94
No related branches found
No related tags found
No related merge requests found
......@@ -113,9 +113,7 @@ option(VTK_DISPATCH_SOA_ARRAYS "Include struct-of-arrays vtkDataArray subclasses
option(VTK_DISPATCH_TYPED_ARRAYS "Include vtkTypedDataArray subclasses (e.g. old mapped arrays) in dispatcher." OFF)
option(VTK_DISPATCH_AFFINE_ARRAYS "Include implicit vtkDataArray subclasses based on an affine function backend in dispatcher" OFF)
option(VTK_DISPATCH_COMPOSITE_ARRAYS "Include implicit vtkDataArray subclasses based on a composite binary tree backend in dispatcher" OFF)
option(VTK_DISPATCH_CONSTANT_ARRAYS "Include implicit vtkDataArray subclasses based on a constant backend in dispatcher" OFF)
option(VTK_DISPATCH_INDEXED_ARRAYS "Include implicit vtkDataArray subclasses based on an index referencing backend in dispatcher" OFF)
option(VTK_DISPATCH_STD_FUNCTION_ARRAYS "Include implicit vtkDataArray subclasses based on std::function in dispatcher" OFF)
option(VTK_WARN_ON_DISPATCH_FAILURE "If enabled, vtkArrayDispatch will print a warning when a dispatch fails." OFF)
......@@ -126,9 +124,7 @@ mark_as_advanced(
VTK_DISPATCH_TYPED_ARRAYS
VTK_DISPATCH_AFFINE_ARRAYS
VTK_DISPATCH_COMPOSITE_ARRAYS
VTK_DISPATCH_CONSTANT_ARRAYS
VTK_DISPATCH_INDEXED_ARRAYS
VTK_DISPATCH_STD_FUNCTION_ARRAYS
VTK_WARN_ON_DISPATCH_FAILURE)
......
......@@ -7,41 +7,11 @@
#include "vtkIntArray.h"
#include "vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
#ifdef VTK_DISPATCH_COMPOSITE_ARRAYS
#include "vtkArrayDispatch.h"
#endif // VTK_DISPATCH_AFFINE_ARRAYS
#include <cstdlib>
#include <memory>
namespace
{
#ifdef VTK_DISPATCH_COMPOSITE_ARRAYS
struct ScaleWorker
{
template <typename SrcArray, typename DstArray>
void operator()(SrcArray* srcArr, DstArray* dstArr, double scale)
{
using SrcType = vtk::GetAPIType<SrcArray>;
using DstType = vtk::GetAPIType<DstArray>;
const auto srcRange = vtk::DataArrayValueRange(srcArr);
auto dstRange = vtk::DataArrayValueRange(dstArr);
if (srcRange.size() != dstRange.size())
{
std::cout << "Different array sizes in ScaleWorker" << std::endl;
return;
}
auto dstIter = dstRange.begin();
for (SrcType srcVal : srcRange)
{
*dstIter++ = static_cast<DstType>(srcVal * scale);
}
}
};
#endif // VTK_DISPATCH_COMPOSITE_ARRAYS
vtkSmartPointer<vtkCompositeArray<int>> SetupCompositeArray(int length)
{
......@@ -104,33 +74,6 @@ int TestCompositeArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
iArr++;
}
#ifdef VTK_DISPATCH_COMPOSITE_ARRAYS
std::cout << "vtkCompositeArray: performing dispatch tests" << std::endl;
vtkNew<vtkIntArray> destination;
destination->SetNumberOfTuples(100);
destination->SetNumberOfComponents(1);
using Dispatcher =
vtkArrayDispatch::Dispatch2ByArray<vtkArrayDispatch::ReadOnlyArrays, vtkArrayDispatch::Arrays>;
::ScaleWorker worker;
if (!Dispatcher::Execute(composite, destination, worker, 3.0))
{
res = EXIT_FAILURE;
std::cout << "vtkArrayDispatch failed with vtkCompositeArray" << std::endl;
worker(composite.Get(), destination.Get(), 3.0);
}
iArr = 0;
for (auto val : vtk::DataArrayValueRange<1>(destination))
{
if (val != 3 * iArr)
{
res = EXIT_FAILURE;
std::cout << "dispatch failed to populate the array with the correct values" << std::endl;
}
iArr++;
}
#endif // VTK_DISPATCH_COMPOSITE_ARRAYS
// test a 1 composite
vtkSmartPointer<vtkCompositeArray<int>> oneComposite =
vtk::ConcatenateDataArrays<int>(std::vector<vtkDataArray*>({ composite }));
......
......@@ -7,44 +7,10 @@
#include "vtkIntArray.h"
#include "vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
#ifdef VTK_DISPATCH_INDEXED_ARRAYS
#include "vtkArrayDispatch.h"
#endif // VTK_DISPATCH_INDEXED_ARRAYS
#include <cstdlib>
#include <numeric>
#include <random>
#ifdef VTK_DISPATCH_INDEXED_ARRAYS
namespace
{
struct ScaleWorker
{
template <typename SrcArray, typename DstArray>
void operator()(SrcArray* srcArr, DstArray* dstArr, double scale)
{
using SrcType = vtk::GetAPIType<SrcArray>;
using DstType = vtk::GetAPIType<DstArray>;
const auto srcRange = vtk::DataArrayValueRange(srcArr);
auto dstRange = vtk::DataArrayValueRange(dstArr);
if (srcRange.size() != dstRange.size())
{
std::cout << "Different array sizes in ScaleWorker" << std::endl;
return;
}
auto dstIter = dstRange.begin();
for (SrcType srcVal : srcRange)
{
*dstIter++ = static_cast<DstType>(srcVal * scale);
}
}
};
}
#endif // VTK_DISPATCH_INDEXED_ARRAYS
int TestIndexedArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
{
int res = EXIT_SUCCESS;
......@@ -90,31 +56,5 @@ int TestIndexedArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
iArr++;
}
#ifdef VTK_DISPATCH_INDEXED_ARRAYS
std::cout << "vtkIndexedArray: performing dispatch tests" << std::endl;
vtkNew<vtkIntArray> destination;
destination->SetNumberOfTuples(100);
destination->SetNumberOfComponents(1);
using Dispatcher =
vtkArrayDispatch::Dispatch2ByArray<vtkArrayDispatch::ReadOnlyArrays, vtkArrayDispatch::Arrays>;
::ScaleWorker worker;
if (!Dispatcher::Execute(indexed, destination, worker, 3.0))
{
res = EXIT_FAILURE;
std::cout << "vtkArrayDispatch failed with vtkIndexedArray" << std::endl;
worker(indexed.Get(), destination.Get(), 3.0);
}
iArr = 0;
for (auto val : vtk::DataArrayValueRange<1>(destination))
{
if (val != 3 * static_cast<int>(handles->GetId(iArr)))
{
res = EXIT_FAILURE;
std::cout << "dispatch failed to populate the array with the correct values" << std::endl;
}
iArr++;
}
#endif // VTK_DISPATCH_INDEXED_ARRAYS
return res;
};
......@@ -19,15 +19,9 @@
# - VTK_DISPATCH_AFFINE_ARRAYS (default: OFF)
# Include vtkAffineArray<ValueType> for the basic types supported
# by VTK.
# - VTK_DISPATCH_COMPOSITE_ARRAYS (default: OFF)
# Include vtkCompositeDataArrayTemplate<ValueType> for the basic types
# supported by VTK.
# - VTK_DISPATCH_CONSTANT_ARRAYS (default: OFF)
# Include vtkConstantArray<ValueType> for the basic types supported
# by VTK.
# - VTK_DISPATCH_INDEXED_ARRAYS (default: OFF)
# Include vtkIndexedDataArrayTemplate<ValueType> for the basic types
# supported by VTK.
# - VTK_DISPATCH_STD_FUNCTION_ARRAYS (default: OFF)
# Include vtkStdFunctionArray<ValueType> for the basic types supported
# by VTK.
......@@ -194,15 +188,9 @@ endmacro()
_vtkCreateArrayDispatchImplicit(VTK_DISPATCH_AFFINE_ARRAYS "vtkAffineArray"
"${vtkArrayDispatch_all_types}")
_vtkCreateArrayDispatchImplicit(VTK_DISPATCH_COMPOSITE_ARRAYS "vtkCompositeArray"
"${vtkArrayDispatch_all_types}")
_vtkCreateArrayDispatchImplicit(VTK_DISPATCH_CONSTANT_ARRAYS "vtkConstantArray"
"${vtkArrayDispatch_all_types}")
_vtkCreateArrayDispatchImplicit(VTK_DISPATCH_INDEXED_ARRAYS "vtkIndexedArray"
"${vtkArrayDispatch_all_types}")
_vtkCreateArrayDispatchImplicit(VTK_DISPATCH_STD_FUNCTION_ARRAYS "vtkStdFunctionArray"
"${vtkArrayDispatch_all_types}")
......
......@@ -6,12 +6,8 @@
// defined if VTK dispatches the vtkAffineArray class
#cmakedefine VTK_DISPATCH_AFFINE_ARRAYS
// defined if VTK dispatches the vtkCompositeArray class
#cmakedefine VTK_DISPATCH_COMPOSITE_ARRAYS
// defined if VTK dispatches the vtkConstantArray class
#cmakedefine VTK_DISPATCH_CONSTANT_ARRAYS
// defined if VTK dispatches the vtkIndexedArray class
#cmakedefine VTK_DISPATCH_INDEXED_ARRAYS
// defined if VTK dispatches the vtkStdFunctionArray class
#cmakedefine VTK_DISPATCH_STD_FUNCTION_ARRAYS
......
......@@ -228,12 +228,6 @@ currently exist for use with the VTK dispatch mechanism:
`vtkConstantArray` as part of the implicit array framework
* `VTK_DISPATCH_STD_FUNCTION_ARRAYS` (default `OFF`): includes dispatching for arrays with
an `std::function` backend `vtkStdFunctionArray` as part of the implicit array framework
* `VTK_DISPATCH_COMPOSITE_ARRAYS` (default `OFF`): includes dispatching of arrays with a
`vtkCompositeImplicitBackend` backend, `vtkCompositeArray`, as part of the implicit array
framework
* `VTK_DISPATCH_INDEXED_ARRAYS` (default `OFF`): includes dispatching of arrays with a
`vtkIndexedImplicitBackend` backend, `vtkIndexedArray`, as part of the implicit array
framework
The outlier in terms of dispatch support is the family of arrays derived from
`vtkScaledSOADataArrayTemplate` which are automatically included in dispatch when built setting
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment