refactor using pimpl and fix test
This commit is contained in:
@@ -109,8 +109,20 @@ public:
|
||||
|
||||
VoxImage(const Vector3i &size);
|
||||
|
||||
VoxImage(const VoxImage<T> ©) : 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; }
|
||||
|
||||
Reference in New Issue
Block a user