Hollowed interior is now visible in preview

This commit is contained in:
tamasmeszaros 2019-11-06 14:25:03 +01:00
parent bdf6f7342e
commit a82f1268f3
5 changed files with 15 additions and 17 deletions

View file

@ -1975,6 +1975,14 @@ const TriangleMesh& SLAPrintObject::pad_mesh() const
return EMPTY_MESH;
}
const TriangleMesh &SLAPrintObject::hollowed_interior_mesh() const
{
if (m_hollowing_data && m_config.hollowing_enable.getBool())
return m_hollowing_data->interior;
return EMPTY_MESH;
}
const TriangleMesh &SLAPrintObject::transformed_mesh() const {
// we need to transform the raw mesh...
// currently all the instances share the same x and y rotation and scaling

View file

@ -5362,6 +5362,8 @@ void GLCanvas3D::_load_sla_shells()
unsigned int initial_volumes_count = (unsigned int)m_volumes.volumes.size();
for (const SLAPrintObject::Instance& instance : obj->instances()) {
add_volume(*obj, 0, instance, obj->transformed_mesh(), GLVolume::MODEL_COLOR[0], true);
if (! obj->hollowed_interior_mesh().empty())
add_volume(*obj, -int(slaposHollowing), instance, obj->hollowed_interior_mesh(), GLVolume::MODEL_COLOR[0], false);
// Set the extruder_id and volume_id to achieve the same color as in the 3D scene when
// through the update_volumes_colors_by_extruder() call.
m_volumes.volumes.back()->extruder_id = obj->model_object()->volumes.front()->extruder_id();

View file

@ -595,17 +595,9 @@ void GLGizmoHollow::on_update(const UpdateData& data)
}
void GLGizmoHollow::hollow_mesh(float offset, float adaptibility)
void GLGizmoHollow::hollow_mesh(float offset)
{
// Slic3r::sla::Contour3D imesh{*m_mesh};
// auto ptr = meshToVolume(imesh, {});
// sla::Contour3D omesh = volumeToMesh(*ptr, -offset, adaptibility, true);
// if (omesh.empty())
// return;
// imesh.merge(omesh);
TriangleMesh cavity = hollowed_interior(*m_mesh, double(offset), int(adaptibility));
TriangleMesh cavity = hollowed_interior(*m_mesh, double(offset));
if (cavity.empty())
return;
@ -700,7 +692,7 @@ RENDER_AGAIN:
if (m_editing_mode) {
if (m_imgui->button(m_desc.at("hollow"))) {
hollow_mesh(m_offset, m_adaptibility);
hollow_mesh(m_offset);
}
float diameter_upper_cap = static_cast<ConfigOptionFloat*>(wxGetApp().preset_bundle->sla_prints.get_edited_preset().config.option("support_pillar_diameter"))->value;
@ -762,9 +754,6 @@ RENDER_AGAIN:
m_imgui->text("Offset: ");
ImGui::SameLine();
ImGui::SliderFloat(" ", &m_offset, 0.f, 10.f, "%.1f");
m_imgui->text("Adaptibility: ");
ImGui::SameLine();
ImGui::SliderFloat(" ", &m_adaptibility, 0.f, 1.f, "%.1f");
}
else { // not in editing mode:
m_imgui->text(m_desc.at("minimal_distance"));

View file

@ -92,7 +92,7 @@ private:
void render_clipping_plane(const Selection& selection) const;
bool is_mesh_update_necessary() const;
void update_mesh();
void hollow_mesh(float offset = 2.f, float adaptability = 1.f);
void hollow_mesh(float offset = 2.f);
bool unsaved_changes() const;
const TriangleMesh* mesh() const;
@ -109,7 +109,6 @@ private:
std::vector<sla::SupportPoint> m_normal_cache; // to restore after discarding changes or undo/redo
float m_offset = 2.f;
float m_adaptibility = 1.f;
float m_clipping_plane_distance = 0.f;
std::unique_ptr<ClippingPlane> m_clipping_plane;

View file

@ -49,7 +49,7 @@ static Slic3r::TriangleMesh load_model(const std::string &obj_filename)
TEST_CASE("Negative 3D offset should produce smaller object.", "[Hollowing]")
{
Slic3r::TriangleMesh in_mesh = load_model("zaba.obj");
Slic3r::TriangleMesh in_mesh = load_model("20mm_cube.obj");
Benchmark bench;
bench.start();