diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e1b6331e7..4ee47913f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,6 +137,7 @@ if(SLIC3R_STATIC) # set(Boost_USE_STATIC_RUNTIME ON) endif() #set(Boost_DEBUG ON) +set(Boost_COMPILER "-vc120") find_package(Boost REQUIRED COMPONENTS system filesystem thread log locale regex) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) diff --git a/src/libnest2d/CMakeLists.txt b/src/libnest2d/CMakeLists.txt index cabc9bdfaa..163143bcbf 100644 --- a/src/libnest2d/CMakeLists.txt +++ b/src/libnest2d/CMakeLists.txt @@ -88,7 +88,7 @@ endif() add_subdirectory(${SRC_DIR}/libnest2d/backends/${LIBNEST2D_GEOMETRIES}) add_subdirectory(${SRC_DIR}/libnest2d/optimizers/${LIBNEST2D_OPTIMIZER}) -target_sources(libnest2d INTERFACE ${LIBNEST2D_SRCFILES}) +#target_sources(libnest2d INTERFACE ${LIBNEST2D_SRCFILES}) target_include_directories(libnest2d INTERFACE ${SRC_DIR}) if(NOT LIBNEST2D_HEADER_ONLY) diff --git a/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt b/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt index 995afcc76d..aa53f957e5 100644 --- a/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt +++ b/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt @@ -62,9 +62,9 @@ if(NOT Boost_INCLUDE_DIRS_FOUND) endif() target_include_directories(ClipperBackend INTERFACE ${Boost_INCLUDE_DIRS} ) -target_sources(ClipperBackend INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/geometries.hpp - ${SRC_DIR}/libnest2d/utils/boost_alg.hpp ) +#target_sources(ClipperBackend INTERFACE +# ${CMAKE_CURRENT_SOURCE_DIR}/geometries.hpp +# ${SRC_DIR}/libnest2d/utils/boost_alg.hpp ) target_compile_definitions(ClipperBackend INTERFACE LIBNEST2D_BACKEND_CLIPPER) diff --git a/src/libnest2d/include/libnest2d/optimizers/nlopt/CMakeLists.txt b/src/libnest2d/include/libnest2d/optimizers/nlopt/CMakeLists.txt index 5559ad6453..2a32019f42 100644 --- a/src/libnest2d/include/libnest2d/optimizers/nlopt/CMakeLists.txt +++ b/src/libnest2d/include/libnest2d/optimizers/nlopt/CMakeLists.txt @@ -48,12 +48,12 @@ else() target_link_libraries(NloptOptimizer INTERFACE Nlopt::Nlopt) endif() -target_sources( NloptOptimizer INTERFACE -${CMAKE_CURRENT_SOURCE_DIR}/simplex.hpp -${CMAKE_CURRENT_SOURCE_DIR}/subplex.hpp -${CMAKE_CURRENT_SOURCE_DIR}/genetic.hpp -${CMAKE_CURRENT_SOURCE_DIR}/nlopt_boilerplate.hpp -) +#target_sources( NloptOptimizer INTERFACE +#${CMAKE_CURRENT_SOURCE_DIR}/simplex.hpp +#${CMAKE_CURRENT_SOURCE_DIR}/subplex.hpp +#${CMAKE_CURRENT_SOURCE_DIR}/genetic.hpp +#${CMAKE_CURRENT_SOURCE_DIR}/nlopt_boilerplate.hpp +#) target_compile_definitions(NloptOptimizer INTERFACE LIBNEST2D_OPTIMIZER_NLOPT) diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index ab60987088..be31734df9 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -172,15 +172,15 @@ target_include_directories(libslic3r PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${LIBNES target_link_libraries(libslic3r libnest2d admesh - miniz + miniz ${Boost_LIBRARIES} - clipper + clipper nowide - ${EXPAT_LIBRARIES} - ${GLEW_LIBRARIES} + ${EXPAT_LIBRARIES} + ${GLEW_LIBRARIES} ${PNG_LIBRARIES} - polypartition - poly2tri + polypartition + poly2tri qhull semver tbb diff --git a/src/libslic3r/SLA/SLABoilerPlate.hpp b/src/libslic3r/SLA/SLABoilerPlate.hpp index c15137ac53..e94eaf2c21 100644 --- a/src/libslic3r/SLA/SLABoilerPlate.hpp +++ b/src/libslic3r/SLA/SLABoilerPlate.hpp @@ -64,11 +64,6 @@ struct Contour3D { } }; -struct EigenMesh3D { - Eigen::MatrixXd V; - Eigen::MatrixXi F; -}; - using PointSet = Eigen::MatrixXd; using ClusterEl = std::vector; using ClusteredPoints = std::vector; diff --git a/src/libslic3r/SLA/SLARotfinder.cpp b/src/libslic3r/SLA/SLARotfinder.cpp index f2dab05ac5..1ecd74e0e3 100644 --- a/src/libslic3r/SLA/SLARotfinder.cpp +++ b/src/libslic3r/SLA/SLARotfinder.cpp @@ -4,6 +4,7 @@ #include #include "SLABoilerPlate.hpp" #include "SLARotfinder.hpp" +#include "SLASupportTree.hpp" #include "Model.hpp" namespace Slic3r { diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 0be3e76808..34821f7ae2 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -1209,6 +1209,7 @@ bool SLASupportTree::generate(const PointSet &points, (SpatIndex& spindex, const Vec3d& jsh) { long nearest_id = -1; + const double max_len = maxbridgelen / 2; while(nearest_id < 0 && !spindex.empty()) { // loop until a suitable head is not found // if there is a pillar closer than the cluster center @@ -1227,16 +1228,14 @@ bool SLASupportTree::generate(const PointSet &points, Vec3d jn(jh(X), jh(Y), jp(Z) + dist2d*std::tan(-cfg.tilt)); if(jn(Z) > jh(Z)) { - // if the main head is below the point where the bridge - // would connect, than we must adjust the bridge - // endpoints - double hdiff = jn(Z) - jh(Z); - jp(Z) -= hdiff; - jn(Z) -= hdiff; + // If the sidepoint cannot connect to the pillar from + // its head junction, then just skip this pillar. + spindex.remove(ne); + continue; } double d = distance(jp, jn); - if(jn(Z) <= 0 || d > maxbridgelen) break; + if(jn(Z) <= 0 || d > max_len) break; double chkd = ray_mesh_intersect(jp, dirv(jp, jn), emesh); if(chkd >= d) nearest_id = ne.second; diff --git a/src/libslic3r/SLA/SLASupportTree.hpp b/src/libslic3r/SLA/SLASupportTree.hpp index d6e7afca5f..fe611a2ee7 100644 --- a/src/libslic3r/SLA/SLASupportTree.hpp +++ b/src/libslic3r/SLA/SLASupportTree.hpp @@ -63,6 +63,13 @@ struct Controller { std::function stopcondition = [](){ return false; }; }; +struct EigenMesh3D { + Eigen::MatrixXd V; + Eigen::MatrixXi F; +}; + +using PointSet = Eigen::MatrixXd; + /* ************************************************************************** */ /* TODO: May not be needed: */ /* ************************************************************************** */ @@ -73,10 +80,10 @@ void create_head(TriangleMesh&, double r1_mm, double r2_mm, double width_mm); void add_sla_supports(Model& model, const SupportConfig& cfg = {}, const Controller& ctl = {}); -/* ************************************************************************** */ +EigenMesh3D to_eigenmesh(const Model& model); +PointSet support_points(const Model& model); -using PointSet = Eigen::MatrixXd; -struct EigenMesh3D; +/* ************************************************************************** */ /// Just a wrapper to the runtime error to be recognizable in try blocks class SLASupportsStoppedException: public std::runtime_error { diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index 0420d9bf51..b793f96263 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include @@ -1599,6 +1601,29 @@ void GLGizmoSlaSupports::update_mesh() } } +void GLGizmoSlaSupports::on_deactivate() { + if(!m_model_object) return; + + sla::Controller supportctl; + std::cout << "Generating supports:" << std::endl; + + // TODO: somehow get the global status indicator + supportctl.statuscb = [] (unsigned st, const std::string& msg) { + std::cout << st << "% " << msg << std::endl; + }; + + const Model& model = *m_model_object->get_model(); + auto emesh = sla::to_eigenmesh(model); + sla::PointSet input = sla::support_points(model); + sla::SupportConfig cfg; + + sla::SLASupportTree stree(input, emesh, cfg, supportctl); + + TriangleMesh output; + stree.merged_mesh(output); + m_model_object->add_volume(output); +} + Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos) { // if the gizmo doesn't have the V, F structures for igl, calculate them first: diff --git a/src/slic3r/GUI/GLGizmo.hpp b/src/slic3r/GUI/GLGizmo.hpp index ea6e3ae6b3..a2cf05ee32 100644 --- a/src/slic3r/GUI/GLGizmo.hpp +++ b/src/slic3r/GUI/GLGizmo.hpp @@ -78,7 +78,17 @@ public: void set_group_id(int id) { m_group_id = id; } EState get_state() const { return m_state; } - void set_state(EState state) { m_state = state; on_set_state(); } + void set_state(EState state) { + // FIXME: this is my workaround to react on the disabling event (Tamas) + bool call_deactivate = ((m_state == On || m_state == Hover) && + state == Off); + + m_state = state; on_set_state(); + + if(call_deactivate) { + on_deactivate(); + } + } bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); } @@ -110,6 +120,7 @@ protected: virtual bool on_init() = 0; virtual std::string on_get_name() const = 0; virtual void on_set_state() {} + virtual void on_deactivate() {} // FIXME: how to react to disabling the Gizmo? (Tamas) virtual void on_set_hover_id() {} virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; } virtual void on_enable_grabber(unsigned int id) {} @@ -415,9 +426,13 @@ private: protected: void on_set_state() override { - if (m_state == On && is_mesh_update_necessary()) + if (m_state == On && is_mesh_update_necessary()) { update_mesh(); + } } + + void on_deactivate() override; + std::string on_get_name() const override; };