diff --git a/sandboxes/CMakeLists.txt b/sandboxes/CMakeLists.txt index 5905c438e..0e1f52d6c 100644 --- a/sandboxes/CMakeLists.txt +++ b/sandboxes/CMakeLists.txt @@ -1,2 +1 @@ add_subdirectory(slabasebed) -add_subdirectory(slasupporttree) diff --git a/sandboxes/slasupporttree/CMakeLists.txt b/sandboxes/slasupporttree/CMakeLists.txt deleted file mode 100644 index a3323a83d..000000000 --- a/sandboxes/slasupporttree/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(slasupporttree EXCLUDE_FROM_ALL slasupporttree.cpp) -target_link_libraries(slasupporttree libslic3r) \ No newline at end of file diff --git a/sandboxes/slasupporttree/slasupporttree.cpp b/sandboxes/slasupporttree/slasupporttree.cpp deleted file mode 100644 index 0cfc60f7a..000000000 --- a/sandboxes/slasupporttree/slasupporttree.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include - -#include -#include "TriangleMesh.hpp" -#include "Model.hpp" -#include "callback.hpp" -#include "SLA/SLASupportTree.hpp" -#include "benchmark.h" - -const std::string USAGE_STR = { - "Usage: slasupporttree stlfilename.stl" -}; - -void confess_at(const char * /*file*/, - int /*line*/, - const char * /*func*/, - const char * /*pat*/, - ...) {} - -namespace Slic3r { - -void PerlCallback::deregister_callback() {} -} - -int main(const int argc, const char *argv[]) { - using namespace Slic3r; - using std::cout; using std::endl; - - if(argc < 2) { - cout << USAGE_STR << endl; - return EXIT_SUCCESS; - } - - Benchmark bench; - TriangleMesh result; - - bench.start(); - sla::create_head(result, 3, 1, 4); - bench.stop(); - - cout << "Support tree creation time: " << std::setprecision(10) - << bench.getElapsedSec() << " seconds." << endl; - - result.write_ascii("out.stl"); - - return EXIT_SUCCESS; -} diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index cd2f491c6..029c45069 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -541,20 +541,6 @@ EigenMesh3D to_eigenmesh(const Contour3D& cntr) { return emesh; } -void create_head(TriangleMesh& out, double r1_mm, double r2_mm, double width_mm) -{ - Head head(r1_mm, r2_mm, width_mm, 0, - {0, std::sqrt(0.5), -std::sqrt(0.5)}, - {0, 0, 30}); - out.merge(mesh(head.mesh)); - - Pillar cst(head, {0, 0, 0}); - cst.add_base(); - - out.merge(mesh(cst.mesh)); - out.merge(mesh(cst.base)); -} - // The minimum distance for two support points to remain valid. static const double /*constexpr*/ D_SP = 0.1; @@ -597,21 +583,6 @@ EigenMesh3D to_eigenmesh(const ModelObject& modelobj) { return to_eigenmesh(modelobj.raw_mesh()); } -EigenMesh3D to_eigenmesh(const Model& model) { - TriangleMesh combined_mesh; - - for(ModelObject *o : model.objects) { - TriangleMesh tmp = o->raw_mesh(); - for(ModelInstance * inst: o->instances) { - TriangleMesh ttmp(tmp); - inst->transform_mesh(&ttmp); - combined_mesh.merge(ttmp); - } - } - - return to_eigenmesh(combined_mesh); -} - PointSet to_point_set(const std::vector &v) { PointSet ret(v.size(), 3); @@ -623,43 +594,6 @@ Vec3d model_coord(const ModelInstance& object, const Vec3f& mesh_coord) { return object.transform_vector(mesh_coord.cast()); } -PointSet support_points(const Model& model) { - size_t sum = 0; - for(auto *o : model.objects) - sum += o->instances.size() * o->sla_support_points.size(); - - PointSet ret(sum, 3); - - for(ModelObject *o : model.objects) - for(ModelInstance *inst : o->instances) { - int i = 0; - for(Vec3f& msource : o->sla_support_points) { - ret.row(i++) = model_coord(*inst, msource); - } - } - - return ret; -} - -PointSet support_points(const ModelObject& modelobject) -{ - PointSet ret(modelobject.sla_support_points.size(), 3); - auto rot = modelobject.instances.front()->get_rotation(); -// auto scaling = modelobject.instances.front()->get_scaling_factor(); - -// Transform3d tr; -// tr.rotate(Eigen::AngleAxisd(rot(X), Vec3d::UnitX()) * -// Eigen::AngleAxisd(rot(Y), Vec3d::UnitY())); - - long i = 0; - for(const Vec3f& msource : modelobject.sla_support_points) { - Vec3d&& p = msource.cast(); -// p = tr * p; - ret.row(i++) = p; - } - return ret; -} - double ray_mesh_intersect(const Vec3d& s, const Vec3d& dir, const EigenMesh3D& m); @@ -1744,14 +1678,6 @@ double SLASupportTree::get_elevation() const return m_elevation + ph; } -SLASupportTree::SLASupportTree(const Model& model, - const SupportConfig& cfg, - const Controller& ctl): - m_impl(new Impl()), m_ctl(ctl) -{ - generate(support_points(model), to_eigenmesh(model), cfg, ctl); -} - SLASupportTree::SLASupportTree(const PointSet &points, const EigenMesh3D& emesh, const SupportConfig &cfg, @@ -1774,66 +1700,5 @@ SLASupportTree &SLASupportTree::operator=(const SLASupportTree &c) SLASupportTree::~SLASupportTree() {} -void add_sla_supports(Model &model, - const SupportConfig &cfg, - const Controller &ctl) -{ - Benchmark bench; - - bench.start(); - SLASupportTree _stree(model, cfg, ctl); - bench.stop(); - - std::cout << "Support tree creation time: " << bench.getElapsedSec() - << " seconds" << std::endl; - - bench.start(); - ModelObject* o = model.add_object(); - o->add_instance(); - - TriangleMesh streemsh; - _stree.merged_mesh(streemsh); - o->add_volume(streemsh); - - bench.stop(); - std::cout << "support tree added to model in: " << bench.getElapsedSec() - << " seconds" << std::endl; - - // TODO this would roughly be the code for the base pool - ExPolygons plate; - auto modelmesh = model.mesh(); - TriangleMesh poolmesh; - sla::PoolConfig poolcfg; - poolcfg.min_wall_height_mm = 1; - poolcfg.edge_radius_mm = 0.1; - poolcfg.min_wall_thickness_mm = 0.8; - - bench.start(); - sla::base_plate(modelmesh, plate); - bench.stop(); - - std::cout << "Base plate calculation time: " << bench.getElapsedSec() - << " seconds." << std::endl; - - bench.start(); - sla::create_base_pool(plate, poolmesh, poolcfg); - bench.stop(); - - std::cout << "Pool generation completed in " << bench.getElapsedSec() - << " second." << std::endl; - - bench.start(); - poolmesh.translate(.0f, .0f, float(poolcfg.min_wall_height_mm / 2)); - o->add_volume(poolmesh); - bench.stop(); - - // TODO: will cause incorrect placement of the model; -// o->translate({0, 0, poolcfg.min_wall_height_mm / 2}); - - std::cout << "Added pool to model in " << bench.getElapsedSec() - << " seconds." << std::endl; - -} - } } diff --git a/src/libslic3r/SLA/SLASupportTree.hpp b/src/libslic3r/SLA/SLASupportTree.hpp index c2f7e6f21..cf61f07b0 100644 --- a/src/libslic3r/SLA/SLASupportTree.hpp +++ b/src/libslic3r/SLA/SLASupportTree.hpp @@ -90,34 +90,17 @@ struct EigenMesh3D { Eigen::MatrixXd V; Eigen::MatrixXi F; double ground_level = 0; - - // igl crashes with the following data types: -// Eigen::Matrix V; -// Eigen::Matrix F; }; -//using PointSet = Eigen::Matrix; //Eigen::MatrixXd; using PointSet = Eigen::MatrixXd; -/* ************************************************************************** */ -/* TODO: May not be needed: */ -/* ************************************************************************** */ - -void create_head(TriangleMesh&, double r1_mm, double r2_mm, double width_mm); - -/// Add support volumes to the model directly -void add_sla_supports(Model& model, const SupportConfig& cfg = {}, - const Controller& ctl = {}); - EigenMesh3D to_eigenmesh(const TriangleMesh& m); -PointSet to_point_set(const std::vector&); - -// obsolete, not used anymore -EigenMesh3D to_eigenmesh(const Model& model); +// needed for find best rotation EigenMesh3D to_eigenmesh(const ModelObject& model); -PointSet support_points(const ModelObject& modelobject); -PointSet support_points(const Model& model); + +// Simple conversion of 'vector of points' to an Eigen matrix +PointSet to_point_set(const std::vector&); /* ************************************************************************** */ @@ -134,6 +117,8 @@ class SLASupportTree { class Impl; std::unique_ptr m_impl; Controller m_ctl; + + // the only value from config that is also needed after construction double m_elevation = 0; Impl& get() { return *m_impl; } @@ -150,11 +135,6 @@ class SLASupportTree { const Controller& ctl = {}); public: - // Constructors will throw if the stop condition becomes true. - SLASupportTree(const Model& model, - const SupportConfig& cfg = {}, - const Controller& ctl = {}); - SLASupportTree(const PointSet& pts, const EigenMesh3D& em, const SupportConfig& cfg = {},