2018-08-16 15:47:05 +00:00
|
|
|
#include <iostream>
|
2019-02-13 15:44:48 +00:00
|
|
|
#include <fstream>
|
2018-08-16 15:47:05 +00:00
|
|
|
#include <string>
|
|
|
|
|
2018-12-11 14:54:54 +00:00
|
|
|
#include <libslic3r/libslic3r.h>
|
|
|
|
#include <libslic3r/TriangleMesh.hpp>
|
2019-05-07 11:06:15 +00:00
|
|
|
#include <libslic3r/Tesselate.hpp>
|
2018-12-11 14:54:54 +00:00
|
|
|
#include <libslic3r/SLA/SLABasePool.hpp>
|
2019-02-13 15:44:48 +00:00
|
|
|
#include <libslic3r/SLA/SLABoilerPlate.hpp>
|
2018-12-11 14:54:54 +00:00
|
|
|
#include <libnest2d/tools/benchmark.h>
|
2018-08-16 15:47:05 +00:00
|
|
|
|
|
|
|
const std::string USAGE_STR = {
|
|
|
|
"Usage: slabasebed stlfilename.stl"
|
|
|
|
};
|
|
|
|
|
2019-02-13 15:44:48 +00:00
|
|
|
namespace Slic3r { namespace sla {
|
|
|
|
|
2019-06-11 10:40:07 +00:00
|
|
|
Contour3D create_base_pool(const Polygons &ground_layer,
|
|
|
|
const Polygons &holes = {},
|
2019-05-07 11:06:15 +00:00
|
|
|
const PoolConfig& cfg = PoolConfig());
|
|
|
|
|
2019-02-13 17:21:27 +00:00
|
|
|
Contour3D walls(const Polygon& floor_plate, const Polygon& ceiling,
|
2019-02-13 15:44:48 +00:00
|
|
|
double floor_z_mm, double ceiling_z_mm,
|
2019-02-13 17:21:27 +00:00
|
|
|
double offset_difference_mm, ThrowOnCancel thr);
|
2019-02-13 15:44:48 +00:00
|
|
|
|
|
|
|
void offset(ExPolygon& sh, coord_t distance);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-16 15:47:05 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
TriangleMesh model;
|
|
|
|
Benchmark bench;
|
|
|
|
|
|
|
|
model.ReadSTLFile(argv[1]);
|
|
|
|
model.align_to_origin();
|
|
|
|
|
2019-06-11 10:40:07 +00:00
|
|
|
Polygons ground_slice;
|
2018-12-11 14:54:54 +00:00
|
|
|
sla::base_plate(model, ground_slice, 0.1f);
|
2019-02-13 15:44:48 +00:00
|
|
|
if(ground_slice.empty()) return EXIT_FAILURE;
|
|
|
|
|
2019-06-11 10:40:07 +00:00
|
|
|
Polygon gndfirst; gndfirst = ground_slice.front();
|
|
|
|
sla::offset_with_breakstick_holes(gndfirst, 0.5, 10, 0.3);
|
|
|
|
|
|
|
|
sla::Contour3D mesh;
|
|
|
|
|
2019-02-13 15:44:48 +00:00
|
|
|
|
2018-08-16 15:47:05 +00:00
|
|
|
bench.start();
|
2019-02-13 15:44:48 +00:00
|
|
|
|
2019-05-07 11:06:15 +00:00
|
|
|
sla::PoolConfig cfg;
|
|
|
|
cfg.min_wall_height_mm = 0;
|
2019-06-11 10:40:07 +00:00
|
|
|
cfg.edge_radius_mm = 0;
|
|
|
|
mesh = sla::create_base_pool(ground_slice, {}, cfg);
|
|
|
|
|
2018-08-16 15:47:05 +00:00
|
|
|
bench.stop();
|
|
|
|
|
|
|
|
cout << "Base pool creation time: " << std::setprecision(10)
|
|
|
|
<< bench.getElapsedSec() << " seconds." << endl;
|
2019-06-11 10:40:07 +00:00
|
|
|
|
2019-05-07 11:06:15 +00:00
|
|
|
for(auto& trind : mesh.indices) {
|
|
|
|
Vec3d p0 = mesh.points[size_t(trind[0])];
|
|
|
|
Vec3d p1 = mesh.points[size_t(trind[1])];
|
|
|
|
Vec3d p2 = mesh.points[size_t(trind[2])];
|
|
|
|
Vec3d p01 = p1 - p0;
|
|
|
|
Vec3d p02 = p2 - p0;
|
|
|
|
auto a = p01.cross(p02).norm() / 2.0;
|
|
|
|
if(std::abs(a) < 1e-6) std::cout << "degenerate triangle" << std::endl;
|
|
|
|
}
|
2018-08-16 15:47:05 +00:00
|
|
|
|
2019-02-13 15:44:48 +00:00
|
|
|
// basepool.write_ascii("out.stl");
|
|
|
|
|
|
|
|
std::fstream outstream("out.obj", std::fstream::out);
|
|
|
|
mesh.to_obj(outstream);
|
2018-08-16 15:47:05 +00:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|