mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 14:20:58 +00:00
A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block.
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#include "../Model.hpp"
|
|
#include "../TriangleMesh.hpp"
|
|
|
|
#include "STL.hpp"
|
|
|
|
#include <cstring>
|
|
#include <string>
|
|
#include <utility>
|
|
#include "libslic3r/Format/STL.hpp"
|
|
|
|
#ifdef _WIN32
|
|
#define DIR_SEPARATOR '\\'
|
|
#else
|
|
#define DIR_SEPARATOR '/'
|
|
#endif
|
|
|
|
namespace Slic3r {
|
|
|
|
bool load_stl(const char *path, Model *model, const char *object_name_in, ImportstlProgressFn stlFn, int custom_header_length)
|
|
{
|
|
TriangleMesh mesh;
|
|
std::string design_id;
|
|
|
|
if (!mesh.ReadSTLFile(path, true, stlFn, custom_header_length)) {
|
|
// die "Failed to open $file\n" if !-e $path;
|
|
return false;
|
|
}
|
|
if (mesh.empty()) {
|
|
// die "This STL file couldn't be read because it's empty.\n"
|
|
return false;
|
|
}
|
|
|
|
std::string object_name;
|
|
if (object_name_in == nullptr) {
|
|
const char *last_slash = strrchr(path, DIR_SEPARATOR);
|
|
object_name.assign((last_slash == nullptr) ? path : last_slash + 1);
|
|
} else
|
|
object_name.assign(object_name_in);
|
|
|
|
model->add_object(object_name.c_str(), path, std::move(mesh));
|
|
return true;
|
|
}
|
|
|
|
bool store_stl(const char *path, TriangleMesh *mesh, bool binary)
|
|
{
|
|
if (binary)
|
|
mesh->write_binary(path);
|
|
else
|
|
mesh->write_ascii(path);
|
|
//FIXME returning false even if write failed.
|
|
return true;
|
|
}
|
|
|
|
bool store_stl(const char *path, ModelObject *model_object, bool binary)
|
|
{
|
|
TriangleMesh mesh = model_object->mesh();
|
|
return store_stl(path, &mesh, binary);
|
|
}
|
|
|
|
bool store_stl(const char *path, Model *model, bool binary)
|
|
{
|
|
TriangleMesh mesh = model->mesh();
|
|
return store_stl(path, &mesh, binary);
|
|
}
|
|
|
|
}; // namespace Slic3r
|