refactor: update transformation system, improve template readability, and reorganize VTK assembly management

This commit is contained in:
AndreaRigoni
2026-03-31 16:04:03 +00:00
parent 22d0041942
commit d4fd2d3914
30 changed files with 568 additions and 501 deletions

View File

@@ -98,15 +98,14 @@ template <typename T> void Kernel<T>::PrintSelf(std::ostream &o) const {
////////////////////////////////////////////////////////////////////////////////
#define _TPL_ template <typename VoxelT, typename AlgorithmT>
#define _TPLT_ VoxelT, AlgorithmT
_TPL_
VoxImageFilter<_TPLT_>::VoxImageFilter(const Vector3i &size)
template <typename VoxelT, typename AlgorithmT>
VoxImageFilter<VoxelT, AlgorithmT>::VoxImageFilter(const Vector3i &size)
: m_KernelData(size), t_Algoritm(static_cast<AlgorithmT *>(this)) {}
_TPL_
void VoxImageFilter<_TPLT_>::Run() {
template <typename VoxelT, typename AlgorithmT>
void VoxImageFilter<VoxelT, AlgorithmT>::Run() {
VoxImage<VoxelT> buffer = *m_Image;
#pragma omp parallel for
for (int i = 0; i < m_Image->Data().size(); ++i)
@@ -114,8 +113,8 @@ void VoxImageFilter<_TPLT_>::Run() {
#pragma omp barrier
}
_TPL_
void VoxImageFilter<_TPLT_>::SetKernelOffset() {
template <typename VoxelT, typename AlgorithmT>
void VoxImageFilter<VoxelT, AlgorithmT>::SetKernelOffset() {
Vector3i id(0, 0, 0);
for (int z = 0; z < m_KernelData.GetDims()(2); ++z) {
for (int x = 0; x < m_KernelData.GetDims()(0); ++x) {
@@ -127,8 +126,8 @@ void VoxImageFilter<_TPLT_>::SetKernelOffset() {
}
}
_TPL_
float VoxImageFilter<_TPLT_>::Distance2(const Vector3i &v) {
template <typename VoxelT, typename AlgorithmT>
float VoxImageFilter<VoxelT, AlgorithmT>::Distance2(const Vector3i &v) {
Vector3i tmp = v;
const Vector3i &dim = this->m_KernelData.GetDims();
Vector3i center = dim / 2;
@@ -140,8 +139,8 @@ float VoxImageFilter<_TPLT_>::Distance2(const Vector3i &v) {
0.25 * (3 - (dim(0) % 2) - (dim(1) % 2) - (dim(2) % 2)));
}
_TPL_
void VoxImageFilter<_TPLT_>::SetKernelNumericXZY(
template <typename VoxelT, typename AlgorithmT>
void VoxImageFilter<VoxelT, AlgorithmT>::SetKernelNumericXZY(
const std::vector<float> &numeric) {
// set data order //
StructuredData::Order order = m_KernelData.GetDataOrder();
@@ -159,8 +158,8 @@ void VoxImageFilter<_TPLT_>::SetKernelNumericXZY(
// m_KernelData.SetDataOrder(order);
}
_TPL_
void VoxImageFilter<_TPLT_>::SetKernelSpherical(float (*shape)(float)) {
template <typename VoxelT, typename AlgorithmT>
void VoxImageFilter<VoxelT, AlgorithmT>::SetKernelSpherical(float (*shape)(float)) {
Vector3i id;
for (int y = 0; y < m_KernelData.GetDims()(1); ++y) {
for (int z = 0; z < m_KernelData.GetDims()(2); ++z) {
@@ -172,8 +171,8 @@ void VoxImageFilter<_TPLT_>::SetKernelSpherical(float (*shape)(float)) {
}
}
_TPL_ template <class ShapeT>
void VoxImageFilter<_TPLT_>::SetKernelSpherical(ShapeT shape) {
template <typename VoxelT, typename AlgorithmT> template <class ShapeT>
void VoxImageFilter<VoxelT, AlgorithmT>::SetKernelSpherical(ShapeT shape) {
Interface::IsA<ShapeT, Interface::VoxImageFilterShape>();
Vector3i id;
for (int y = 0; y < m_KernelData.GetDims()(1); ++y) {
@@ -186,8 +185,8 @@ void VoxImageFilter<_TPLT_>::SetKernelSpherical(ShapeT shape) {
}
}
_TPL_
void VoxImageFilter<_TPLT_>::SetKernelWeightFunction(
template <typename VoxelT, typename AlgorithmT>
void VoxImageFilter<VoxelT, AlgorithmT>::SetKernelWeightFunction(
float (*shape)(const Vector3f &)) {
const Vector3i &dim = m_KernelData.GetDims();
Vector3i id;
@@ -207,8 +206,8 @@ void VoxImageFilter<_TPLT_>::SetKernelWeightFunction(
}
}
_TPL_ template <class ShapeT>
void VoxImageFilter<_TPLT_>::SetKernelWeightFunction(ShapeT shape) {
template <typename VoxelT, typename AlgorithmT> template <class ShapeT>
void VoxImageFilter<VoxelT, AlgorithmT>::SetKernelWeightFunction(ShapeT shape) {
Interface::IsA<ShapeT, Interface::VoxImageFilterShape>();
const Vector3i &dim = m_KernelData.GetDims();
Vector3i id;
@@ -228,14 +227,14 @@ void VoxImageFilter<_TPLT_>::SetKernelWeightFunction(ShapeT shape) {
}
}
_TPL_
void VoxImageFilter<_TPLT_>::SetImage(Abstract::VoxImage *image) {
template <typename VoxelT, typename AlgorithmT>
void VoxImageFilter<VoxelT, AlgorithmT>::SetImage(Abstract::VoxImage *image) {
this->m_Image = reinterpret_cast<VoxImage<VoxelT> *>(image);
this->SetKernelOffset();
}
_TPL_
float VoxImageFilter<_TPLT_>::Convolve(const VoxImage<VoxelT> &buffer,
template <typename VoxelT, typename AlgorithmT>
float VoxImageFilter<VoxelT, AlgorithmT>::Convolve(const VoxImage<VoxelT> &buffer,
int index) {
const DataAllocator<VoxelT> &vbuf = buffer.ConstData();
const DataAllocator<VoxelT> &vker = m_KernelData.ConstData();
@@ -252,8 +251,8 @@ float VoxImageFilter<_TPLT_>::Convolve(const VoxImage<VoxelT> &buffer,
return conv / ksum;
}
#undef _TPLT_
#undef _TPL_
} // namespace uLib