mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 15:44:12 -06:00
Merge remote-tracking branch 'origin/master' into tm_sla_supports_backend
This commit is contained in:
commit
5f43ec1b78
85 changed files with 33181 additions and 543 deletions
|
@ -174,7 +174,7 @@ if (NOT SLIC3R_SYNTAXONLY)
|
|||
endif ()
|
||||
|
||||
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB ${PNG_DEFINITIONS})
|
||||
target_include_directories(libslic3r PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${LIBNEST2D_INCLUDES} ${PNG_INCLUDE_DIRS})
|
||||
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} ${PNG_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(libslic3r
|
||||
libnest2d
|
||||
admesh
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef slic3r_ClipperUtils_hpp_
|
||||
#define slic3r_ClipperUtils_hpp_
|
||||
|
||||
#include <libslic3r.h>
|
||||
#include "libslic3r.h"
|
||||
#include "clipper.hpp"
|
||||
#include "ExPolygon.hpp"
|
||||
#include "Polygon.hpp"
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "../PrintConfig.hpp"
|
||||
#include "../ExtrusionEntity.hpp"
|
||||
|
||||
#include "Point.hpp"
|
||||
#include "GCodeReader.hpp"
|
||||
#include "../Point.hpp"
|
||||
#include "../GCodeReader.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#include "../libslic3r.h"
|
||||
#include "../ExtrusionEntity.hpp"
|
||||
|
||||
#include "Point.hpp"
|
||||
#include "../Point.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
|
|
@ -981,63 +981,76 @@ template<class T> static void cut_reset_transform(T *thing) {
|
|||
thing->set_offset(offset);
|
||||
}
|
||||
|
||||
ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z)
|
||||
ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, bool keep_lower, bool rotate_lower)
|
||||
{
|
||||
// Clone the object to duplicate instances, materials etc.
|
||||
ModelObject* upper = ModelObject::new_clone(*this);
|
||||
ModelObject* lower = ModelObject::new_clone(*this);
|
||||
upper->set_model(nullptr);
|
||||
lower->set_model(nullptr);
|
||||
upper->sla_support_points.clear();
|
||||
lower->sla_support_points.clear();
|
||||
upper->clear_volumes();
|
||||
lower->clear_volumes();
|
||||
upper->input_file = "";
|
||||
lower->input_file = "";
|
||||
ModelObject* upper = keep_upper ? ModelObject::new_clone(*this) : nullptr;
|
||||
ModelObject* lower = keep_lower ? ModelObject::new_clone(*this) : nullptr;
|
||||
|
||||
if (keep_upper) {
|
||||
upper->set_model(nullptr);
|
||||
upper->sla_support_points.clear();
|
||||
upper->clear_volumes();
|
||||
upper->input_file = "";
|
||||
}
|
||||
|
||||
if (keep_lower) {
|
||||
lower->set_model(nullptr);
|
||||
lower->sla_support_points.clear();
|
||||
lower->clear_volumes();
|
||||
lower->input_file = "";
|
||||
}
|
||||
|
||||
const auto instance_matrix = instances[instance]->get_matrix(true);
|
||||
|
||||
// Because transformations are going to be applied to meshes directly,
|
||||
// we reset transformation of all instances and volumes,
|
||||
// _except_ for translation, which is preserved in the transformation matrix
|
||||
// except for translation, which is preserved in the transformation matrix
|
||||
// and not applied to the mesh transform.
|
||||
// TODO: Do the same for Z-rotation as well?
|
||||
|
||||
// Convert z from relative to bb's base to object coordinates
|
||||
// FIXME: doesn't work well for rotated objects
|
||||
const auto bb = instance_bounding_box(instance, true);
|
||||
z -= bb.min(2);
|
||||
|
||||
for (auto *instance : upper->instances) { cut_reset_transform(instance); }
|
||||
for (auto *instance : lower->instances) { cut_reset_transform(instance); }
|
||||
if (keep_upper) {
|
||||
for (auto *instance : upper->instances) { cut_reset_transform(instance); }
|
||||
}
|
||||
if (keep_lower) {
|
||||
for (auto *instance : lower->instances) { cut_reset_transform(instance); }
|
||||
}
|
||||
|
||||
for (ModelVolume *volume : volumes) {
|
||||
if (! volume->is_model_part()) {
|
||||
// don't cut modifiers
|
||||
upper->add_volume(*volume);
|
||||
lower->add_volume(*volume);
|
||||
if (keep_upper) { upper->add_volume(*volume); }
|
||||
if (keep_lower) { lower->add_volume(*volume); }
|
||||
} else {
|
||||
TriangleMesh upper_mesh, lower_mesh;
|
||||
|
||||
// Transform the mesh by the object transformation matrix
|
||||
volume->mesh.transform(instance_matrix * volume->get_matrix(true));
|
||||
const auto volume_tr = instance_matrix * volume->get_matrix(true);
|
||||
volume->mesh.transform(volume_tr);
|
||||
cut_reset_transform(volume);
|
||||
|
||||
// Transform z from world to object
|
||||
const auto local_z = volume_tr * Vec3d(0.0, 0.0, z);
|
||||
|
||||
TriangleMeshSlicer tms(&volume->mesh);
|
||||
tms.cut(z, &upper_mesh, &lower_mesh);
|
||||
tms.cut(local_z(2), &upper_mesh, &lower_mesh);
|
||||
|
||||
upper_mesh.repair();
|
||||
lower_mesh.repair();
|
||||
upper_mesh.reset_repair_stats();
|
||||
lower_mesh.reset_repair_stats();
|
||||
if (keep_upper) {
|
||||
upper_mesh.repair();
|
||||
upper_mesh.reset_repair_stats();
|
||||
}
|
||||
if (keep_lower) {
|
||||
lower_mesh.repair();
|
||||
lower_mesh.reset_repair_stats();
|
||||
}
|
||||
|
||||
if (upper_mesh.facets_count() > 0) {
|
||||
if (keep_upper && upper_mesh.facets_count() > 0) {
|
||||
ModelVolume* vol = upper->add_volume(upper_mesh);
|
||||
vol->name = volume->name;
|
||||
vol->config = volume->config;
|
||||
vol->set_material(volume->material_id(), *volume->material());
|
||||
}
|
||||
if (lower_mesh.facets_count() > 0) {
|
||||
if (keep_lower && lower_mesh.facets_count() > 0) {
|
||||
ModelVolume* vol = lower->add_volume(lower_mesh);
|
||||
vol->name = volume->name;
|
||||
vol->config = volume->config;
|
||||
|
@ -1046,12 +1059,27 @@ ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z)
|
|||
}
|
||||
}
|
||||
|
||||
upper->invalidate_bounding_box();
|
||||
lower->invalidate_bounding_box();
|
||||
if (keep_lower && rotate_lower) {
|
||||
for (auto *instance : lower->instances) {
|
||||
Geometry::Transformation tr;
|
||||
tr.set_offset(instance->get_offset());
|
||||
tr.set_rotation({Geometry::deg2rad(180.0), 0.0, 0.0});
|
||||
instance->set_transformation(tr);
|
||||
}
|
||||
}
|
||||
|
||||
ModelObjectPtrs res;
|
||||
if (upper->volumes.size() > 0) { res.push_back(upper); }
|
||||
if (lower->volumes.size() > 0) { res.push_back(lower); }
|
||||
|
||||
if (keep_upper && upper->volumes.size() > 0) {
|
||||
upper->invalidate_bounding_box();
|
||||
upper->center_around_origin();
|
||||
res.push_back(upper);
|
||||
}
|
||||
if (keep_lower && lower->volumes.size() > 0) {
|
||||
lower->invalidate_bounding_box();
|
||||
lower->center_around_origin();
|
||||
res.push_back(lower);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
size_t materials_count() const;
|
||||
size_t facets_count() const;
|
||||
bool needed_repair() const;
|
||||
ModelObjectPtrs cut(size_t instance, coordf_t z);
|
||||
ModelObjectPtrs cut(size_t instance, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false); // Note: z is in world coordinates
|
||||
void split(ModelObjectPtrs* new_objects);
|
||||
void repair();
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#define ENABLE_WORLD_ROTATIONS (1 && ENABLE_1_42_0)
|
||||
// Enables shortcut keys for gizmos
|
||||
#define ENABLE_GIZMOS_SHORTCUT (1 && ENABLE_1_42_0)
|
||||
// Scene's GUI made using imgui library
|
||||
#define ENABLE_IMGUI (1 && ENABLE_1_42_0)
|
||||
|
||||
#endif // _technologies_h_
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue