Clone of dtkNurbsCurveData2D in 'convexHull3DApproximation'
In convexHull3DApproximation
, even when dtkNurbsCurveData2D is const& and then cloned
, it is modified after 'delete' its 'cloned' copy.
Xiao created a copy of dtkNurbsCurveData2D as a workaround.
Put std::cout << "degree: " << p_rational_bezier_curve.degree() << std::endl;
before and after
delete (*it);
, we can see that the degree changes although p_rational_bezier_curve
is a const&.
The reason may be the clone
function in dtkNurbsCurveData2D is not a deep clone, and after we changed to a shared pointer, it still didn't solve the issue.
We call new dtkRationalBezierCurve2D(p_rational_bezier_curve);
dtkRationalBezierCurve2D
contains dtkAbstractRationalBezierCurve2DData *m_data;
and the copy constructor of dtkRationalBezierCurve2D
calls m_data->clone()
.
m_data
is of the type dtkRationalBezierCurve2DDataOn
and the clone()
function makes a copy of *this
, that is a copy of mutable ON_BezierCurve* d;