Fixed conflicts after merge with tm_integrate_libbgcode

This commit is contained in:
enricoturri1966 2023-08-02 15:21:23 +02:00
commit 6e88ee76da
10 changed files with 98 additions and 43 deletions

9
deps/CMakeLists.txt vendored
View File

@ -20,8 +20,8 @@
# therefore, unfortunatelly, the installation cannot be copied/moved elsewhere without re-installing wxWidgets.
#
cmake_minimum_required(VERSION 3.10)
project(PrusaSlicer-deps)
cmake_minimum_required(VERSION 3.2)
include(ExternalProject)
include(ProcessorCount)
@ -62,6 +62,10 @@ if (NOT _is_multi AND NOT CMAKE_BUILD_TYPE)
message(STATUS "Forcing CMAKE_BUILD_TYPE to Release as it was not specified.")
endif ()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)
endif ()
function(prusaslicer_add_cmake_project projectname)
cmake_parse_arguments(P_ARGS "" "INSTALL_DIR;BUILD_COMMAND;INSTALL_COMMAND" "CMAKE_ARGS" ${ARGN})
@ -195,6 +199,8 @@ include(NanoSVG/NanoSVG.cmake)
include(wxWidgets/wxWidgets.cmake)
include(OCCT/OCCT.cmake)
include(LibBGCode/LibBGCode.cmake)
set(_dep_list
dep_Boost
dep_TBB
@ -210,6 +216,7 @@ set(_dep_list
${PNG_PKG}
${ZLIB_PKG}
${EXPAT_PKG}
dep_LibBGCode
)
# if (NOT MSVC)

24
deps/LibBGCode/LibBGCode.cmake vendored Normal file
View File

@ -0,0 +1,24 @@
set(LibBGCode_SOURCE_DIR "" CACHE PATH "Optionally specify local LibBGCode source directory")
set(_source_dir_line "GIT_REPOSITORY;git@github.com:prusa3d/libbgcode.git;GIT_TAG;main")
if (LibBGCode_SOURCE_DIR)
set(_source_dir_line "SOURCE_DIR;${LibBGCode_SOURCE_DIR};BUILD_ALWAYS;ON")
endif ()
prusaslicer_add_cmake_project(LibBGCode_deps
${_source_dir_line}
SOURCE_SUBDIR deps
CMAKE_ARGS
-DDEP_DOWNLOAD_DIR:PATH=${DEP_DOWNLOAD_DIR}
-DLibBGCode_Deps_SELECT_ALL:BOOL=OFF
-DLibBGCode_Deps_SELECT_heatshrink:BOOL=ON
-DDESTDIR=${DESTDIR}
)
prusaslicer_add_cmake_project(LibBGCode
${_source_dir_line}
DEPENDS dep_LibBGCode_deps
CMAKE_ARGS
-DLibBGCode_BUILD_TESTS:BOOL=OFF
)

View File

@ -14,6 +14,8 @@ if (TARGET OpenVDB::openvdb)
set(OpenVDBUtils_SOURCES OpenVDBUtils.cpp OpenVDBUtils.hpp OpenVDBUtilsLegacy.hpp)
endif()
find_package(LibBGCode REQUIRED COMPONENTS Convert)
set(SLIC3R_SOURCES
pchheader.cpp
pchheader.hpp
@ -510,7 +512,7 @@ target_link_libraries(libslic3r
ZLIB::ZLIB
JPEG::JPEG
qoi
heatshrink
LibBGCode::bgcode_convert
)
if (APPLE)

View File

@ -1,8 +1,10 @@
#ifndef CSGMESH_HPP
#define CSGMESH_HPP
#include "libslic3r/Point.hpp"
#include <libslic3r/AnyPtr.hpp>
#include <admesh/stl.h>
#include <libslic3r/TriangleMesh.hpp>
namespace Slic3r { namespace csg {
@ -81,6 +83,35 @@ struct CSGPart {
{}
};
template<class Cont> bool is_all_positive(const Cont &csgmesh)
{
bool is_all_pos =
std::all_of(csgmesh.begin(),
csgmesh.end(),
[](auto &part) {
return csg::get_operation(part) == csg::CSGType::Union;
});
return is_all_pos;
}
template<class Cont>
indexed_triangle_set csgmesh_merge_positive_parts(const Cont &csgmesh)
{
indexed_triangle_set m;
for (auto &csgpart : csgmesh) {
auto op = csg::get_operation(csgpart);
const indexed_triangle_set * pmesh = csg::get_mesh(csgpart);
if (pmesh && op == csg::CSGType::Union) {
indexed_triangle_set mcpy = *pmesh;
its_transform(mcpy, csg::get_transform(csgpart), true);
its_merge(m, mcpy);
}
}
return m;
}
}} // namespace Slic3r::csg
#endif // CSGMESH_HPP

View File

@ -516,7 +516,7 @@ WipeTower::ToolChangeResult WipeTower::construct_tcr(WipeTowerWriter& writer,
WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
WipeTower::WipeTower(const PrintConfig& config, const PrintRegionConfig& default_region_config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
m_semm(config.single_extruder_multi_material.value),
m_wipe_tower_pos(config.wipe_tower_x, config.wipe_tower_y),
m_wipe_tower_width(float(config.wipe_tower_width)),
@ -530,6 +530,8 @@ WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<fl
m_no_sparse_layers(config.wipe_tower_no_sparse_layers),
m_gcode_flavor(config.gcode_flavor),
m_travel_speed(config.travel_speed),
m_infill_speed(default_region_config.infill_speed),
m_perimeter_speed(default_region_config.perimeter_speed),
m_current_tool(initial_tool),
wipe_volumes(wiping_matrix)
{
@ -541,6 +543,13 @@ WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<fl
if (m_first_layer_speed == 0.f) // just to make sure autospeed doesn't break it.
m_first_layer_speed = default_speed / 2.f;
// Autospeed may be used...
if (m_infill_speed == 0.f)
m_infill_speed = 80.f;
if (m_perimeter_speed == 0.f)
m_perimeter_speed = 80.f;
// If this is a single extruder MM printer, we will use all the SE-specific config values.
// Otherwise, the defaults will be used to turn off the SE stuff.
if (m_semm) {
@ -1034,7 +1043,7 @@ void WipeTower::toolchange_Wipe(
float x_to_wipe = volume_to_length(wipe_volume, m_perimeter_width, m_layer_height);
float dy = m_extra_spacing*m_perimeter_width;
const float target_speed = is_first_layer() ? m_first_layer_speed * 60.f : 4800.f;
const float target_speed = is_first_layer() ? m_first_layer_speed * 60.f : m_infill_speed * 60.f;
float wipe_speed = 0.33f * target_speed;
// if there is less than 2.5*m_perimeter_width to the edge, advance straightaway (there is likely a blob anyway)
@ -1103,7 +1112,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
// Slow down on the 1st layer.
bool first_layer = is_first_layer();
float feedrate = first_layer ? m_first_layer_speed * 60.f : 2900.f;
float feedrate = first_layer ? m_first_layer_speed * 60.f : m_infill_speed * 60.f;
float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth();
box_coordinates fill_box(Vec2f(m_perimeter_width, m_layer_info->depth-(current_depth-m_perimeter_width)),
m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width);
@ -1203,7 +1212,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
// First generate vector of annotated point which form the boundary.
std::vector<std::pair<Vec2f, Type>> pts = {{wt_box.ru, Corner}};
if (double alpha_start = std::asin((0.5*w)/r); ! std::isnan(alpha_start) && r > 0.5*w+0.01) {
for (double alpha = alpha_start; alpha < M_PI-alpha_start+0.001; alpha+=(M_PI-2*alpha_start) / 20.)
for (double alpha = alpha_start; alpha < M_PI-alpha_start+0.001; alpha+=(M_PI-2*alpha_start) / 40.)
pts.emplace_back(Vec2f(center.x() + r*std::cos(alpha)/support_scale, center.y() + r*std::sin(alpha)), alpha == alpha_start ? ArcStart : Arc);
pts.back().second = ArcEnd;
}
@ -1285,6 +1294,8 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
return poly;
};
feedrate = first_layer ? m_first_layer_speed * 60.f : m_perimeter_speed * 60.f;
// outer contour (always)
bool infill_cone = first_layer && m_wipe_tower_width > 2*spacing && m_wipe_tower_depth > 2*spacing;
Polygon poly = supported_rectangle(wt_box, feedrate, infill_cone);

View File

@ -14,6 +14,7 @@ namespace Slic3r
class WipeTowerWriter;
class PrintConfig;
class PrintRegionConfig;
enum GCodeFlavor : unsigned char;
@ -129,7 +130,10 @@ public:
// y -- y coordinates of wipe tower in mm ( left bottom corner )
// width -- width of wipe tower in mm ( default 60 mm - leave as it is )
// wipe_area -- space available for one toolchange in mm
WipeTower(const PrintConfig& config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool);
WipeTower(const PrintConfig& config,
const PrintRegionConfig& default_region_config,
const std::vector<std::vector<float>>& wiping_matrix,
size_t initial_tool);
// Set the extruder properties.
@ -269,6 +273,8 @@ private:
size_t m_max_color_changes = 0; // Maximum number of color changes per layer.
int m_old_temperature = -1; // To keep track of what was the last temp that we set (so we don't issue the command when not neccessary)
float m_travel_speed = 0.f;
float m_infill_speed = 0.f;
float m_perimeter_speed = 0.f;
float m_first_layer_speed = 0.f;
size_t m_first_layer_idx = size_t(-1);

View File

@ -1456,7 +1456,7 @@ void Print::_make_wipe_tower()
this->throw_if_canceled();
// Initialize the wipe tower.
WipeTower wipe_tower(m_config, wipe_volumes, m_wipe_tower_data.tool_ordering.first_extruder());
WipeTower wipe_tower(m_config, m_default_region_config, wipe_volumes, m_wipe_tower_data.tool_ordering.first_extruder());
//wipe_tower.set_retract();
//wipe_tower.set_zhop();

View File

@ -814,15 +814,15 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "overhang_speed_2"
|| opt_key == "overhang_speed_3"
|| opt_key == "external_perimeter_speed"
|| opt_key == "infill_speed"
|| opt_key == "perimeter_speed"
|| opt_key == "small_perimeter_speed"
|| opt_key == "solid_infill_speed"
|| opt_key == "top_solid_infill_speed") {
invalidated |= m_print->invalidate_step(psGCodeExport);
} else if (
opt_key == "wipe_into_infill"
|| opt_key == "wipe_into_objects") {
|| opt_key == "wipe_into_objects"
|| opt_key == "infill_speed"
|| opt_key == "perimeter_speed") {
invalidated |= m_print->invalidate_step(psWipeTower);
invalidated |= m_print->invalidate_step(psGCodeExport);
} else {

View File

@ -127,35 +127,6 @@ void SLAPrint::Steps::apply_printer_corrections(SLAPrintObject &po, SliceOrigin
}
}
template<class Cont> bool is_all_positive(const Cont &csgmesh)
{
bool is_all_pos =
std::all_of(csgmesh.begin(),
csgmesh.end(),
[](auto &part) {
return csg::get_operation(part) == csg::CSGType::Union;
});
return is_all_pos;
}
template<class Cont>
static indexed_triangle_set csgmesh_merge_positive_parts(const Cont &csgmesh)
{
indexed_triangle_set m;
for (auto &csgpart : csgmesh) {
auto op = csg::get_operation(csgpart);
const indexed_triangle_set * pmesh = csg::get_mesh(csgpart);
if (pmesh && op == csg::CSGType::Union) {
indexed_triangle_set mcpy = *pmesh;
its_transform(mcpy, csg::get_transform(csgpart), true);
its_merge(m, mcpy);
}
}
return m;
}
indexed_triangle_set SLAPrint::Steps::generate_preview_vdb(
SLAPrintObject &po, SLAPrintObjectStep step)
{

View File

@ -6535,9 +6535,12 @@ void Plater::export_stl_obj(bool extended, bool selection_only)
csg::model_to_csgmesh(mo, Transform3d::Identity(), std::back_inserter(csgmesh),
csg::mpartsPositive | csg::mpartsNegative | csg::mpartsDoSplits);
if (csg::check_csgmesh_booleans(range(csgmesh)) == csgmesh.end()) {
auto csgrange = range(csgmesh);
if (csg::is_all_positive(csgrange)) {
mesh = TriangleMesh{csg::csgmesh_merge_positive_parts(csgrange)};
} else if (csg::check_csgmesh_booleans(csgrange) == csgrange.end()) {
try {
auto cgalm = csg::perform_csgmesh_booleans(range(csgmesh));
auto cgalm = csg::perform_csgmesh_booleans(csgrange);
mesh = MeshBoolean::cgal::cgal_to_triangle_mesh(*cgalm);
} catch (...) {}
}