From 506be9035b9467127de2dec88579209cb250e403 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 23 Jul 2019 13:58:07 +0200 Subject: [PATCH 1/2] Wipe tower now supports filaments with diameters different from 1.75 mm --- src/libslic3r/GCode/WipeTower.cpp | 4 ++-- src/libslic3r/GCode/WipeTower.hpp | 16 +++++++++++----- src/libslic3r/Print.cpp | 10 +++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 354ec6d9e..55a6c4437 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -157,7 +157,7 @@ public: change_analyzer_mm3_per_mm(len, e); // Width of a squished extrusion, corrected for the roundings of the squished extrusions. // This is left zero if it is a travel move. - float width = float(double(e) * /*Filament_Area*/2.40528 / (len * m_layer_height)); + float width = float(double(e) * m_filpar[0].filament_area / (len * m_layer_height)); // Correct for the roundings of a squished extrusion. width += m_layer_height * float(1. - M_PI / 4.); if (m_extrusions.empty() || m_extrusions.back().pos != rotated_current_pos) @@ -822,7 +822,7 @@ void WipeTower::toolchange_Unload( while (i < m_filpar[m_current_tool].ramming_speed.size()) { const float x = volume_to_length(m_filpar[m_current_tool].ramming_speed[i] * 0.25f, line_width, m_layer_height); - const float e = m_filpar[m_current_tool].ramming_speed[i] * 0.25f / Filament_Area; // transform volume per sec to E move; + const float e = m_filpar[m_current_tool].ramming_speed[i] * 0.25f / filament_area(); // transform volume per sec to E move; const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround const float actual_time = dist/x * 0.25; writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), dist / (actual_time / 60.)); diff --git a/src/libslic3r/GCode/WipeTower.hpp b/src/libslic3r/GCode/WipeTower.hpp index badb3e8b2..6dfad1b8c 100644 --- a/src/libslic3r/GCode/WipeTower.hpp +++ b/src/libslic3r/GCode/WipeTower.hpp @@ -111,7 +111,8 @@ public: // Set the extruder properties. void set_extruder(size_t idx, std::string material, int temp, int first_layer_temp, float loading_speed, float loading_speed_start, float unloading_speed, float unloading_speed_start, float delay, int cooling_moves, - float cooling_initial_speed, float cooling_final_speed, std::string ramming_parameters, float max_volumetric_speed, float nozzle_diameter) + float cooling_initial_speed, float cooling_final_speed, std::string ramming_parameters, float max_volumetric_speed, + float nozzle_diameter, float filament_diameter) { //while (m_filpar.size() < idx+1) // makes sure the required element is in the vector m_filpar.push_back(FilamentParameters()); @@ -133,10 +134,12 @@ public: m_filpar[idx].cooling_final_speed = cooling_final_speed; } - if (max_volumetric_speed != 0.f) - m_filpar[idx].max_e_speed = (max_volumetric_speed / Filament_Area); + m_filpar[idx].filament_area = (M_PI/4.f) * pow(filament_diameter, 2); // all extruders are assumed to have the same filament diameter at this point m_filpar[idx].nozzle_diameter = nozzle_diameter; // to be used in future with (non-single) multiextruder MM + if (max_volumetric_speed != 0.f) + m_filpar[idx].max_e_speed = (max_volumetric_speed / filament_area()); + m_perimeter_width = nozzle_diameter * Width_To_Nozzle_Ratio; // all extruders are now assumed to have the same diameter if (m_semm) { @@ -248,6 +251,7 @@ public: float max_e_speed = std::numeric_limits::max(); std::vector ramming_speed; float nozzle_diameter; + float filament_area; }; private: @@ -261,9 +265,11 @@ private: const bool m_peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet - const float Filament_Area = float(M_PI * 1.75f * 1.75f / 4.f); // filament area in mm^2 const float Width_To_Nozzle_Ratio = 1.25f; // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust const float WT_EPSILON = 1e-3f; + const float filament_area() const { + return m_filpar[0].filament_area; // all extruders are assumed to have the same filament diameter at this point + } bool m_semm = true; // Are we using a single extruder multimaterial printer? @@ -315,7 +321,7 @@ private: { if ( layer_height < 0 ) return m_extrusion_flow; - return layer_height * ( m_perimeter_width - layer_height * (1.f-float(M_PI)/4.f)) / Filament_Area; + return layer_height * ( m_perimeter_width - layer_height * (1.f-float(M_PI)/4.f)) / filament_area(); } // Calculates length of extrusion line to extrude given volume diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index a9b8a827f..5702f49e3 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1092,6 +1092,13 @@ std::string Print::validate() const } if (this->has_wipe_tower() && ! m_objects.empty()) { + // make sure all extruders use same diameter filament and have the same nozzle diameter + for (const auto& extruder_idx : extruders()) { + if (m_config.nozzle_diameter.get_at(extruder_idx) != m_config.nozzle_diameter.get_at(extruders().front()) + || m_config.filament_diameter.get_at(extruder_idx) != m_config.filament_diameter.get_at(extruders().front())) + return L("The wipe tower is only supported if all extruders have the same nozzle diameter and use filaments of the same diameter."); + } + if (m_config.gcode_flavor != gcfRepRap && m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlin) return L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter and Repetier G-code flavors."); if (! m_config.use_relative_e_distances) @@ -1701,7 +1708,8 @@ void Print::_make_wipe_tower() (float)m_config.filament_cooling_final_speed.get_at(i), m_config.filament_ramming_parameters.get_at(i), m_config.filament_max_volumetric_speed.get_at(i), - m_config.nozzle_diameter.get_at(i)); + m_config.nozzle_diameter.get_at(i), + m_config.filament_diameter.get_at(i)); m_wipe_tower_data.priming = Slic3r::make_unique>( wipe_tower.prime((float)this->skirt_first_layer_height(), m_wipe_tower_data.tool_ordering.all_extruders(), false)); From 91a5d70a627aec290860971c338d638e60ce595e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 23 Jul 2019 11:22:54 +0200 Subject: [PATCH 2/2] Fixed a few warnings in headers (meaning they were reported once for each include) Fixed an identification of CXX compiler in cmake so that 'AppleClang' is recognized --- CMakeLists.txt | 4 ++-- src/libslic3r/Utils.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoBase.cpp | 4 ++-- src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp | 6 +++--- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 2 +- src/slic3r/GUI/wxExtensions.hpp | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f60c8bde6..6f2332ce0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,7 +162,7 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX) endif () endif() -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") add_compile_options(-Wall) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder" ) @@ -170,7 +170,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STRE add_compile_options(-Werror=return-type) #removes LOTS of extraneous Eigen warnings (GCC only supports it since 6.1) - #if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.1) + #if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.1) # add_compile_options(-Wno-ignored-attributes) # Tamas: Eigen include dirs are marked as SYSTEM #endif() diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 09e24a475..8a4f1424b 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -172,7 +172,7 @@ extern std::string xml_escape(std::string text); #if defined __GNUC__ && __GNUC__ < 5 && !defined __clang__ // Older GCCs don't have std::is_trivially_copyable // cf. https://gcc.gnu.org/onlinedocs/gcc-4.9.4/libstdc++/manual/manual/status.html#status.iso.2011 -#warning "GCC version < 5, faking std::is_trivially_copyable" +// #warning "GCC version < 5, faking std::is_trivially_copyable" template struct IsTriviallyCopyable { static constexpr bool value = true; }; #else template struct IsTriviallyCopyable : public std::is_trivially_copyable {}; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index 4b975e87e..a65074646 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -166,7 +166,7 @@ void GLGizmoBase::set_highlight_color(const float* color) void GLGizmoBase::enable_grabber(unsigned int id) { - if ((0 <= id) && (id < (unsigned int)m_grabbers.size())) + if (id < m_grabbers.size()) m_grabbers[id].enabled = true; on_enable_grabber(id); @@ -174,7 +174,7 @@ void GLGizmoBase::enable_grabber(unsigned int id) void GLGizmoBase::disable_grabber(unsigned int id) { - if ((0 <= id) && (id < (unsigned int)m_grabbers.size())) + if (id < m_grabbers.size()) m_grabbers[id].enabled = false; on_disable_grabber(id); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp index 7846edb22..8733c9a11 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp @@ -93,19 +93,19 @@ protected: } virtual void on_set_hover_id() { - for (unsigned int i = 0; i < 3; ++i) + for (int i = 0; i < 3; ++i) { m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1); } } virtual void on_enable_grabber(unsigned int id) { - if ((0 <= id) && (id < 3)) + if (id < 3) m_gizmos[id].enable_grabber(0); } virtual void on_disable_grabber(unsigned int id) { - if ((0 <= id) && (id < 3)) + if (id < 3) m_gizmos[id].disable_grabber(0); } virtual void on_start_dragging(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 2aaf55424..d96b806e5 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -223,7 +223,7 @@ void GLGizmosManager::update_data() enable_grabber(Rotate, 1, !is_wipe_tower); bool enable_scale_xyz = selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier(); - for (int i = 0; i < 6; ++i) + for (unsigned int i = 0; i < 6; ++i) { enable_grabber(Scale, i, enable_scale_xyz); } diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 9a6460dcb..a704f79d7 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -323,9 +323,9 @@ public: } bool SwapChildrens(int frst_id, int scnd_id) { - if (GetChildCount() < 2 || - frst_id < 0 || frst_id >= GetChildCount() || - scnd_id < 0 || scnd_id >= GetChildCount()) + if (GetChildCount() < 2 || + frst_id < 0 || (size_t)frst_id >= GetChildCount() || + scnd_id < 0 || (size_t)scnd_id >= GetChildCount()) return false; ObjectDataViewModelNode new_scnd = *GetNthChild(frst_id);