refactor using pimpl and fix test

This commit is contained in:
AndreaRigoni
2026-03-25 16:18:07 +00:00
parent a467b7385b
commit 7d4acaef6d
17 changed files with 479 additions and 412 deletions

View File

@@ -109,8 +109,20 @@ public:
VoxImage(const Vector3i &size);
VoxImage(const VoxImage<T> &copy) : BaseClass(copy) {
this->m_Data = copy.m_Data;
// Use compiler-generated copy constructor and assignment operator
VoxImage<T>& operator=(const VoxImage<T>& other) {
if (this != &other) {
// Copy the base class non-virtual parts (dims, spacing, position, etc.)
// WITHOUT going through the virtual SetDims chain (which would call
// m_Data.resize() THEN DataAllocator::operator= will resize again → double-free).
// Instead, directly copy DataAllocator and update the StructuredGrid state.
this->m_Data = other.m_Data;
StructuredGrid::SetDims(other.GetDims());
this->SetSpacing(other.GetSpacing());
this->SetPosition(other.GetPosition());
}
return *this;
}
inline DataAllocator<T> &Data() { return this->m_Data; }