Skip to content
Snippets Groups Projects
Commit 37301a94 authored by Ben Boeckel's avatar Ben Boeckel Committed by Spiros Tsalikis
Browse files

vtkAffineImplicitBackend: move implementation into its own file

This hides it from those just looking for the declaration and
accidentally instantiating it.
parent 8fd0d339
No related branches found
No related tags found
No related merge requests found
......@@ -401,6 +401,7 @@ set(templates
${vtk_smp_templates})
set(private_templates
vtkAffineImplicitBackend.txx
vtkDataArrayPrivate.txx)
set(vtk_include_dirs)
......
......@@ -40,11 +40,7 @@ struct VTKCOMMONCORE_EXPORT vtkAffineImplicitBackend final
* \param slope the slope of the affine function
* \param intercept the intercept value at the origin (i.e. the value at 0)
*/
vtkAffineImplicitBackend(ValueType slope, ValueType intercept)
: Slope(slope)
, Intercept(intercept)
{
}
vtkAffineImplicitBackend(ValueType slope, ValueType intercept);
/**
* The main call method for the backend
......@@ -52,10 +48,7 @@ struct VTKCOMMONCORE_EXPORT vtkAffineImplicitBackend final
* \param index the index at which one wished to evaluate the backend
* \return the affinely computed value
*/
ValueType operator()(int index) const
{
return this->Slope * static_cast<ValueType>(index) + this->Intercept;
}
ValueType operator()(int index) const;
/**
* The slope of the affine function on the indeces
......@@ -69,10 +62,3 @@ struct VTKCOMMONCORE_EXPORT vtkAffineImplicitBackend final
VTK_ABI_NAMESPACE_END
#endif // vtkAffineImplicitBackend_h
#ifdef VTK_AFFINE_BACKEND_INSTANTIATING
#define VTK_INSTANTIATE_AFFINE_BACKEND(ValueType) \
VTK_ABI_NAMESPACE_BEGIN \
template struct VTKCOMMONCORE_EXPORT vtkAffineImplicitBackend<ValueType>; \
VTK_ABI_NAMESPACE_END
#endif
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
// Funded by CEA, DAM, DIF, F-91297 Arpajon, France
#ifndef vtkAffineImplicitBackend_txx
#define vtkAffineImplicitBackend_txx
#include "vtkAffineImplicitBackend.h"
/**
* \struct vtkAffineImplicitBackend
* \brief A utility structure serving as a backend for affine (as a function of the index) implicit
* arrays
*
* This structure can be classified as a closure and can be called using syntax similar to a
* function call.
*
* At construction it takes two parameters: the slope of the map and the intercept. It returns a
* value calculated as:
*
* value = slope * index + intercept
*
* An example of potential usage in a vtkImplicitArray
* ```
* double slope = some_number;
* double intercept = some_other_number;
* vtkNew<vtkImplicitArray<vtkAffineImplicitBackend<double>>> affineArray;
* affineArray->SetBackend(std::make_shared<vtkAffineImplicitBackend<double>>(slope, intercept));
* affineArray->SetNumberOfTuples(however_many_you_want);
* affineArray->SetNumberOfComponents(whatever_youd_like);
* double value = affineArray->GetTypedComponent(index_in_tuple_range, index_in_component_range);
* ```
*/
VTK_ABI_NAMESPACE_BEGIN
template <typename ValueType>
vtkAffineImplicitBackend<ValueType>::vtkAffineImplicitBackend(ValueType slope, ValueType intercept)
: Slope(slope)
, Intercept(intercept)
{
}
template <typename ValueType>
ValueType vtkAffineImplicitBackend<ValueType>::operator()(int index) const
{
return this->Slope * static_cast<ValueType>(index) + this->Intercept;
}
#endif // vtkAffineImplicitBackend_txx
#ifdef VTK_AFFINE_BACKEND_INSTANTIATING
#define VTK_INSTANTIATE_AFFINE_BACKEND(ValueType) \
VTK_ABI_NAMESPACE_BEGIN \
template struct VTKCOMMONCORE_EXPORT vtkAffineImplicitBackend<ValueType>; \
VTK_ABI_NAMESPACE_END
#endif
/*=========================================================================
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
Program: Visualization Toolkit
Module: vtkAffineImplicitBackendInstantiate_@INSTANTIATION_VALUE_TYPE@.cxx
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.
=========================================================================*/
#define VTK_AFFINE_BACKEND_INSTANTIATING
#include "vtkAffineImplicitBackend.h"
#include "vtkAffineImplicitBackend.txx"
VTK_INSTANTIATE_AFFINE_BACKEND(@INSTANTIATION_VALUE_TYPE@)
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