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(); ExPolygons ground_slice; TriangleMesh basepool; sla::base_plate(model, ground_slice, 0.1f); bench.start(); 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"); return EXIT_SUCCESS; }
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(); ExPolygons ground_slice; 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(); 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.contour, top_plate.contour, 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"); std::fstream outstream("out.obj", std::fstream::out); mesh.to_obj(outstream); return EXIT_SUCCESS; }
bool STL::read_file(std::string input_file, Model* model) { // TODO: encode file name // TODO: check that file exists TriangleMesh mesh; mesh.ReadSTLFile(input_file); mesh.repair(); if (mesh.facets_count() == 0) throw std::runtime_error("This STL file couldn't be read because it's empty."); ModelObject* object = model->add_object(); object->name = input_file; // TODO: use basename() object->input_file = input_file; ModelVolume* volume = object->add_volume(mesh); volume->name = input_file; // TODO: use basename() return true; }