Skip to content
Snippets Groups Projects
Commit ab8498fa authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Layer: remove private copy constructor and refactor clone and cloneInvertB

parent 32ec7781
No related branches found
No related tags found
No related merge requests found
...@@ -36,16 +36,20 @@ Layer::Layer(HomogeneousMaterial material, double thickness) ...@@ -36,16 +36,20 @@ Layer::Layer(HomogeneousMaterial material, double thickness)
Layer::~Layer() Layer::~Layer()
{} {}
Layer*Layer::clone() const Layer* Layer::clone() const
{ {
return new Layer(*this); Layer* p_result = shallowClone();
p_result->m_n_slices = m_n_slices;
for (auto p_layout : layouts())
p_result->addLayout(*p_layout);
return p_result;
} }
Layer* Layer::cloneInvertB() const Layer* Layer::cloneInvertB() const
{ {
Layer* p_clone = new Layer(m_material.inverted(), m_thickness); Layer* p_result = shallowClone();
p_clone->m_B_field = - m_B_field; p_result->m_B_field = -m_B_field;
return p_clone; return p_result;
} }
SafePointerVector<Layer> Layer::cloneSliced(ZLimits limits, Layer::ELayerType layer_type) const SafePointerVector<Layer> Layer::cloneSliced(ZLimits limits, Layer::ELayerType layer_type) const
...@@ -160,18 +164,6 @@ void Layer::initBField(kvector_t h_field, double b_z) ...@@ -160,18 +164,6 @@ void Layer::initBField(kvector_t h_field, double b_z)
m_B_field.setZ(b_z); m_B_field.setZ(b_z);
} }
Layer::Layer(const Layer& other)
: m_material(other.m_material)
{
setName(other.getName());
m_thickness = other.m_thickness;
m_n_slices = other.m_n_slices;
m_B_field = other.m_B_field;
for (auto p_layout : other.layouts())
addLayout(*p_layout);
registerThickness();
}
Layer* Layer::shallowClone() const Layer* Layer::shallowClone() const
{ {
Layer* p_result = new Layer(m_material, m_thickness); Layer* p_result = new Layer(m_material, m_thickness);
......
...@@ -81,7 +81,6 @@ public: ...@@ -81,7 +81,6 @@ public:
static constexpr double Magnetic_Permeability = 4e-7 * M_PI; static constexpr double Magnetic_Permeability = 4e-7 * M_PI;
private: private:
Layer(const Layer& other);
//! Clone the layer without its layouts //! Clone the layer without its layouts
Layer* shallowClone() const; Layer* shallowClone() const;
//! Clone and offsets the particles in the z-direction //! Clone and offsets the particles in the z-direction
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment