move(implicitArrays): into its own module

HTGFixUnlimitedToRoot
Julien Fausty 7 months ago
parent 741cc86a95
commit 295ed1ec9f

@ -266,14 +266,11 @@ list(APPEND vtk_requested_modules
# Required for just about everything.
VTK::CommonCore
VTK::CommonDataModel
VTK::CommonImplicitBackends
)
set("_vtk_module_reason_VTK::CommonCore"
"because all VTK builds require VTK::CommonCore")
set("_vtk_module_reason_VTK::CommonDataModel"
"because all VTK builds require VTK::CommonDataModel")
set("_vtk_module_reason_VTK::CommonImplicitBackends"
"because VTK::CommonCore requires VTK::CommonImplicitBackends")
if (VTK_ENABLE_WRAPPING)
list(APPEND vtk_requested_modules

@ -117,33 +117,6 @@ mark_as_advanced(
option(VTK_BUILD_SCALED_SOA_ARRAYS "Include struct-of-arrays with scaled vtkDataArray implementation." OFF)
option(VTK_BUILD_IMPLICIT_ARRAYS "Include implicit vtkDataArray implementation" ON)
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)
option(VTK_DISPATCH_STD_FUNCTION_ARRAYS "Include implicit vtkDataArray subclasses based on std::function in dispatcher" OFF)
mark_as_advanced(
VTK_DISPATCH_CONSTANT_ARRAYS
VTK_DISPATCH_AFFINE_ARRAYS
VTK_DISPATCH_STD_FUNCTION_ARRAYS
)
set(implicit_array_classes)
set(implicit_array_template_classes)
set(implicit_array_sources)
set(implicit_array_headers)
set(implicit_array_dispatch_list)
if (VTK_BUILD_IMPLICIT_ARRAYS)
list(APPEND implicit_array_headers
vtkAffineArray.h
vtkConstantArray.h
vtkStdFunctionArray.h
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
@ONLY)
endif ()
include("${CMAKE_CURRENT_SOURCE_DIR}/vtkCreateArrayDispatchArrayList.cmake")
vtkArrayDispatch_default_array_setup()
vtkArrayDispatch_generate_array_header(VTK_ARRAYDISPATCH_ARRAY_LIST)
@ -168,11 +141,7 @@ foreach (INSTANTIATION_VALUE_TYPE IN LISTS vtkArrayDispatch_all_types)
if (VTK_BUILD_SCALED_SOA_ARRAYS)
list(APPEND _list "vtkScaledSOADataArrayTemplateInstantiate")
endif ()
if (VTK_BUILD_IMPLICIT_ARRAYS)
list(APPEND _list "vtkAffineArrayInstantiate")
list(APPEND _list "vtkConstantArrayInstantiate")
list(APPEND _list "vtkStdFunctionArrayInstantiate")
endif ()
# see comments in vtkGenericDataArray.h for explanation
if (INSTANTIATION_VALUE_TYPE MATCHES "(^| )long( |$)")
list(APPEND _list "vtkGenericDataArrayValueRangeInstantiate")
@ -328,7 +297,6 @@ set(nowrap_template_classes
set(sources
vtkArrayIteratorTemplateInstantiate.cxx
vtkGenericDataArray.cxx
${implicit_array_sources}
${instantiation_sources}
${vtk_smp_sources})
@ -340,17 +308,6 @@ configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/vtkVTK_USE_SCALED_SOA_ARRAYS.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_USE_SCALED_SOA_ARRAYS.h")
if (VTK_BUILD_IMPLICIT_ARRAYS)
list (APPEND template_classes
vtkImplicitArray
${implicit_array_template_classes})
list (APPEND classes
${implicit_array_classes})
endif ()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/vtkVTK_USE_IMPLICIT_ARRAYS.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_USE_IMPLICIT_ARRAYS.h")
set(headers
vtkABI.h
vtkArrayIteratorIncludes.h
@ -394,15 +351,7 @@ set(headers
"${CMAKE_CURRENT_BINARY_DIR}/vtkArrayDispatchArrayList.h"
"${CMAKE_CURRENT_BINARY_DIR}/vtkMathConfigure.h"
"${CMAKE_CURRENT_BINARY_DIR}/vtkTypeListMacros.h"
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_USE_SCALED_SOA_ARRAYS.h"
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_USE_IMPLICIT_ARRAYS.h")
if (VTK_BUILD_IMPLICIT_ARRAYS)
list(APPEND headers
vtkImplicitArrayTraits.h
${implicit_array_headers}
)
endif ()
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_USE_SCALED_SOA_ARRAYS.h")
set(private_headers
"${CMAKE_CURRENT_BINARY_DIR}/vtkFloatingPointExceptionsConfigure.h")

@ -93,16 +93,6 @@ if (VTK_BUILD_SCALED_SOA_ARRAYS)
set(scale_soa_test TestScaledSOADataArrayTemplate.cxx)
endif ()
if(VTK_BUILD_IMPLICIT_ARRAYS)
set(implicit_array_tests
TestAffineArray.cxx
TestConstantArray.cxx
TestImplicitArrayTraits.cxx
TestImplicitArraysBase.cxx
TestStdFunctionArray.cxx
)
endif ()
vtk_add_test_cxx(vtkCommonCoreCxxTests tests
NO_DATA NO_VALID NO_OUTPUT
@ -179,8 +169,6 @@ vtk_add_test_cxx(vtkCommonCoreCxxTests tests
${data_array_tests}
${scale_soa_test}
${implicit_array_tests}
)
# Special test to check whether disabling loguru signal handling, i.e.,

@ -11,11 +11,11 @@ GROUPS
DEPENDS
VTK::kwiml
VTK::vtksys
VTK::CommonImplicitBackends
PRIVATE_DEPENDS
VTK::utf8
OPTIONAL_DEPENDS
VTK::loguru
VTK::ImplicitArrays
TEST_DEPENDS
VTK::cli11
VTK::CommonDataModel

@ -146,32 +146,6 @@ if (VTK_DISPATCH_TYPED_ARRAYS)
)
endif()
if (VTK_BUILD_IMPLICIT_ARRAYS)
if (VTK_DISPATCH_STD_FUNCTION_ARRAYS)
list(APPEND vtkArrayDispatch_containers vtkStdFunctionArray)
set(vtkArrayDispatch_vtkStdFunctionArray_header vtkStdFunctionArray.h)
set(vtkArrayDispatch_vtkStdFunctionArray_types
${vtkArrayDispatch_all_types}
)
endif()
if (VTK_DISPATCH_CONSTANT_ARRAYS)
list(APPEND vtkArrayDispatch_containers vtkConstantArray)
set(vtkArrayDispatch_vtkConstantArray_header vtkConstantArray.h)
set(vtkArrayDispatch_vtkConstantArray_types
${vtkArrayDispatch_all_types}
)
endif()
if (VTK_DISPATCH_AFFINE_ARRAYS)
list(APPEND vtkArrayDispatch_containers vtkAffineArray)
set(vtkArrayDispatch_vtkAffineArray_header vtkAffineArray.h)
set(vtkArrayDispatch_vtkAffineArray_types
${vtkArrayDispatch_all_types}
)
endif()
endif()
endmacro()
# Create a header that declares the vtkArrayDispatch::Arrays TypeList.

@ -38,7 +38,7 @@
#ifdef VTK_USE_SCALED_SOA_ARRAYS
#include "vtkScaledSOADataArrayTemplate.h" // For fast paths
#endif
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
#include "vtkImplicitArray.h"
#endif
#include "vtkSMPTools.h"
@ -127,13 +127,13 @@ struct DeepCopyWorker
}
#endif
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
template <typename BackendTSrc, typename BackendTDst>
void operator()(vtkImplicitArray<BackendTSrc>* src, vtkImplicitArray<BackendTDst>* dst)
{
dst->ImplicitDeepCopy(src);
}
#endif // VTK_BUILD_IMPLICIT_ARRAYS
#endif // VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
// Undo warning suppression.
#if defined(__clang__) && defined(__has_warning)

@ -490,7 +490,7 @@ template <typename ValueType>
class vtkScaledSOADataArrayTemplate;
#endif
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
template <typename BackendT>
class vtkImplicitArray;
#include "vtkAffineImplicitBackend.h"
@ -509,7 +509,7 @@ VTK_ABI_NAMESPACE_END
template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char);
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
#define VTK_INSTANTIATE_VALUERANGE_ADD_IMPLICIT_BACKENDS(ValueType) \
VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
vtkImplicitArray<vtkAffineImplicitBackend<ValueType>>, ValueType) \
@ -559,7 +559,7 @@ class vtkSOADataArrayTemplate;
template <typename ValueType>
class vtkScaledSOADataArrayTemplate;
#endif
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
template <typename BackendT>
class vtkImplicitArray;
#include "vtkAffineImplicitBackend.h"
@ -593,7 +593,7 @@ VTK_ABI_NAMESPACE_END
extern template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char);
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
#define VTK_DECLARE_VALUERANGE_ADD_IMPLICIT_BACKENDS(ValueType) \
VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
vtkImplicitArray<vtkAffineImplicitBackend<ValueType>>, ValueType) \
@ -621,7 +621,7 @@ VTK_ABI_NAMESPACE_END
#endif
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
#define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT) \
VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<float>>, double) \
VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<double>>, double) \
@ -698,7 +698,7 @@ VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkScaledSOADataArrayTemplate<unsigned long lon
#endif // VTK_USE_SCALED_SOA_ARRAYS
// These are instantiated in vtk${BackendT}ArrayInstantiate_${i}.cxx
#ifdef VTK_BUILD_IMPLICIT_ARRAYS
#ifdef VTK_MODULE_ENABLE_VTK_CommonImplicitArrays
VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(vtkAffineImplicitBackend)
VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(vtkConstantImplicitBackend)

@ -1,22 +0,0 @@
/*=========================================================================
Program: Visualization Toolkit
Module: vtkVTK_USE_IMPLICIT_ARRAYS.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef vtkVTK_USE_IMPLICIT_ARRAYS_h
#define vtkVTK_USE_IMPLICIT_ARRAYS_h
// defined if VTK provides the vtkImplicitArray classes
#cmakedefine VTK_BUILD_IMPLICIT_ARRAYS
#endif // vtkVTK_USE_IMPLICIT_ARRAYS_h

@ -0,0 +1,78 @@
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)
option(VTK_DISPATCH_STD_FUNCTION_ARRAYS "Include implicit vtkDataArray subclasses based on std::function in dispatcher" OFF)
mark_as_advanced(
VTK_DISPATCH_CONSTANT_ARRAYS
VTK_DISPATCH_AFFINE_ARRAYS
VTK_DISPATCH_STD_FUNCTION_ARRAYS
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
@ONLY)
include("${CMAKE_CURRENT_SOURCE_DIR}/vtkCreateArrayDispatchImplicitList.cmake")
vtkArrayDispatchImplicit_default_array_setup()
vtkArrayDispatchImplicit_generate_array_header(VTK_ARRAYDISPATCH_IMPLICIT_ARRAY_LIST)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/vtkArrayDispatchImplicitArrayList.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkArrayDispatchImplicitArrayList.h"
@ONLY)
set(instantiation_sources)
foreach (INSTANTIATION_VALUE_TYPE IN LISTS vtkArrayDispatchImplicit_all_types)
# only instantiate fundamental types, not typedefs
if (INSTANTIATION_VALUE_TYPE STREQUAL "vtkIdType")
continue()
endif ()
# create a file suffix from the type
string(REPLACE " " "_" _suffix "${INSTANTIATION_VALUE_TYPE}")
list(APPEND _list "vtkAffineArrayInstantiate")
list(APPEND _list "vtkConstantArrayInstantiate")
list(APPEND _list "vtkStdFunctionArrayInstantiate")
# generate cxx file to instantiate template with this type
foreach (_prefix IN LISTS _list)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${_prefix}.cxx.in"
"${CMAKE_CURRENT_BINARY_DIR}/${_prefix}_${_suffix}.cxx"
@ONLY)
list(APPEND instantiation_sources
"${CMAKE_CURRENT_BINARY_DIR}/${_prefix}_${_suffix}.cxx")
endforeach ()
endforeach ()
set(headers
vtkAffineArray.h
vtkAffineImplicitBackend.h
vtkConstantArray.h
vtkConstantImplicitBackend.h
vtkImplicitArrayTraits.h
vtkStdFunctionArray.h
"${CMAKE_CURRENT_BINARY_DIR}/vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
)
set(template_classes
vtkImplicitArray
)
set(sources
${instantiation_sources}
)
vtk_module_add_module(VTK::CommonImplicitArrays
HEADERS ${headers}
TEMPLATE_CLASSES ${template_classes}
SOURCES ${sources}
)
vtk_add_test_mangling(VTK::CommonImplicitArrays
EXEMPTIONS GetVTKVersion)
vtk_module_compile_features(VTK::CommonImplicitArrays
PUBLIC
cxx_std_11)

@ -0,0 +1,10 @@
vtk_add_test_cxx(vtkCommonImplicitArrayCxxTests tests
NO_DATA NO_OUTPUT NO_VALID
TestAffineArray.cxx
TestConstantArray.cxx
TestImplicitArraysBase.cxx
TestImplicitArrayTraits.cxx
TestStdFunctionArray.cxx
)
vtk_test_cxx_executable(vtkCommonImplicitArrayCxxTests tests)

@ -14,11 +14,15 @@
=========================================================================*/
#include "vtkAffineArray.h"
#include "vtkArrayDispatch.h"
#include "vtkDataArrayRange.h"
#include "vtkIntArray.h"
#include "vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
#ifdef VTK_DISPATCH_AFFINE_ARRAYS
#include "vtkArrayDispatch.h"
#include "vtkArrayDispatchImplicitArrayList.h"
#endif // VTK_DISPATCH_AFFINE_ARRAYS
#include <cstdlib>
#include <memory>
@ -91,8 +95,10 @@ int TestAffineArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
vtkNew<vtkIntArray> destination;
destination->SetNumberOfTuples(100);
destination->SetNumberOfComponents(1);
using Dispatcher = vtkArrayDispatch::Dispatch2ByArray<vtkArrayDispatch::ReadOnlyArrays,
vtkArrayDispatch::Arrays>;
::ScaleWorker worker;
if (!vtkArrayDispatch::Dispatch2::Execute(affine, destination, worker, 3.0))
if (!Dispatcher::Execute(affine, destination, worker, 3.0))
{
res = EXIT_FAILURE;
std::cout << "vtkArrayDispatch failed with vtkAffineArray" << std::endl;

@ -14,11 +14,15 @@
=========================================================================*/
#include "vtkConstantArray.h"
#include "vtkArrayDispatch.h"
#include "vtkDataArrayRange.h"
#include "vtkIntArray.h"
#include "vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
#ifdef VTK_DISPATCH_CONSTANT_ARRAYS
#include "vtkArrayDispatch.h"
#include "vtkArrayDispatchImplicitArrayList.h"
#endif // VTK_DISPATCH_CONSTANT_ARRAYS
#include <cstdlib>
#include <memory>
@ -91,8 +95,10 @@ int TestConstantArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
vtkNew<vtkIntArray> destination;
destination->SetNumberOfTuples(100);
destination->SetNumberOfComponents(1);
using Dispatcher = vtkArrayDispatch::Dispatch2ByArray<vtkArrayDispatch::ReadOnlyArrays,
vtkArrayDispatch::Arrays>;
::ScaleWorker worker;
if (!vtkArrayDispatch::Dispatch2::Execute(identity, destination, worker, 3.0))
if (!Dispatcher::Execute(identity, destination, worker, 3.0))
{
res = EXIT_FAILURE;
std::cout << "vtkArrayDispatch failed with vtkConstantArray" << std::endl;

@ -19,6 +19,11 @@
#include "vtkIntArray.h"
#include "vtkVTK_DISPATCH_IMPLICIT_ARRAYS.h"
#ifdef VTK_DISPATCH_STD_FUNCTION_ARRAYS
#include "vtkArrayDispatch.h"
#include "vtkArrayDispatchImplicitArrayList.h"
#endif // VTK_DISPATCH_STD_FUNCTION_ARRAYS
#include <cstdlib>
#include <memory>
@ -92,8 +97,10 @@ int TestStdFunctionArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
vtkNew<vtkIntArray> destination;
destination->SetNumberOfTuples(100);
destination->SetNumberOfComponents(1);
using Dispatcher = vtkArrayDispatch::Dispatch2ByArray<vtkArrayDispatch::ReadOnlyArrays,
vtkArrayDispatch::Arrays>;
::ScaleWorker worker;
if (!vtkArrayDispatch::Dispatch2::Execute(identity, destination, worker, 3.0))
if (!Dispatcher::Execute(identity, destination, worker, 3.0))
{
res = EXIT_FAILURE;
std::cout << "vtkArrayDispatch failed with vtkStdFunctionArray" << std::endl;

@ -0,0 +1,14 @@
NAME
VTK::CommonImplicitArrays
LIBRARY_NAME
vtkCommonImplicitArrays
DESCRIPTION
A VTK library for the for the vtkImplicitArray framework
KIT
VTK::Common
GROUPS
StandAlone
DEPENDS
VTK::CommonCore
TEST_DEPENDS
VTK::TestingCore

@ -64,7 +64,7 @@ VTK_ABI_NAMESPACE_END
#ifdef _MSC_VER
#pragma warning(push)
// The following is needed when the vtkImplicitArray is declared
// dllexport and is used from another class in vtkCommonCore
// dllexport and is used from another class in vtkCommonImplicitArray
#pragma warning(disable : 4910) // extern and dllexport incompatible
#endif
VTK_ABI_NAMESPACE_BEGIN
@ -76,4 +76,36 @@ VTK_ABI_NAMESPACE_END
#endif
#endif // VTK_AFFINE_ARRAY_TEMPLATE_EXTERN
// The following clause is only for MSVC
#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
#pragma warning(push)
// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
#pragma warning(disable : 4091)
// Compiler-specific extension warning.
#pragma warning(disable : 4231)
// We need to disable warning 4910 and do an extern dllexport
// anyway. When deriving vtkCharArray and other types from an
// instantiation of this template the compiler does an explicit
// instantiation of the base class. From outside the vtkCommon
// library we block this using an extern dllimport instantiation.
// For classes inside vtkCommon we should be able to just do an
// extern instantiation, but VS complains about missing
// definitions. We cannot do an extern dllimport inside vtkCommon
// since the symbols are local to the dll. An extern dllexport
// seems to be the only way to convince VS to do the right
// thing, so we just disable the warning.
#pragma warning(disable : 4910) // extern and dllexport incompatible
// Use an "extern explicit instantiation" to give the class a DLL
// interface. This is a compiler-specific extension.
VTK_ABI_NAMESPACE_BEGIN
vtkInstantiateSecondOrderTemplateMacro(
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray, vtkAffineImplicitBackend);
VTK_ABI_NAMESPACE_END
#pragma warning(pop)
#endif // VTK_AFFINE_ARRAY_INSTANTIATING

@ -0,0 +1 @@
@VTK_ARRAYDISPATCH_IMPLICIT_ARRAY_LIST@

@ -74,7 +74,38 @@ VTK_ABI_NAMESPACE_END
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // VTK_CONSTANT_ARRAY_TEMPLATE_EXTERN
// The following clause is only for MSVC
#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
#pragma warning(push)
// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
#pragma warning(disable : 4091)
// Compiler-specific extension warning.
#pragma warning(disable : 4231)
// We need to disable warning 4910 and do an extern dllexport
// anyway. When deriving vtkCharArray and other types from an
// instantiation of this template the compiler does an explicit
// instantiation of the base class. From outside the vtkCommon
// library we block this using an extern dllimport instantiation.
// For classes inside vtkCommon we should be able to just do an
// extern instantiation, but VS complains about missing
// definitions. We cannot do an extern dllimport inside vtkCommon
// since the symbols are local to the dll. An extern dllexport
// seems to be the only way to convince VS to do the right
// thing, so we just disable the warning.
#pragma warning(disable : 4910) // extern and dllexport incompatible
// Use an "extern explicit instantiation" to give the class a DLL
// interface. This is a compiler-specific extension.
VTK_ABI_NAMESPACE_BEGIN
vtkInstantiateSecondOrderTemplateMacro(
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray, vtkConstantImplicitBackend);
VTK_ABI_NAMESPACE_END
#pragma warning(pop)
#endif // VTK_CONSTANT_ARRAY_INSTANTIATING

@ -0,0 +1,196 @@
# This file contains macros that are used by VTK to generate the list of
# implicit arrays used by the vtkArrayDispatch system.
#
# There are a number of CMake variables that control the final array list. At
# the high level, the following options enable/disable predefined categories of
# arrays:
#
# - VTK_DISPATCH_AFFINE_ARRAYS (default: OFF)
# Include vtkAffineArray<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_STD_FUNCTION_ARRAYS (default: OFF)
# Include vtkStdFunctionArray<ValueType> for the basic types supported
# by VTK.
#
# At a lower level, specific arrays can be added to the list individually in
# two ways:
#
# For templated classes, set the following variables:
# - vtkArrayDispatchImplicit_containers:
# List of template class names.
# - vtkArrayDispatchImplicit_[template class name]_types:
# For the specified template class, add an entry to the array list that
# instantiates the container for each type listed here.
# - vtkArrayDispatchImplicit_[template class name]_header
# Specifies the header file to include for the specified template class.
#
# Both templated and non-templated arrays can be added using these variables:
# - vtkArrayDispatchImplicit_extra_arrays:
# List of arrays to add to the list.
# - vtkArrayDispatchImplicit_extra_headers:
# List of headers to include.
#
################################ Example #######################################
#
# The cmake call below instantiates the array list that follows:
#
# cmake [path to VTK source]
# -DvtkArrayDispatchImplicit_containers="MyCustomArray1;MyCustomArray2"
# -DvtkArrayDispatchImplicit_MyCustomArray1_header="MyCustomArray1.h"
# -DvtkArrayDispatchImplicit_MyCustomArray1_types="float;double"
# -DvtkArrayDispatchImplicit_MyCustomArray2_header="MyCustomArray2.h"
# -DvtkArrayDispatchImplicit_MyCustomArray2_types="int;unsigned char"
# -DvtkArrayDispatchImplicit_extra_headers="ExtraHeader1.h;ExtraHeader2.h"
# -DvtkArrayDispatchImplicit_extra_arrays="ExtraArray1;ExtraArray2<float>;ExtraArray2<char>"
#
# Generated header:
#
# #ifndef vtkArrayDispatchImplicitArrayList_h
# #define vtkArrayDispatchImplicitArrayList_h
#
# #include "vtkTypeList.h"
# #include "MyCustomArray1.h"
# #include "MyCustomArray2.h"
# #include "ExtraHeader1.h"
# #include "ExtraHeader2.h"
# #include "vtkArrayDispatchArrayList.h"
#
# namespace vtkArrayDispatch {
#
# VTK_ABI_NAMESPACE_BEGIN
#
# typedef vtkTypeList::Unique<
# vtkTypeListvtkTypeList::Create<
# MyCustomArray1<float>,
# MyCustomArray1<double>,
# MyCustomArray2<int>,
# MyCustomArray2<unsigned char>,
# ExtraArray1,
# ExtraArray2<float>,
# ExtraArray2<char>
# >
# >::Result ReadOnlyArrays;
#
# typedef vtkTypeList::Unique< vtkTypeList::TypeList<Arrays, ReadOnlyArrays> >::Result AllArrays;
#
# VTK_ABI_NAMESPACE_END
#
# } // end namespace vtkArrayDispatch
#
# #endif // vtkArrayDispatchImplicitArrayList_h
#
# Populate the environment so that vtk_array_dispatch_generate_array_header will
# create the array TypeList with all known array types.
macro(vtkArrayDispatchImplicit_default_array_setup)
# The default set of scalar types:
set(vtkArrayDispatchImplicit_all_types
"char"
"double"
"float"
"int"
"long"
"long long"
"short"
"signed char"
"unsigned char"
"unsigned int"
"unsigned long"
"unsigned long long"
"unsigned short"
"vtkIdType"
)
if (VTK_DISPATCH_STD_FUNCTION_ARRAYS)
list(APPEND vtkArrayDispatchImplicit_containers vtkStdFunctionArray)
set(vtkArrayDispatchImplicit_vtkStdFunctionArray_header vtkStdFunctionArray.h)
set(vtkArrayDispatchImplicit_vtkStdFunctionArray_types
${vtkArrayDispatchImplicit_all_types}
)
endif()
if (VTK_DISPATCH_CONSTANT_ARRAYS)
list(APPEND vtkArrayDispatchImplicit_containers vtkConstantArray)
set(vtkArrayDispatchImplicit_vtkConstantArray_header vtkConstantArray.h)
set(vtkArrayDispatchImplicit_vtkConstantArray_types
${vtkArrayDispatchImplicit_all_types}
)
endif()
if (VTK_DISPATCH_AFFINE_ARRAYS)
list(APPEND vtkArrayDispatchImplicit_containers vtkAffineArray)
set(vtkArrayDispatchImplicit_vtkAffineArray_header vtkAffineArray.h)
set(vtkArrayDispatchImplicit_vtkAffineArray_types
${vtkArrayDispatchImplicit_all_types}
)
endif()
endmacro()
# Create a header that declares the vtkArrayDispatch::Arrays TypeList.
macro(vtkArrayDispatchImplicit_generate_array_header result)
set(vtkAD_headers vtkTypeList.h)
list(APPEND vtkAD_headers vtkArrayDispatchArrayList.h)
set(vtkAD_arrays)
foreach(container ${vtkArrayDispatchImplicit_containers})
list(APPEND vtkAD_headers ${vtkArrayDispatchImplicit_${container}_header})
foreach(value_type ${vtkArrayDispatchImplicit_${container}_types})
list(APPEND vtkAD_arrays "${container}<${value_type}>")
endforeach()
endforeach()
# Include externally specified headers/arrays:
list(APPEND vtkAD_headers ${vtkArrayDispatchImplicit_extra_headers})
list(APPEND vtkAD_arrays ${vtkArrayDispatchImplicit_extra_arrays})
set(temp
"// This file is autogenerated by vtkCreateArrayDispatchImplicitArrayList.cmake.\n"
"// Do not edit this file. Your changes will not be saved.\n"
"\n"
"#ifndef vtkArrayDispatchImplicitArrayList_h\n"
"#define vtkArrayDispatchImplicitArrayList_h\n"
"\n"
)
foreach(header ${vtkAD_headers})
list(APPEND temp "#include \"${header}\"\n")
endforeach()
list(APPEND temp
"\n"
"namespace vtkArrayDispatch {\n"
"VTK_ABI_NAMESPACE_BEGIN\n"
"\n"
"typedef vtkTypeList::Unique<\n"
" vtkTypeList::Create<\n"
)
foreach(array ${vtkAD_arrays})
list(APPEND temp " ${array},\n")
endforeach()
# Remove the final comma from the array list:
string(CONCAT temp ${temp})
string(REGEX REPLACE ",\n$" "\n" temp "${temp}")
list(APPEND temp
" >\n"
">::Result ReadOnlyArrays\;\n"
"\n"
"typedef vtkTypeList::Unique< vtkTypeList::TypeList<Arrays, ReadOnlyArrays>>::Result AllArrays\;\n"
"\n"
"VTK_ABI_NAMESPACE_END\n"
"\n"
"} // end namespace vtkArrayDispatch\n"
"#endif // vtkArrayDispatchImplicitArrayList_h\n"
)
string(CONCAT ${result} ${temp})
endmacro()

@ -91,4 +91,46 @@ VTK_ABI_NAMESPACE_END
#endif
#endif // VTK_STD_FUNCTION_ARRAY_TEMPLATE_EXTERN
// The following clause is only for MSVC
#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
#pragma warning(push)
// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
#pragma warning(disable : 4091)
// Compiler-specific extension warning.
#pragma warning(disable : 4231)
// We need to disable warning 4910 and do an extern dllexport
// anyway. When deriving vtkCharArray and other types from an
// instantiation of this template the compiler does an explicit
// instantiation of the base class. From outside the vtkCommon
// library we block this using an extern dllimport instantiation.
// For classes inside vtkCommon we should be able to just do an
// extern instantiation, but VS complains about missing
// definitions. We cannot do an extern dllimport inside vtkCommon
// since the symbols are local to the dll. An extern dllexport
// seems to be the only way to convince VS to do the right
// thing, so we just disable the warning.
#pragma warning(disable : 4910) // extern and dllexport incompatible
// Use an "extern explicit instantiation" to give the class a DLL
// interface. This is a compiler-specific extension.
VTK_ABI_NAMESPACE_BEGIN
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<float(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<double(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<char(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<signed char(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<unsigned char(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<short(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<unsigned short(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<int(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<long(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<unsigned long(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<long long(int)>>;
extern template class VTKCOMMONCORE_EXPORT vtkImplicitArray<std::function<unsigned long long(int)>>;
VTK_ABI_NAMESPACE_END
#pragma warning(pop)
#endif // VTK_STD_FUNCTION_ARRAY_INSTANTIATING

@ -1,9 +0,0 @@
set(headers
vtkAffineImplicitBackend.h
vtkConstantImplicitBackend.h
)
vtk_module_add_module(VTK::CommonImplicitBackends
HEADER_ONLY
HEADERS ${headers}
)

@ -1,10 +0,0 @@
NAME
VTK::CommonImplicitBackends
LIBRARY_NAME
vtkCommonImplicitBackends
DESCRIPTION
A VTK library for the backends intended for vtkImplicitArray
KIT
VTK::Common
GROUPS
StandAlone

@ -20,6 +20,7 @@ PRIVATE_DEPENDS
VTK::CommonTransforms
VTK::vtksys
TEST_DEPENDS
VTK::CommonImplicitArrays
VTK::CommonSystem
VTK::FiltersFlowPaths
VTK::FiltersExtraction

@ -22,6 +22,7 @@ PRIVATE_DEPENDS
VTK::IOCore
VTK::eigen
TEST_DEPENDS
VTK::CommonImplicitArrays
VTK::FiltersAMR
VTK::FiltersExtraction
VTK::FiltersGeneral

@ -68,7 +68,6 @@ bool RedistributeImageData(vtkMultiProcessController* controller)
vtkNew<vtkImplicitArray<Backend42>> vortex;
vortex->SetName("42");
baseGrid->GetPointData()->AddArray(vortex);
baseGrid->GetPointData()->SetActiveVectors("42");
if (controller->GetLocalProcessId() == 0)
{
baseGrid->SetExtent(-halfCells / 2, halfCells, -halfCells, halfCells, -halfCells, halfCells);
@ -83,6 +82,7 @@ bool RedistributeImageData(vtkMultiProcessController* controller)
vortex->SetNumberOfComponents(3);
vortex->SetNumberOfTuples(baseGrid->GetNumberOfPoints());
}
baseGrid->GetPointData()->SetActiveVectors("42");
vtkNew<vtkRedistributeDataSetFilter> redistribute;
redistribute->SetInputData(baseGrid);

@ -22,6 +22,7 @@ PRIVATE_DEPENDS
VTK::IOXML
VTK::ParallelCore
TEST_DEPENDS
VTK::CommonImplicitArrays
VTK::diy2
VTK::FiltersGeometry
VTK::FiltersParallelMPI

@ -19,6 +19,7 @@ PRIVATE_DEPENDS
VTK::CommonTransforms
VTK::ImagingCore
TEST_DEPENDS
VTK::CommonImplicitArrays
VTK::CommonSystem
VTK::FiltersGeometry
VTK::FiltersModeling

Loading…
Cancel
Save