Merge branch 'master' into fs_emboss
# Conflicts: # src/libslic3r/CMakeLists.txt # src/libslic3r/Format/3mf.cpp # src/libslic3r/Model.hpp # src/libslic3r/Point.hpp # src/libslic3r/Technologies.hpp # src/slic3r/CMakeLists.txt # src/slic3r/GUI/GLCanvas3D.cpp # src/slic3r/GUI/GLSelectionRectangle.cpp # src/slic3r/GUI/GUI_Factories.hpp # src/slic3r/GUI/Gizmos/GLGizmoBase.cpp # src/slic3r/GUI/Gizmos/GLGizmoBase.hpp # src/slic3r/GUI/Gizmos/GLGizmoMove.cpp # src/slic3r/GUI/Gizmos/GLGizmoMove.hpp # src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp # src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp # src/slic3r/GUI/MeshUtils.cpp # src/slic3r/GUI/MeshUtils.hpp # src/slic3r/GUI/ObjectDataViewModel.cpp # src/slic3r/GUI/ObjectDataViewModel.hpp # src/slic3r/GUI/Selection.cpp
This commit is contained in:
commit
c549c6afbe
386 changed files with 39391 additions and 33206 deletions
|
@ -483,6 +483,7 @@ namespace Slic3r {
|
|||
|
||||
bool load_model_from_file(const std::string& filename, Model& model, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions, bool check_version);
|
||||
unsigned int version() const { return m_version; }
|
||||
boost::optional<Semver> prusaslicer_generator_version() const { return m_prusaslicer_generator_version; }
|
||||
|
||||
private:
|
||||
void _destroy_xml_parser();
|
||||
|
@ -3258,8 +3259,7 @@ bool _3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive( mz_zip_archiv
|
|||
}
|
||||
|
||||
// Perform conversions based on the config values available.
|
||||
//FIXME provide a version of PrusaSlicer that stored the project file (3MF).
|
||||
static void handle_legacy_project_loaded(unsigned int version_project_file, DynamicPrintConfig& config)
|
||||
static void handle_legacy_project_loaded(unsigned int version_project_file, DynamicPrintConfig& config, const boost::optional<Semver>& prusaslicer_generator_version)
|
||||
{
|
||||
if (! config.has("brim_separation")) {
|
||||
if (auto *opt_elephant_foot = config.option<ConfigOptionFloat>("elefant_foot_compensation", false); opt_elephant_foot) {
|
||||
|
@ -3268,6 +3268,23 @@ static void handle_legacy_project_loaded(unsigned int version_project_file, Dyna
|
|||
opt_brim_separation->value = opt_elephant_foot->value;
|
||||
}
|
||||
}
|
||||
|
||||
// In PrusaSlicer 2.5.0-alpha2 and 2.5.0-alpha3, we introduce several parameters for Arachne that depend
|
||||
// on nozzle size . Later we decided to make default values for those parameters computed automatically
|
||||
// until the user changes them.
|
||||
if (prusaslicer_generator_version && *prusaslicer_generator_version >= *Semver::parse("2.5.0-alpha2") && *prusaslicer_generator_version <= *Semver::parse("2.5.0-alpha3")) {
|
||||
if (auto *opt_wall_transition_length = config.option<ConfigOptionFloatOrPercent>("wall_transition_length", false);
|
||||
opt_wall_transition_length && !opt_wall_transition_length->percent && opt_wall_transition_length->value == 0.4) {
|
||||
opt_wall_transition_length->percent = true;
|
||||
opt_wall_transition_length->value = 100;
|
||||
}
|
||||
|
||||
if (auto *opt_min_feature_size = config.option<ConfigOptionFloatOrPercent>("min_feature_size", false);
|
||||
opt_min_feature_size && !opt_min_feature_size->percent && opt_min_feature_size->value == 0.1) {
|
||||
opt_min_feature_size->percent = true;
|
||||
opt_min_feature_size->value = 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_project_3mf(const std::string& filename)
|
||||
|
@ -3308,9 +3325,9 @@ bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionCo
|
|||
// All import should use "C" locales for number formatting.
|
||||
CNumericLocalesSetter locales_setter;
|
||||
_3MF_Importer importer;
|
||||
bool res = importer.load_model_from_file(path, *model, config, config_substitutions, check_version);
|
||||
importer.load_model_from_file(path, *model, config, config_substitutions, check_version);
|
||||
importer.log_errors();
|
||||
handle_legacy_project_loaded(importer.version(), config);
|
||||
handle_legacy_project_loaded(importer.version(), config, importer.prusaslicer_generator_version());
|
||||
|
||||
return !model->objects.empty() || !config.empty();
|
||||
}
|
||||
|
|
131
src/libslic3r/Format/STEP.cpp
Normal file
131
src/libslic3r/Format/STEP.cpp
Normal file
|
@ -0,0 +1,131 @@
|
|||
#include "STEP.hpp"
|
||||
#include "occt_wrapper/OCCTWrapper.hpp"
|
||||
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/TriangleMesh.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/dll/runtime_symbol_info.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include<windows.h>
|
||||
#else
|
||||
#include<occt_wrapper/OCCTWrapper.hpp>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
#if __APPLE__
|
||||
extern "C" bool load_step_internal(const char *path, OCCTResult* res);
|
||||
#endif
|
||||
|
||||
LoadStepFn get_load_step_fn()
|
||||
{
|
||||
static LoadStepFn load_step_fn = nullptr;
|
||||
|
||||
#ifndef __APPLE__
|
||||
constexpr const char* fn_name = "load_step_internal";
|
||||
#endif
|
||||
|
||||
if (!load_step_fn) {
|
||||
auto libpath = boost::dll::program_location().parent_path();
|
||||
#ifdef _WIN32
|
||||
libpath /= "OCCTWrapper.dll";
|
||||
HMODULE module = LoadLibraryW(libpath.wstring().c_str());
|
||||
if (module == NULL)
|
||||
throw Slic3r::RuntimeError("Cannot load OCCTWrapper.dll");
|
||||
|
||||
try {
|
||||
FARPROC farproc = GetProcAddress(module, fn_name);
|
||||
if (! farproc) {
|
||||
DWORD ec = GetLastError();
|
||||
throw Slic3r::RuntimeError(std::string("Cannot load function from OCCTWrapper.dll: ") + fn_name
|
||||
+ "\n\nError code: " + std::to_string(ec));
|
||||
}
|
||||
load_step_fn = reinterpret_cast<LoadStepFn>(farproc);
|
||||
} catch (const Slic3r::RuntimeError&) {
|
||||
FreeLibrary(module);
|
||||
throw;
|
||||
}
|
||||
#elif __APPLE__
|
||||
load_step_fn = &load_step_internal;
|
||||
#else
|
||||
libpath /= "OCCTWrapper.so";
|
||||
void *plugin_ptr = dlopen(libpath.c_str(), RTLD_NOW | RTLD_GLOBAL);
|
||||
|
||||
if (plugin_ptr) {
|
||||
load_step_fn = reinterpret_cast<LoadStepFn>(dlsym(plugin_ptr, fn_name));
|
||||
if (!load_step_fn) {
|
||||
dlclose(plugin_ptr);
|
||||
throw Slic3r::RuntimeError(std::string("Cannot load function from OCCTWrapper.so: ") + fn_name
|
||||
+ "\n\n" + dlerror());
|
||||
}
|
||||
} else {
|
||||
throw Slic3r::RuntimeError(std::string("Cannot load OCCTWrapper.so:\n\n") + dlerror());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return load_step_fn;
|
||||
}
|
||||
|
||||
bool load_step(const char *path, Model *model /*BBS:, ImportStepProgressFn proFn*/)
|
||||
{
|
||||
OCCTResult occt_object;
|
||||
|
||||
LoadStepFn load_step_fn = get_load_step_fn();
|
||||
|
||||
if (!load_step_fn)
|
||||
return false;
|
||||
|
||||
load_step_fn(path, &occt_object);
|
||||
|
||||
assert(! occt_object.volumes.empty());
|
||||
|
||||
assert(boost::algorithm::iends_with(occt_object.object_name, ".stp")
|
||||
|| boost::algorithm::iends_with(occt_object.object_name, ".step"));
|
||||
occt_object.object_name.erase(occt_object.object_name.find("."));
|
||||
assert(! occt_object.object_name.empty());
|
||||
|
||||
|
||||
ModelObject* new_object = model->add_object();
|
||||
new_object->input_file = path;
|
||||
if (new_object->volumes.size() == 1 && ! occt_object.volumes.front().volume_name.empty())
|
||||
new_object->name = new_object->volumes.front()->name;
|
||||
else
|
||||
new_object->name = occt_object.object_name;
|
||||
|
||||
|
||||
for (size_t i=0; i<occt_object.volumes.size(); ++i) {
|
||||
indexed_triangle_set its;
|
||||
for (size_t j=0; j<occt_object.volumes[i].vertices.size(); ++j)
|
||||
its.vertices.emplace_back(Vec3f(occt_object.volumes[i].vertices[j][0],
|
||||
occt_object.volumes[i].vertices[j][1],
|
||||
occt_object.volumes[i].vertices[j][2]));
|
||||
for (size_t j=0; j<occt_object.volumes[i].indices.size(); ++j)
|
||||
its.indices.emplace_back(Vec3i(occt_object.volumes[i].indices[j][0],
|
||||
occt_object.volumes[i].indices[j][1],
|
||||
occt_object.volumes[i].indices[j][2]));
|
||||
its_merge_vertices(its, true);
|
||||
TriangleMesh triangle_mesh(std::move(its));
|
||||
ModelVolume* new_volume = new_object->add_volume(std::move(triangle_mesh));
|
||||
|
||||
new_volume->name = occt_object.volumes[i].volume_name.empty()
|
||||
? std::string("Part") + std::to_string(i+1)
|
||||
: occt_object.volumes[i].volume_name;
|
||||
new_volume->source.input_file = path;
|
||||
new_volume->source.object_idx = (int)model->objects.size() - 1;
|
||||
new_volume->source.volume_idx = (int)new_object->volumes.size() - 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}; // namespace Slic3r
|
19
src/libslic3r/Format/STEP.hpp
Normal file
19
src/libslic3r/Format/STEP.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Original implementation of STEP format import created by Bambulab.
|
||||
// https://github.com/bambulab/BambuStudio
|
||||
// Forked off commit 1555904, modified by Prusa Research.
|
||||
|
||||
#ifndef slic3r_Format_STEP_hpp_
|
||||
#define slic3r_Format_STEP_hpp_
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class Model;
|
||||
|
||||
//typedef std::function<void(int load_stage, int current, int total, bool& cancel)> ImportStepProgressFn;
|
||||
|
||||
// Load a step file into a provided model.
|
||||
extern bool load_step(const char *path_str, Model *model /*LMBBS:, ImportStepProgressFn proFn = nullptr*/);
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_Format_STEP_hpp_ */
|
Loading…
Add table
Add a link
Reference in a new issue