Merge branch 'tm_openvdb_integration' into lm_tm_hollowing

This commit is contained in:
tamasmeszaros 2019-11-11 16:19:03 +01:00
commit 98e2327a9f
4 changed files with 70 additions and 31 deletions

View File

@ -216,10 +216,6 @@ add_library(libslic3r STATIC
encoding_check(libslic3r) encoding_check(libslic3r)
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE)
endif ()
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB -DTBB_USE_CAPTURED_EXCEPTION=0) target_compile_definitions(libslic3r PUBLIC -DUSE_TBB -DTBB_USE_CAPTURED_EXCEPTION=0)
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(libslic3r target_link_libraries(libslic3r
@ -252,3 +248,7 @@ endif()
if(SLIC3R_PROFILE) if(SLIC3R_PROFILE)
target_link_libraries(slic3r Shiny) target_link_libraries(slic3r Shiny)
endif() endif()
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE)
endif ()

View File

@ -571,13 +571,7 @@ std::pair<const TriangleMesh *, sla::HollowingConfig> GLGizmoHollow::get_hollowi
return std::make_pair(m_mesh, sla::HollowingConfig{double(m_offset), double(m_accuracy), double(m_closing_d)}); return std::make_pair(m_mesh, sla::HollowingConfig{double(m_offset), double(m_accuracy), double(m_closing_d)});
} }
void GLGizmoHollow::hollow_mesh() void GLGizmoHollow::set_hollowing_result(std::unique_ptr<TriangleMesh> mesh)
{
// Trigger a UI job to hollow the mesh.
wxGetApp().plater()->hollow();
}
void GLGizmoHollow::update_hollowed_mesh(std::unique_ptr<TriangleMesh> mesh)
{ {
// Called from Plater when the UI job finishes // Called from Plater when the UI job finishes
m_cavity_mesh = std::move(mesh); m_cavity_mesh = std::move(mesh);
@ -591,10 +585,21 @@ void GLGizmoHollow::update_hollowed_mesh(std::unique_ptr<TriangleMesh> mesh)
volume_trafo.set_offset(volume_trafo.get_offset() + Vec3d(0., 0., m_z_shift)); volume_trafo.set_offset(volume_trafo.get_offset() + Vec3d(0., 0., m_z_shift));
m_volume_with_cavity.reset(new GLVolume(1.f, 0.f, 0.f, 0.5f)); m_volume_with_cavity.reset(new GLVolume(1.f, 0.f, 0.f, 0.5f));
m_volume_with_cavity->indexed_vertex_array.load_mesh(*m_cavity_mesh.get()); m_volume_with_cavity->indexed_vertex_array.load_mesh(*m_cavity_mesh.get());
m_volume_with_cavity->finalize_geometry(true);
m_volume_with_cavity->set_volume_transformation(volume_trafo); m_volume_with_cavity->set_volume_transformation(volume_trafo);
m_volume_with_cavity->set_instance_transformation(m_model_object->instances[m_active_instance]->get_transformation()); m_volume_with_cavity->set_instance_transformation(m_model_object->instances[size_t(m_active_instance)]->get_transformation());
} }
}
void GLGizmoHollow::hollow_mesh()
{
// Trigger a UI job to hollow the mesh.
wxGetApp().plater()->hollow();
}
void GLGizmoHollow::update_hollowed_mesh()
{
if (m_volume_with_cavity) m_volume_with_cavity->finalize_geometry(true);
m_parent.toggle_model_objects_visibility(! m_cavity_mesh, m_model_object, m_active_instance); m_parent.toggle_model_objects_visibility(! m_cavity_mesh, m_model_object, m_active_instance);
} }

View File

@ -76,8 +76,11 @@ public:
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
void delete_selected_points(bool force = false); void delete_selected_points(bool force = false);
ClippingPlane get_sla_clipping_plane() const; ClippingPlane get_sla_clipping_plane() const;
void update_hollowed_mesh(std::unique_ptr<TriangleMesh> mesh);
std::pair<const TriangleMesh *, sla::HollowingConfig> get_hollowing_parameters() const; std::pair<const TriangleMesh *, sla::HollowingConfig> get_hollowing_parameters() const;
void set_hollowing_result(std::unique_ptr<TriangleMesh> mesh);
void update_hollowed_mesh();
bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); }

View File

@ -1714,6 +1714,9 @@ struct Plater::priv
void process() override; void process() override;
void finalize() override; void finalize() override;
private: private:
GLGizmoHollow * get_gizmo();
const GLGizmoHollow * get_gizmo() const;
std::unique_ptr<TriangleMesh> m_output; std::unique_ptr<TriangleMesh> m_output;
const TriangleMesh* m_object_mesh = nullptr; const TriangleMesh* m_object_mesh = nullptr;
sla::HollowingConfig m_cfg; sla::HollowingConfig m_cfg;
@ -2873,22 +2876,50 @@ void Plater::priv::HollowJob::prepare()
void Plater::priv::HollowJob::process() void Plater::priv::HollowJob::process()
{ {
sla::JobController ctl; sla::JobController ctl;
ctl.stopcondition = [this]{ return was_canceled(); };
ctl.statuscb = [this](unsigned st, const std::string &s) {
if (st < 100) update_status(int(st), s);
};
TriangleMesh omesh = sla::generate_interior(*m_object_mesh, m_cfg, ctl); TriangleMesh omesh = sla::generate_interior(*m_object_mesh, m_cfg, ctl);
if (omesh.empty()) return; if (!omesh.empty()) {
m_output.reset(new TriangleMesh{*m_object_mesh});
m_output->merge(omesh);
m_output->require_shared_vertices();
m_output.reset(new TriangleMesh{*m_object_mesh}); update_status(90, "Rendering hollowed object");
m_output->merge(omesh);
m_output->require_shared_vertices(); auto gizmo = get_gizmo();
if (gizmo) gizmo->set_hollowing_result(std::move(m_output));
update_status(100, was_canceled() ? _(L("Hollowing cancelled.")) :
_(L("Hollowing done.")));
} else {
update_status(100, _(L("Hollowing failed.")));
}
} }
void Plater::priv::HollowJob::finalize() void Plater::priv::HollowJob::finalize()
{
auto gizmo = get_gizmo();
if (gizmo) gizmo->update_hollowed_mesh();
}
GLGizmoHollow *Plater::priv::HollowJob::get_gizmo()
{ {
const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager(); const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager();
GLGizmoHollow* gizmo_hollow = dynamic_cast<GLGizmoHollow*>(gizmo_manager.get_current()); auto ret = dynamic_cast<GLGizmoHollow*>(gizmo_manager.get_current());
assert(gizmo_hollow); assert(ret);
gizmo_hollow->update_hollowed_mesh(std::move(m_output)); return ret;
}
const GLGizmoHollow *Plater::priv::HollowJob::get_gizmo() const
{
const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager();
auto ret = dynamic_cast<const GLGizmoHollow*>(gizmo_manager.get_current());
assert(ret);
return ret;
} }
void Plater::priv::split_object() void Plater::priv::split_object()