Add more built-in models: Disc/Torus/Bunny

This commit is contained in:
SoftFever 2023-12-20 17:53:12 +08:00
parent 604851fc9c
commit 69602d24fc
7 changed files with 51 additions and 27 deletions

View file

@ -2084,23 +2084,27 @@ static TriangleMesh create_mesh(const std::string& type_name, const BoundingBoxf
{
const double side = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.1);
indexed_triangle_set mesh;
TriangleMesh mesh;
if (type_name == "Cube")
// Sitting on the print bed, left front front corner at (0, 0).
mesh = its_make_cube(side, side, side);
mesh = TriangleMesh(its_make_cube(side, side, side));
else if (type_name == "Cylinder")
// Centered around 0, sitting on the print bed.
// The cylinder has the same volume as the box above.
mesh = its_make_cylinder(0.5 * side, side);
mesh = TriangleMesh(its_make_cylinder(0.5 * side, side));
else if (type_name == "Sphere")
// Centered around 0, half the sphere below the print bed, half above.
// The sphere has the same volume as the box above.
mesh = its_make_sphere(0.5 * side, PI / 18);
mesh = TriangleMesh(its_make_sphere(0.5 * side, PI / 18));
else if (type_name == "Slab")
// Sitting on the print bed, left front front corner at (0, 0).
mesh = its_make_cube(bb.size().x() * 1.5, bb.size().y() * 1.5, bb.size().z() * 0.5);
mesh = TriangleMesh(its_make_cube(bb.size().x() * 1.5, bb.size().y() * 1.5, bb.size().z() * 0.5));
else if (type_name == "Cone")
mesh = its_make_cone(0.5 * side, side);
mesh = TriangleMesh(its_make_cone(0.5 * side, side));
else if (type_name == "Disc")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/handy_models/helper_disk.stl").c_str(), true, nullptr);
else if (type_name == "Torus")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/handy_models/torus.stl").c_str(), true, nullptr);
return TriangleMesh(mesh);
}