mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 10:17:55 -06:00
Fixed out-of-bouds access in RammingChart.cpp in case the ramming was turned off
This commit is contained in:
parent
e9d629f248
commit
7185125f9c
1 changed files with 81 additions and 82 deletions
|
@ -141,6 +141,9 @@ void Chart::mouse_double_clicked(wxMouseEvent& event) {
|
||||||
|
|
||||||
|
|
||||||
void Chart::recalculate_line() {
|
void Chart::recalculate_line() {
|
||||||
|
m_line_to_draw.clear();
|
||||||
|
m_total_volume = 0.f;
|
||||||
|
|
||||||
std::vector<wxPoint> points;
|
std::vector<wxPoint> points;
|
||||||
for (auto& but : m_buttons) {
|
for (auto& but : m_buttons) {
|
||||||
points.push_back(wxPoint(math_to_screen(but.get_pos())));
|
points.push_back(wxPoint(math_to_screen(but.get_pos())));
|
||||||
|
@ -150,12 +153,11 @@ void Chart::recalculate_line() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The calculation wouldn't work in case the ramming is to be turned off completely.
|
||||||
|
if (points.size()>1) {
|
||||||
std::sort(points.begin(),points.end(),[](wxPoint& a,wxPoint& b) { return a.x < b.x; });
|
std::sort(points.begin(),points.end(),[](wxPoint& a,wxPoint& b) { return a.x < b.x; });
|
||||||
|
|
||||||
m_line_to_draw.clear();
|
|
||||||
m_total_volume = 0.f;
|
|
||||||
|
|
||||||
|
|
||||||
// Cubic spline interpolation: see https://en.wikiversity.org/wiki/Cubic_Spline_Interpolation#Methods
|
// Cubic spline interpolation: see https://en.wikiversity.org/wiki/Cubic_Spline_Interpolation#Methods
|
||||||
const bool boundary_first_derivative = true; // true - first derivative is 0 at the leftmost and rightmost point
|
const bool boundary_first_derivative = true; // true - first derivative is 0 at the leftmost and rightmost point
|
||||||
// false - second ---- || -------
|
// false - second ---- || -------
|
||||||
|
@ -202,9 +204,6 @@ void Chart::recalculate_line() {
|
||||||
for (int i=N-1;i>=0;--i)
|
for (int i=N-1;i>=0;--i)
|
||||||
rhs[i] = (rhs[i]-lambda[i]*rhs[i+1])/diag[i];
|
rhs[i] = (rhs[i]-lambda[i]*rhs[i+1])/diag[i];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int i=1;
|
unsigned int i=1;
|
||||||
float y=0.f;
|
float y=0.f;
|
||||||
for (int x=m_rect.GetLeft(); x<=m_rect.GetRight() ; ++x) {
|
for (int x=m_rect.GetLeft(); x<=m_rect.GetRight() ; ++x) {
|
||||||
|
@ -230,11 +229,11 @@ void Chart::recalculate_line() {
|
||||||
m_line_to_draw.push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[i].get_pos().m_y)).y);
|
m_line_to_draw.push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[i].get_pos().m_y)).y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_line_to_draw.back() = std::max(m_line_to_draw.back(), m_rect.GetTop()-1);
|
m_line_to_draw.back() = std::max(m_line_to_draw.back(), m_rect.GetTop()-1);
|
||||||
m_line_to_draw.back() = std::min(m_line_to_draw.back(), m_rect.GetBottom()-1);
|
m_line_to_draw.back() = std::min(m_line_to_draw.back(), m_rect.GetBottom()-1);
|
||||||
m_total_volume += (m_rect.GetBottom() - m_line_to_draw.back()) * (visible_area.m_width / m_rect.GetWidth()) * (visible_area.m_height / m_rect.GetHeight());
|
m_total_volume += (m_rect.GetBottom() - m_line_to_draw.back()) * (visible_area.m_width / m_rect.GetWidth()) * (visible_area.m_height / m_rect.GetHeight());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxPostEvent(this->GetParent(), wxCommandEvent(EVT_WIPE_TOWER_CHART_CHANGED));
|
wxPostEvent(this->GetParent(), wxCommandEvent(EVT_WIPE_TOWER_CHART_CHANGED));
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue