mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE -> Small refactoring to improve performances
This commit is contained in:
parent
e1f06a1b84
commit
68a9980a5e
2 changed files with 11 additions and 7 deletions
|
@ -361,16 +361,15 @@ std::vector<double> smooth_height_profile(const std::vector<double>& profile, co
|
||||||
|
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
ret.push_back(0.0);
|
||||||
double value = 0.0;
|
double& height = ret.back();
|
||||||
for (int j = (int)(i - radius); j <= (int)(i + radius); ++j)
|
int begin = (int)(i - radius);
|
||||||
|
int end = (int)(i + radius);
|
||||||
|
for (int j = begin; j <= end; ++j)
|
||||||
{
|
{
|
||||||
if ((0 <= j) && (j < size))
|
if ((0 <= j) && (j < size))
|
||||||
value += kernel[id] * profile[j];
|
height += kernel[j - begin] * profile[j];
|
||||||
|
|
||||||
++id;
|
|
||||||
}
|
}
|
||||||
ret.push_back(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -381,13 +380,16 @@ std::vector<double> smooth_height_profile(const std::vector<double>& profile, co
|
||||||
std::vector<double> heights;
|
std::vector<double> heights;
|
||||||
size_t heights_size = ret.size() / 2;
|
size_t heights_size = ret.size() / 2;
|
||||||
heights.reserve(heights_size);
|
heights.reserve(heights_size);
|
||||||
|
// extract heights from profile
|
||||||
for (size_t i = 0; i < heights_size; ++i)
|
for (size_t i = 0; i < heights_size; ++i)
|
||||||
{
|
{
|
||||||
heights.push_back(ret[i * 2 + 1]);
|
heights.push_back(ret[i * 2 + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// smooth heights
|
||||||
heights = gauss_blur(heights, std::max(radius, (unsigned int)1));
|
heights = gauss_blur(heights, std::max(radius, (unsigned int)1));
|
||||||
|
|
||||||
|
// put smoothed heights back into profile
|
||||||
for (size_t i = 0; i < heights_size; ++i)
|
for (size_t i = 0; i < heights_size; ++i)
|
||||||
{
|
{
|
||||||
ret[i * 2 + 1] = clamp(slicing_params.min_layer_height, slicing_params.max_layer_height, heights[i]);
|
ret[i * 2 + 1] = clamp(slicing_params.min_layer_height, slicing_params.max_layer_height, heights[i]);
|
||||||
|
|
|
@ -287,6 +287,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
|
||||||
|
|
||||||
#if ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE_SMOOTHING
|
#if ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE_SMOOTHING
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
imgui.disabled_begin(m_layer_height_profile.size() < 10);
|
||||||
if (imgui.button(_(L("Smooth"))))
|
if (imgui.button(_(L("Smooth"))))
|
||||||
wxPostEvent((wxEvtHandler*)canvas.get_wxglcanvas(), Event<unsigned int>(EVT_GLCANVAS_SMOOTH_LAYER_HEIGHT_PROFILE, m_smooth_radius));
|
wxPostEvent((wxEvtHandler*)canvas.get_wxglcanvas(), Event<unsigned int>(EVT_GLCANVAS_SMOOTH_LAYER_HEIGHT_PROFILE, m_smooth_radius));
|
||||||
|
|
||||||
|
@ -299,6 +300,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
|
||||||
int radius = (int)m_smooth_radius;
|
int radius = (int)m_smooth_radius;
|
||||||
if (ImGui::SliderInt("##1", &radius, 1, 10))
|
if (ImGui::SliderInt("##1", &radius, 1, 10))
|
||||||
m_smooth_radius = (unsigned int)radius;
|
m_smooth_radius = (unsigned int)radius;
|
||||||
|
imgui.disabled_end();
|
||||||
#endif // ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE_SMOOTHING
|
#endif // ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE_SMOOTHING
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue