mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Trying to engage support creation when the gizmo gets disabled.
This commit is contained in:
parent
a49b506121
commit
22c9c5ae95
11 changed files with 76 additions and 33 deletions
|
@ -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})
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -64,11 +64,6 @@ struct Contour3D {
|
|||
}
|
||||
};
|
||||
|
||||
struct EigenMesh3D {
|
||||
Eigen::MatrixXd V;
|
||||
Eigen::MatrixXi F;
|
||||
};
|
||||
|
||||
using PointSet = Eigen::MatrixXd;
|
||||
using ClusterEl = std::vector<unsigned>;
|
||||
using ClusteredPoints = std::vector<ClusterEl>;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <libnest2d/optimizers/nlopt/genetic.hpp>
|
||||
#include "SLABoilerPlate.hpp"
|
||||
#include "SLARotfinder.hpp"
|
||||
#include "SLASupportTree.hpp"
|
||||
#include "Model.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -63,6 +63,13 @@ struct Controller {
|
|||
std::function<bool(void)> 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 {
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <igl/unproject_onto_mesh.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <SLA/SLASupportTree.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue