diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2019-02-13 18:44:48 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2019-02-13 18:44:48 +0300 |
commit | 0d13ecdce80567378566b28b6fc48611370a569d (patch) | |
tree | b125f3655cb181693e305e466ec8c5b94b045649 /sandboxes | |
parent | 0b8faf57857a379a1413f476151af059c99c2a9b (diff) |
Working proof-of-concept for manual triangulation of pad walls.
Diffstat (limited to 'sandboxes')
-rw-r--r-- | sandboxes/slabasebed/CMakeLists.txt | 5 | ||||
-rw-r--r-- | sandboxes/slabasebed/slabasebed.cpp | 45 |
2 files changed, 45 insertions, 5 deletions
diff --git a/sandboxes/slabasebed/CMakeLists.txt b/sandboxes/slabasebed/CMakeLists.txt index bff5ca588..6efbda35f 100644 --- a/sandboxes/slabasebed/CMakeLists.txt +++ b/sandboxes/slabasebed/CMakeLists.txt @@ -1,2 +1,3 @@ -add_executable(slabasebed EXCLUDE_FROM_ALL slabasebed.cpp) -target_link_libraries(slabasebed libslic3r)
\ No newline at end of file +add_executable(slabasebed #EXCLUDE_FROM_ALL + slabasebed.cpp) +target_link_libraries(slabasebed libslic3r ${Boost_LIBRARIES} ${TBB_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/sandboxes/slabasebed/slabasebed.cpp b/sandboxes/slabasebed/slabasebed.cpp index 9804ea3c9..569af4faa 100644 --- a/sandboxes/slabasebed/slabasebed.cpp +++ b/sandboxes/slabasebed/slabasebed.cpp @@ -1,15 +1,29 @@ #include <iostream> +#include <fstream> #include <string> #include <libslic3r/libslic3r.h> #include <libslic3r/TriangleMesh.hpp> #include <libslic3r/SLA/SLABasePool.hpp> +#include <libslic3r/SLA/SLABoilerPlate.hpp> #include <libnest2d/tools/benchmark.h> const std::string USAGE_STR = { "Usage: slabasebed stlfilename.stl" }; +namespace Slic3r { namespace sla { + +Contour3D convert(const Polygons& triangles, coord_t z, bool dir); +Contour3D walls(const ExPolygon& floor_plate, const ExPolygon& ceiling, + double floor_z_mm, double ceiling_z_mm, + ThrowOnCancel thr, double offset_difference_mm = 0.0); + +void offset(ExPolygon& sh, coord_t distance); + +} +} + int main(const int argc, const char *argv[]) { using namespace Slic3r; using std::cout; using std::endl; @@ -26,18 +40,43 @@ int main(const int argc, const char *argv[]) { model.align_to_origin(); ExPolygons ground_slice; - TriangleMesh basepool; + sla::Contour3D mesh; +// TriangleMesh basepool; sla::base_plate(model, ground_slice, 0.1f); + if(ground_slice.empty()) return EXIT_FAILURE; + + ExPolygon bottom_plate = ground_slice.front(); + ExPolygon top_plate = bottom_plate; + sla::offset(top_plate, coord_t(3.0/SCALING_FACTOR)); + sla::offset(bottom_plate, coord_t(1.0/SCALING_FACTOR)); + bench.start(); - sla::create_base_pool(ground_slice, basepool); + + Polygons top_plate_triangles, bottom_plate_triangles; + top_plate.triangulate_p2t(&top_plate_triangles); + bottom_plate.triangulate_p2t(&bottom_plate_triangles); + + auto top_plate_mesh = sla::convert(top_plate_triangles, coord_t(3.0/SCALING_FACTOR), false); + auto bottom_plate_mesh = sla::convert(bottom_plate_triangles, 0, true); + + mesh.merge(bottom_plate_mesh); + mesh.merge(top_plate_mesh); + + sla::Contour3D w = sla::walls(bottom_plate, top_plate, 0, 3, [](){}, 2.0); + + mesh.merge(w); +// sla::create_base_pool(ground_slice, basepool); bench.stop(); cout << "Base pool creation time: " << std::setprecision(10) << bench.getElapsedSec() << " seconds." << endl; - basepool.write_ascii("out.stl"); +// basepool.write_ascii("out.stl"); + + std::fstream outstream("out.obj", std::fstream::out); + mesh.to_obj(outstream); return EXIT_SUCCESS; } |