mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 15:51:08 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7b740e155 |
@@ -83,7 +83,6 @@
|
||||
#include <cmath>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <functional>
|
||||
#include <gp_XY.hxx>
|
||||
#include <initializer_list>
|
||||
#include <math.h>
|
||||
|
||||
@@ -261,8 +261,6 @@ set(lisbslic3r_sources
|
||||
GCode/PreciseSeam.cpp
|
||||
GCode/PreciseSeam.hpp
|
||||
GCode/PreciseSeamInternal.hpp
|
||||
#GCodeSender.cpp
|
||||
#GCodeSender.hpp
|
||||
GCode/SmallAreaInfillFlowCompensator.cpp
|
||||
GCode/SmallAreaInfillFlowCompensator.hpp
|
||||
GCode/SpiralVase.cpp
|
||||
@@ -447,7 +445,6 @@ set(lisbslic3r_sources
|
||||
SLA/SupportTreeBuildsteps.hpp
|
||||
SLA/SupportTree.cpp
|
||||
SLA/SupportTree.hpp
|
||||
#SLA/SupportTreeIGL.cpp
|
||||
SLA/SupportTreeMesher.cpp
|
||||
SLA/SupportTreeMesher.hpp
|
||||
SlicesToTriangleMesh.cpp
|
||||
|
||||
@@ -2589,7 +2589,6 @@ void priv::create_face_types(FaceTypeMap &map,
|
||||
}
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/clip.h>
|
||||
#include <CGAL/Polygon_mesh_processing/corefinement.h>
|
||||
bool priv::clip_cut(SurfacePatch &cut, CutMesh clipper)
|
||||
{
|
||||
CutMesh& tm = cut.mesh;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "Emboss.hpp"
|
||||
#include <optional>
|
||||
#include <stdio.h>
|
||||
#include <numeric>
|
||||
#include <cstdlib>
|
||||
#include <boost/nowide/convert.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include "TDataStd_Name.hxx"
|
||||
#include "BRepBuilderAPI_Transform.hxx"
|
||||
#include "TopExp_Explorer.hxx"
|
||||
#include "TopExp_Explorer.hxx"
|
||||
#include "BRep_Tool.hxx"
|
||||
#include "BRepTools.hxx"
|
||||
#include <IMeshTools_Parameters.hxx>
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "Print.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "libslic3r.h"
|
||||
#include "LocalesUtils.hpp"
|
||||
#include "libslic3r/format.hpp"
|
||||
#include "Time.hpp"
|
||||
|
||||
@@ -148,6 +148,8 @@ struct ConflictComputeResult
|
||||
|
||||
using ConflictComputeOpt = std::optional<ConflictComputeResult>;
|
||||
|
||||
using ConflictObjName = std::optional<std::pair<std::string, std::string>>;
|
||||
|
||||
struct ConflictChecker
|
||||
{
|
||||
static ConflictResultOpt find_inter_of_lines_in_diff_objs(PrintObjectPtrs objs, std::optional<const FakeWipeTower *> wtdptr);
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "../PrintConfig.hpp"
|
||||
#include "../Utils.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <string>
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
namespace Slic3r {
|
||||
namespace PreciseSeam {
|
||||
|
||||
// Import EnforcedBlockedSeamPoint from SeamPlacerImpl namespace for convenience
|
||||
using SeamPlacerImpl::EnforcedBlockedSeamPoint;
|
||||
|
||||
// Geometry and its exterior bounds are prepared together, then treated as read-only.
|
||||
struct ModifierRegion {
|
||||
ExPolygon polygon;
|
||||
@@ -134,7 +137,7 @@ SegmentExtraction extract_perimeter_segments(const PreparedPerimeter &prepared,
|
||||
|
||||
// Result of weak modifier segment processing
|
||||
struct WeakModifierSegment {
|
||||
SeamPlacerImpl::EnforcedBlockedSeamPoint type; // Enforced/Blocked/Neutral
|
||||
EnforcedBlockedSeamPoint type; // Enforced/Blocked/Neutral
|
||||
Point left_point; // Coordinates of left (first) point of segment
|
||||
PerimeterPosition left_position; // Position on the source perimeter before insertion/refinement.
|
||||
Point right_point; // Coordinates of right (last) point of segment
|
||||
|
||||
@@ -40,7 +40,8 @@ std::string get_error_string(const ThumbnailErrors& errors);
|
||||
|
||||
|
||||
typedef std::vector<std::pair<GCodeThumbnailsFormat, Vec2d>> GCodeThumbnailDefinitionsList;
|
||||
std::pair<GCodeThumbnailDefinitionsList, ThumbnailErrors> make_and_check_thumbnail_list(const std::string& thumbnails_string, const std::string_view def_ext = "PNG");
|
||||
using namespace std::literals;
|
||||
std::pair<GCodeThumbnailDefinitionsList, ThumbnailErrors> make_and_check_thumbnail_list(const std::string& thumbnails_string, const std::string_view def_ext = "PNG"sv);
|
||||
std::pair<GCodeThumbnailDefinitionsList, ThumbnailErrors> make_and_check_thumbnail_list(const ConfigBase &config);
|
||||
|
||||
|
||||
|
||||
@@ -1,580 +0,0 @@
|
||||
#include "GCodeSender.hpp"
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if defined(__APPLE__) || defined(__OpenBSD__)
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include <sys/ioctl.h>
|
||||
#include <IOKit/serial/ioss.h>
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include "/usr/include/asm-generic/ioctls.h"
|
||||
|
||||
/* The following definitions are kindly borrowed from:
|
||||
/usr/include/asm-generic/termbits.h
|
||||
Unfortunately we cannot just include that one because
|
||||
it would redefine the "struct termios" already defined
|
||||
the <termios.h> already included by Boost.ASIO. */
|
||||
#define K_NCCS 19
|
||||
struct termios2 {
|
||||
tcflag_t c_iflag;
|
||||
tcflag_t c_oflag;
|
||||
tcflag_t c_cflag;
|
||||
tcflag_t c_lflag;
|
||||
cc_t c_line;
|
||||
cc_t c_cc[K_NCCS];
|
||||
speed_t c_ispeed;
|
||||
speed_t c_ospeed;
|
||||
};
|
||||
#define BOTHER CBAUDEX
|
||||
|
||||
#endif
|
||||
|
||||
//#define DEBUG_SERIAL
|
||||
#ifdef DEBUG_SERIAL
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
std::fstream fs;
|
||||
#endif
|
||||
|
||||
#define KEEP_SENT 20
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
GCodeSender::GCodeSender()
|
||||
: io(), serial(io), can_send(false), sent(0), open(false), error(false),
|
||||
connected(false), queue_paused(false)
|
||||
{
|
||||
#ifdef DEBUG_SERIAL
|
||||
std::srand(std::time(nullptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
GCodeSender::~GCodeSender()
|
||||
{
|
||||
this->disconnect();
|
||||
}
|
||||
|
||||
bool
|
||||
GCodeSender::connect(std::string devname, unsigned int baud_rate)
|
||||
{
|
||||
this->disconnect();
|
||||
|
||||
this->set_error_status(false);
|
||||
try {
|
||||
this->serial.open(devname);
|
||||
|
||||
this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::odd));
|
||||
this->serial.set_option(boost::asio::serial_port_base::character_size(boost::asio::serial_port_base::character_size(8)));
|
||||
this->serial.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none));
|
||||
this->serial.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
|
||||
this->set_baud_rate(baud_rate);
|
||||
|
||||
this->serial.close();
|
||||
this->serial.open(devname);
|
||||
this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none));
|
||||
|
||||
// set baud rate again because set_option overwrote it
|
||||
this->set_baud_rate(baud_rate);
|
||||
this->open = true;
|
||||
this->reset();
|
||||
} catch (boost::system::system_error &) {
|
||||
this->set_error_status(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// a reset firmware expect line numbers to start again from 1
|
||||
this->sent = 0;
|
||||
this->last_sent.clear();
|
||||
|
||||
/* Initialize debugger */
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs.open("serial.txt", std::fstream::out | std::fstream::trunc);
|
||||
#endif
|
||||
|
||||
// this gives some work to the io_service before it is started
|
||||
// (post() runs the supplied function in its thread)
|
||||
this->io.post(boost::bind(&GCodeSender::do_read, this));
|
||||
|
||||
// start reading in the background thread
|
||||
boost::thread t(boost::bind(&boost::asio::io_service::run, &this->io));
|
||||
this->background_thread.swap(t);
|
||||
|
||||
// always send a M105 to check for connection because firmware might be silent on connect
|
||||
//FIXME Vojtech: This is being sent too early, leading to line number synchronization issues,
|
||||
// from which the GCodeSender never recovers.
|
||||
// this->send("M105", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::set_baud_rate(unsigned int baud_rate)
|
||||
{
|
||||
try {
|
||||
// This does not support speeds > 115200
|
||||
this->serial.set_option(boost::asio::serial_port_base::baud_rate(baud_rate));
|
||||
} catch (boost::system::system_error &) {
|
||||
boost::asio::serial_port::native_handle_type handle = this->serial.native_handle();
|
||||
|
||||
#if __APPLE__
|
||||
termios ios;
|
||||
::tcgetattr(handle, &ios);
|
||||
::cfsetspeed(&ios, baud_rate);
|
||||
speed_t newSpeed = baud_rate;
|
||||
ioctl(handle, IOSSIOSPEED, &newSpeed);
|
||||
::tcsetattr(handle, TCSANOW, &ios);
|
||||
#elif __linux__
|
||||
termios2 ios;
|
||||
if (ioctl(handle, TCGETS2, &ios))
|
||||
printf("Error in TCGETS2: %s\n", strerror(errno));
|
||||
ios.c_ispeed = ios.c_ospeed = baud_rate;
|
||||
ios.c_cflag &= ~CBAUD;
|
||||
ios.c_cflag |= BOTHER | CLOCAL | CREAD;
|
||||
ios.c_cc[VMIN] = 1; // Minimum of characters to read, prevents eof errors when 0 bytes are read
|
||||
ios.c_cc[VTIME] = 1;
|
||||
if (ioctl(handle, TCSETS2, &ios))
|
||||
printf("Error in TCSETS2: %s\n", strerror(errno));
|
||||
|
||||
#elif __OpenBSD__
|
||||
struct termios ios;
|
||||
::tcgetattr(handle, &ios);
|
||||
::cfsetspeed(&ios, baud_rate);
|
||||
if (::tcsetattr(handle, TCSAFLUSH, &ios) != 0)
|
||||
printf("Failed to set baud rate: %s\n", strerror(errno));
|
||||
#else
|
||||
//throw Slic3r::InvalidArgument("OS does not currently support custom bauds");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::disconnect()
|
||||
{
|
||||
if (!this->open) return;
|
||||
this->open = false;
|
||||
this->connected = false;
|
||||
this->io.post(boost::bind(&GCodeSender::do_close, this));
|
||||
this->background_thread.join();
|
||||
this->io.reset();
|
||||
/*
|
||||
if (this->error_status()) {
|
||||
throw(boost::system::system_error(boost::system::error_code(),
|
||||
"Error while closing the device"));
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs << "DISCONNECTED" << std::endl << std::flush;
|
||||
fs.close();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
GCodeSender::is_connected() const
|
||||
{
|
||||
return this->connected;
|
||||
}
|
||||
|
||||
bool
|
||||
GCodeSender::wait_connected(unsigned int timeout) const
|
||||
{
|
||||
using namespace boost::posix_time;
|
||||
ptime t0 = second_clock::local_time() + seconds(timeout);
|
||||
while (!this->connected) {
|
||||
if (second_clock::local_time() > t0) return false;
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t
|
||||
GCodeSender::queue_size() const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
return this->queue.size();
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::pause_queue()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
this->queue_paused = true;
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::resume_queue()
|
||||
{
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
this->queue_paused = false;
|
||||
}
|
||||
this->send();
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::purge_queue(bool priority)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
if (priority) {
|
||||
// clear priority queue
|
||||
std::list<std::string> empty;
|
||||
std::swap(this->priqueue, empty);
|
||||
} else {
|
||||
// clear queue
|
||||
std::queue<std::string> empty;
|
||||
std::swap(this->queue, empty);
|
||||
this->queue_paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
// purge log and return its contents
|
||||
std::vector<std::string>
|
||||
GCodeSender::purge_log()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->log_mutex);
|
||||
std::vector<std::string> retval;
|
||||
retval.reserve(this->log.size());
|
||||
while (!this->log.empty()) {
|
||||
retval.push_back(this->log.front());
|
||||
this->log.pop();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string
|
||||
GCodeSender::getT() const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->log_mutex);
|
||||
return this->T;
|
||||
}
|
||||
|
||||
std::string
|
||||
GCodeSender::getB() const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->log_mutex);
|
||||
return this->B;
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::do_close()
|
||||
{
|
||||
this->set_error_status(false);
|
||||
boost::system::error_code ec;
|
||||
this->serial.cancel(ec);
|
||||
if (ec) this->set_error_status(true);
|
||||
this->serial.close(ec);
|
||||
if (ec) this->set_error_status(true);
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::set_error_status(bool e)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->error_mutex);
|
||||
this->error = e;
|
||||
}
|
||||
|
||||
bool
|
||||
GCodeSender::error_status() const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->error_mutex);
|
||||
return this->error;
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::do_read()
|
||||
{
|
||||
// read one line
|
||||
boost::asio::async_read_until(
|
||||
this->serial,
|
||||
this->read_buffer,
|
||||
'\n',
|
||||
boost::bind(
|
||||
&GCodeSender::on_read,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::on_read(const boost::system::error_code& error,
|
||||
size_t bytes_transferred)
|
||||
{
|
||||
this->set_error_status(false);
|
||||
if (error) {
|
||||
#ifdef __APPLE__
|
||||
if (error.value() == 45) {
|
||||
// OS X bug: http://osdir.com/ml/lib.boost.asio.user/2008-08/msg00004.html
|
||||
this->do_read();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// printf("ERROR: [%d] %s\n", error.value(), error.message().c_str());
|
||||
// error can be true even because the serial port was closed.
|
||||
// In this case it is not a real error, so ignore.
|
||||
if (this->open) {
|
||||
this->do_close();
|
||||
this->set_error_status(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::istream is(&this->read_buffer);
|
||||
std::string line;
|
||||
std::getline(is, line);
|
||||
if (!line.empty()) {
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs << "<< " << line << std::endl << std::flush;
|
||||
#endif
|
||||
|
||||
// note that line might contain \r at its end
|
||||
// parse incoming line
|
||||
if (!this->connected
|
||||
&& (boost::starts_with(line, "start")
|
||||
|| boost::starts_with(line, "Grbl ")
|
||||
|| boost::starts_with(line, "ok")
|
||||
|| boost::contains(line, "T:"))) {
|
||||
this->connected = true;
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
this->can_send = true;
|
||||
}
|
||||
this->send();
|
||||
} else if (boost::starts_with(line, "ok")) {
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
this->can_send = true;
|
||||
}
|
||||
this->send();
|
||||
} else if (boost::istarts_with(line, "resend") // Marlin uses "Resend: "
|
||||
|| boost::istarts_with(line, "rs")) {
|
||||
// extract the first number from line
|
||||
boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
|
||||
size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs << "!! line num out of sync: toresend = " << toresend << ", sent = " << sent << ", last_sent.size = " << last_sent.size() << std::endl;
|
||||
#endif
|
||||
|
||||
if (toresend > this->sent - this->last_sent.size() && toresend <= this->sent) {
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
|
||||
const auto lines_to_resend = this->sent - toresend + 1;
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs << "!! resending " << lines_to_resend << " lines" << std::endl;
|
||||
#endif
|
||||
// move the unsent lines to priqueue
|
||||
this->priqueue.insert(
|
||||
this->priqueue.begin(), // insert at the beginning
|
||||
this->last_sent.begin() + this->last_sent.size() - lines_to_resend,
|
||||
this->last_sent.end()
|
||||
);
|
||||
|
||||
// we can empty last_sent because it's not useful anymore
|
||||
this->last_sent.clear();
|
||||
|
||||
// start resending with the requested line number
|
||||
this->sent = toresend - 1;
|
||||
this->can_send = true;
|
||||
}
|
||||
this->send();
|
||||
} else {
|
||||
printf("Cannot resend %zu (oldest we have is %zu)\n", toresend, this->sent - this->last_sent.size());
|
||||
}
|
||||
} else if (boost::starts_with(line, "wait")) {
|
||||
// ignore
|
||||
} else {
|
||||
// push any other line into the log
|
||||
boost::lock_guard<boost::mutex> l(this->log_mutex);
|
||||
this->log.push(line);
|
||||
}
|
||||
|
||||
// parse temperature info
|
||||
{
|
||||
size_t pos = line.find("T:");
|
||||
if (pos != std::string::npos && line.size() > pos + 2) {
|
||||
// we got temperature info
|
||||
boost::lock_guard<boost::mutex> l(this->log_mutex);
|
||||
this->T = line.substr(pos+2, line.find_first_not_of("0123456789.", pos+2) - (pos+2));
|
||||
|
||||
pos = line.find("B:");
|
||||
if (pos != std::string::npos && line.size() > pos + 2) {
|
||||
// we got bed temperature info
|
||||
this->B = line.substr(pos+2, line.find_first_not_of("0123456789.", pos+2) - (pos+2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this->do_read();
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::send(const std::vector<std::string> &lines, bool priority)
|
||||
{
|
||||
// append lines to queue
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
for (std::vector<std::string>::const_iterator line = lines.begin(); line != lines.end(); ++line) {
|
||||
if (priority) {
|
||||
this->priqueue.push_back(*line);
|
||||
} else {
|
||||
this->queue.push(*line);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->send();
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::send(const std::string &line, bool priority)
|
||||
{
|
||||
// append line to queue
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
if (priority) {
|
||||
this->priqueue.push_back(line);
|
||||
} else {
|
||||
this->queue.push(line);
|
||||
}
|
||||
}
|
||||
this->send();
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::send()
|
||||
{
|
||||
this->io.post(boost::bind(&GCodeSender::do_send, this));
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::do_send()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
|
||||
// printer is not connected or we're still waiting for the previous ack
|
||||
if (!this->can_send) return;
|
||||
|
||||
std::string line;
|
||||
while (!this->priqueue.empty() || (!this->queue.empty() && !this->queue_paused)) {
|
||||
if (!this->priqueue.empty()) {
|
||||
line = this->priqueue.front();
|
||||
this->priqueue.pop_front();
|
||||
} else {
|
||||
line = this->queue.front();
|
||||
this->queue.pop();
|
||||
}
|
||||
|
||||
// strip comments
|
||||
size_t comment_pos = line.find_first_of(';');
|
||||
if (comment_pos != std::string::npos)
|
||||
line.erase(comment_pos, std::string::npos);
|
||||
boost::algorithm::trim(line);
|
||||
|
||||
// if line is not empty, send it
|
||||
if (!line.empty()) break;
|
||||
// if line is empty, process next item in queue
|
||||
}
|
||||
if (line.empty()) return;
|
||||
|
||||
// compute full line
|
||||
++ this->sent;
|
||||
#ifndef DEBUG_SERIAL
|
||||
const auto line_num = this->sent;
|
||||
#else
|
||||
// In DEBUG_SERIAL mode, test line re-synchronization by sending bad line number 1/4 of the time
|
||||
const auto line_num = std::rand() < RAND_MAX/4 ? 0 : this->sent;
|
||||
#endif
|
||||
std::string full_line = "N" + boost::lexical_cast<std::string>(line_num) + " " + line;
|
||||
|
||||
// calculate checksum
|
||||
int cs = 0;
|
||||
for (std::string::const_iterator it = full_line.begin(); it != full_line.end(); ++it)
|
||||
cs = cs ^ *it;
|
||||
|
||||
// write line to device
|
||||
full_line += "*";
|
||||
full_line += boost::lexical_cast<std::string>(cs);
|
||||
full_line += "\n";
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs << ">> " << full_line << std::flush;
|
||||
#endif
|
||||
|
||||
this->last_sent.push_back(line);
|
||||
this->can_send = false;
|
||||
|
||||
while (this->last_sent.size() > KEEP_SENT) {
|
||||
this->last_sent.pop_front();
|
||||
}
|
||||
|
||||
// we can't supply boost::asio::buffer(full_line) to async_write() because full_line is on the
|
||||
// stack and the buffer would lose its underlying storage causing memory corruption
|
||||
std::ostream os(&this->write_buffer);
|
||||
os << full_line;
|
||||
boost::asio::async_write(this->serial, this->write_buffer, boost::bind(&GCodeSender::on_write, this, boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::on_write(const boost::system::error_code& error,
|
||||
size_t bytes_transferred)
|
||||
{
|
||||
this->set_error_status(false);
|
||||
if (error) {
|
||||
if (this->open) {
|
||||
this->do_close();
|
||||
this->set_error_status(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this->do_send();
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::set_DTR(bool on)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__SYMBIAN32__)
|
||||
boost::asio::serial_port_service::native_handle_type handle = this->serial.native_handle();
|
||||
if (on)
|
||||
EscapeCommFunction(handle, SETDTR);
|
||||
else
|
||||
EscapeCommFunction(handle, CLRDTR);
|
||||
#else
|
||||
int fd = this->serial.native_handle();
|
||||
int status;
|
||||
ioctl(fd, TIOCMGET, &status);
|
||||
if (on)
|
||||
status |= TIOCM_DTR;
|
||||
else
|
||||
status &= ~TIOCM_DTR;
|
||||
ioctl(fd, TIOCMSET, &status);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
GCodeSender::reset()
|
||||
{
|
||||
set_DTR(false);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
set_DTR(true);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
set_DTR(false);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
@@ -1,81 +0,0 @@
|
||||
#ifndef slic3r_GCodeSender_hpp_
|
||||
#define slic3r_GCodeSender_hpp_
|
||||
|
||||
#include "libslic3r.h"
|
||||
#include <queue>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/serial_port.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
namespace asio = boost::asio;
|
||||
|
||||
class GCodeSender : private boost::noncopyable {
|
||||
public:
|
||||
GCodeSender();
|
||||
~GCodeSender();
|
||||
bool connect(std::string devname, unsigned int baud_rate);
|
||||
void send(const std::vector<std::string> &lines, bool priority = false);
|
||||
void send(const std::string &s, bool priority = false);
|
||||
void disconnect();
|
||||
bool error_status() const;
|
||||
bool is_connected() const;
|
||||
bool wait_connected(unsigned int timeout = 3) const;
|
||||
size_t queue_size() const;
|
||||
void pause_queue();
|
||||
void resume_queue();
|
||||
void purge_queue(bool priority = false);
|
||||
std::vector<std::string> purge_log();
|
||||
std::string getT() const;
|
||||
std::string getB() const;
|
||||
void set_DTR(bool on);
|
||||
void reset();
|
||||
|
||||
private:
|
||||
asio::io_service io;
|
||||
asio::serial_port serial;
|
||||
boost::thread background_thread;
|
||||
boost::asio::streambuf read_buffer, write_buffer;
|
||||
bool open; // whether the serial socket is connected
|
||||
bool connected; // whether the printer is online
|
||||
bool error;
|
||||
mutable boost::mutex error_mutex;
|
||||
|
||||
// this mutex guards queue, priqueue, can_send, queue_paused, sent, last_sent
|
||||
mutable boost::mutex queue_mutex;
|
||||
std::queue<std::string> queue;
|
||||
std::list<std::string> priqueue;
|
||||
bool can_send;
|
||||
bool queue_paused;
|
||||
size_t sent;
|
||||
std::deque<std::string> last_sent;
|
||||
|
||||
// this mutex guards log, T, B
|
||||
mutable boost::mutex log_mutex;
|
||||
std::queue<std::string> log;
|
||||
std::string T, B;
|
||||
|
||||
void set_baud_rate(unsigned int baud_rate);
|
||||
void set_error_status(bool e);
|
||||
void do_send();
|
||||
void on_write(const boost::system::error_code& error, size_t bytes_transferred);
|
||||
void do_close();
|
||||
void do_read();
|
||||
void on_read(const boost::system::error_code& error, size_t bytes_transferred);
|
||||
void send();
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_GCodeSender_hpp_ */
|
||||
@@ -94,6 +94,8 @@ struct Circle {
|
||||
|
||||
using Circlef = Circle<Vec2f>;
|
||||
using Circled = Circle<Vec2d>;
|
||||
using CircleSqf = CircleSq<Vec2f>;
|
||||
using CircleSqd = CircleSq<Vec2d>;
|
||||
|
||||
/// Find the center of the circle corresponding to the vector of Points as an arc.
|
||||
Point circle_center_taubin_newton(const Points::const_iterator& input_start, const Points::const_iterator& input_end, size_t cycles = 20);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include "MedialAxis.hpp"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/polygon/polygon.hpp>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
@@ -154,12 +154,13 @@ template<class ExecutionPolicy, class Enable = void> struct _Loop
|
||||
};
|
||||
|
||||
// Add Specialization for using ExecutionTBB for parallel loops.
|
||||
template<> struct _Loop<Slic3r::ExecutionTBB>
|
||||
using namespace Slic3r;
|
||||
template<> struct _Loop<ExecutionTBB>
|
||||
{
|
||||
template<class It, class Fn> static void for_each_idx(It from, It to, Fn&& fn)
|
||||
{
|
||||
Slic3r::execution::for_each(
|
||||
Slic3r::ex_tbb, size_t(0), size_t(to - from), [&from, &fn](size_t i) { fn(from[i], i); }, Slic3r::execution::max_concurrency(Slic3r::ex_tbb));
|
||||
execution::for_each(
|
||||
ex_tbb, size_t(0), size_t(to - from), [&from, &fn](size_t i) { fn(from[i], i); }, execution::max_concurrency(ex_tbb));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "Format/AssimpImport.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Exception.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "ModelArrange.hpp"
|
||||
#include "Arrange.hpp"
|
||||
#include "Geometry.hpp"
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "TriangleMesh.hpp"
|
||||
#include "CustomGCode.hpp"
|
||||
#include "calib.hpp"
|
||||
#include "enum_bitmask.hpp"
|
||||
#include "TextConfiguration.hpp"
|
||||
#include "EmbossShape.hpp"
|
||||
#include "TriangleSelector.hpp"
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
using TColor = typename PixelRenderer::color_type;
|
||||
using TValue = typename TColor::value_type;
|
||||
using TPixel = typename PixelRenderer::pixel_type;
|
||||
using TRawBuffer = agg::rendering_buffer;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include "TDataStd_Name.hxx"
|
||||
#include "BRepBuilderAPI_Transform.hxx"
|
||||
#include "TopExp_Explorer.hxx"
|
||||
#include "TopExp_Explorer.hxx"
|
||||
#include "BRep_Tool.hxx"
|
||||
#include "Font_BRepFont.hxx"
|
||||
#include "Font_BRepTextBuilder.hxx"
|
||||
|
||||
@@ -17,6 +17,9 @@ typedef std::vector<Color> ColorList;
|
||||
typedef std::array<double, 3> ColorDouble;
|
||||
typedef std::array<std::size_t, 3> RGB;
|
||||
|
||||
// Function pointer type that points to a specific color-difference function based on the chosen method.
|
||||
using DistanceFunction = double (*)(const Color&, const Color&);
|
||||
|
||||
// Color space used for computing color differences.
|
||||
enum struct ColorDifferenceMethod : std::size_t {
|
||||
RGB = 0, // Simplest and fastest
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
namespace Slic3r { namespace tex2color {
|
||||
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
|
||||
// Default upper bound on the number of half-edges in any single boundary cycle
|
||||
// that CloseBoundariesAndRepairManifoldness will attempt to triangulate. The
|
||||
// cost of triangulate_hole grows non-linearly with cycle length, so this caps
|
||||
@@ -58,7 +60,6 @@ struct BoundaryEdgeStats
|
||||
// any pre-processing (e.g. stitch_borders) needed for the count to be meaningful.
|
||||
inline BoundaryEdgeStats ComputeBoundaryEdgeStats(const cgalutils::CGALMesh& cgal_mesh)
|
||||
{
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
using CGALMesh = cgalutils::CGALMesh;
|
||||
using HalfedgeDescriptor = boost::graph_traits<CGALMesh>::halfedge_descriptor;
|
||||
|
||||
@@ -85,7 +86,6 @@ inline BoundaryEdgeStats ComputeBoundaryEdgeStats(const cgalutils::CGALMesh& cga
|
||||
// boundary statistics; entering this function always triggers triangulation.
|
||||
inline void CloseBoundariesAndRepairManifoldness(cgalutils::CGALMesh& cgal_mesh)
|
||||
{
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
using CGALMesh = cgalutils::CGALMesh;
|
||||
using HalfedgeDescriptor = boost::graph_traits<CGALMesh>::halfedge_descriptor;
|
||||
using FaceDescriptor = boost::graph_traits<CGALMesh>::face_descriptor;
|
||||
@@ -111,7 +111,6 @@ inline bool RepairMesh(const TriMesh& mesh,
|
||||
AlgoCancelCallback cancel_callback = nullptr,
|
||||
const RepairSetting& setting = RepairSetting{})
|
||||
{
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
using Clock = std::chrono::steady_clock;
|
||||
auto elapsed_ms = [](Clock::time_point t0) {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(Clock::now() - t0).count();
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include <initializer_list>
|
||||
#include <string_view>
|
||||
#include <regex>
|
||||
#include <string_view>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
@@ -432,6 +432,8 @@ inline IntegerOnly<I, I> fast_round_up(double a)
|
||||
return a == 0.49999999999999994 ? I(0) : I(floor(a + 0.5));
|
||||
}
|
||||
|
||||
template<class T> using SamePair = std::pair<T, T>;
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
@@ -30,7 +29,6 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
|
||||
@@ -19,20 +19,17 @@
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/tglbtn.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/panel.h>
|
||||
@@ -36,14 +35,12 @@
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/tglbtn.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/webrequest.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "Jobs/ProgressIndicator.hpp"
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <wx/string.h>
|
||||
#include "Jobs/ProgressIndicator.hpp"
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <wx/hyperlink.h>
|
||||
|
||||
#include "Jobs/ProgressIndicator.hpp"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <wx/hyperlink.h>
|
||||
|
||||
#include "Jobs/ProgressIndicator.hpp"
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <wx/string.h>
|
||||
#include <wx/toplevel.h>
|
||||
#include <wx/timer.h>
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "CapsuleButton.hpp"
|
||||
|
||||
namespace Slic3r::GUI { struct IntEvent; }
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/Polygon.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Jobs/BoostThreadWorker.hpp"
|
||||
#include "Jobs/PlaterWorker.hpp"
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/Utils/Bonjour.hpp"
|
||||
|
||||
#include "slic3r/GUI/Widgets/DialogButtons.hpp"
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
@@ -24,7 +23,6 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// #include "libslic3r/GCodeSender.hpp"
|
||||
#include "ConfigManipulation.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
@@ -198,3 +198,6 @@ template<> struct std::hash<NozzleDef>
|
||||
return h1 ^ (h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2));
|
||||
};
|
||||
};
|
||||
|
||||
// key(extruder_id) -> { key1(nozzle type info), val1( number of the nozzle type)}
|
||||
using ExtruderNozzleInfos = std::unordered_map<int, std::unordered_map<NozzleDef, int>>;
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#include <wx/string.h>
|
||||
#include <wx/colour.h>
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "GUI_App.hpp"
|
||||
#include "DeviceErrorDialog.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "ReleaseNote.hpp"
|
||||
#include <string>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
@@ -183,10 +183,13 @@ wxDECLARE_EVENT(EVT_GLCANVAS_PLATE_NAME_CHANGE, SimpleEvent);
|
||||
//BBS: declare EVT_GLCANVAS_PLATE_SELECT
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_PLATE_SELECT, SimpleEvent);
|
||||
|
||||
using Vec2dEvent = Event<Vec2d>;
|
||||
// _bool_ value is used as a indicator of selection in the 3DScene
|
||||
using RBtnEvent = Event<std::pair<Vec2d, bool>>;
|
||||
using RBtnPlateEvent = Event<std::pair<Vec2d, int>>;
|
||||
template <size_t N> using Vec2dsEvent = ArrayEvent<Vec2d, N>;
|
||||
|
||||
using Vec3dEvent = Event<Vec3d>;
|
||||
template <size_t N> using Vec3dsEvent = ArrayEvent<Vec3d, N>;
|
||||
|
||||
using HeightProfileSmoothEvent = Event<HeightProfileSmoothingParams>;
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#include "nanosvg/nanosvgrast.h"
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <wx/dcgraph.h>
|
||||
#include <wx/dcmemory.h>
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include "AboutDialog.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "format.hpp"
|
||||
|
||||
#include "WebUserLoginDialog.hpp"
|
||||
|
||||
|
||||
@@ -172,12 +172,10 @@
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/I18N.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/InstanceLock.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "libslic3r/miniz_extension.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "slic3r/plugin/PluginManager.hpp"
|
||||
#include "slic3r/plugin/host/PluginHostUi.hpp"
|
||||
#include "slic3r/plugin/PythonInterpreter.hpp"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
#include <nanosvg/nanosvg.h>
|
||||
#include <nanosvg/nanosvgrast.h>
|
||||
#include "OpenGLManager.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
@@ -113,7 +113,6 @@
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Notebook.hpp"
|
||||
#include "GUI_Factories.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
#include "MarkdownTip.hpp"
|
||||
#include "NetworkTestDialog.hpp"
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
#include "MainFrame.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "Plater.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "MainFrame.hpp"
|
||||
#include "MediaPlayCtrl.h"
|
||||
#include "MediaFilePanel.h"
|
||||
#include "Plater.hpp"
|
||||
#include "BindDialog.hpp"
|
||||
|
||||
#include "DeviceCore/DevManager.h"
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/panel.h>
|
||||
@@ -31,14 +30,12 @@
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/tglbtn.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/webrequest.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "libslic3r_version.h"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
|
||||
@@ -54,6 +54,7 @@ struct Option {
|
||||
Option(const ConfigOptionDef& _opt, t_config_option_key id) :
|
||||
opt(_opt), opt_id(id) {}
|
||||
};
|
||||
using t_option = std::unique_ptr<Option>; //!
|
||||
|
||||
/// Represents option lines
|
||||
class Line : public UndoValueUIManager
|
||||
|
||||
@@ -108,6 +108,7 @@ class PlaterPresetComboBox;
|
||||
class PartPlateList;
|
||||
class SyncNozzleAndAmsDialog;
|
||||
class FinishSyncAmsDialog;
|
||||
using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>;
|
||||
|
||||
class Plater;
|
||||
enum class ActionButtonType : int;
|
||||
@@ -324,6 +325,7 @@ private:
|
||||
class Plater: public wxPanel
|
||||
{
|
||||
public:
|
||||
using fs_path = boost::filesystem::path;
|
||||
|
||||
Plater(wxWindow *parent, MainFrame *main_frame);
|
||||
Plater(Plater &&) = delete;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "MainFrame.hpp"
|
||||
#include <miniz.h>
|
||||
#include <OrcaCloudServiceAgent.hpp>
|
||||
#include <wx/event.h>
|
||||
#include <wx/utils.h>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
#include "libslic3r_version.h"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/Widgets/Button.hpp"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "Jobs/ProgressIndicator.hpp"
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
@@ -32,10 +31,8 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/hyperlink.h>
|
||||
#include <wx/richtext/richtextctrl.h>
|
||||
|
||||
#include "AmsMappingPopup.hpp"
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
@@ -38,7 +37,6 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
#include <wx/srchctrl.h>
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
@@ -29,7 +28,6 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
#include <wx/srchctrl.h>
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
@@ -33,7 +32,6 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
#include <wx/srchctrl.h>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// #include "libslic3r/GCodeSender.hpp"
|
||||
//#include "slic3r/Utils/Serial.hpp"
|
||||
#include "Tab.hpp"
|
||||
#include "PresetHints.hpp"
|
||||
@@ -102,8 +101,6 @@
|
||||
#include "Widgets/MultiNozzleSync.hpp"
|
||||
#include "Widgets/SwitchButton.hpp"
|
||||
#include "Widgets/TabCtrl.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
#include "Search.hpp"
|
||||
#include "BedShapeDialog.hpp"
|
||||
#include "libslic3r/GCode/Thumbnails.hpp"
|
||||
#include "WipeTowerDialog.hpp"
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include "../GUI/DeviceCore/DevConfig.h"
|
||||
#include "../GUI/DeviceCore/DevExtruderSystem.h"
|
||||
#include "../GUI/DeviceCore/DevManager.h"
|
||||
#include "../GUI/DeviceCore/DevStorage.h"
|
||||
#include "libslic3r/FlushVolCalc.hpp"
|
||||
#include "../GUI/Plater.hpp"
|
||||
#include <memory>
|
||||
#include "slic3r/GUI/Jobs/Worker.hpp"
|
||||
|
||||
@@ -365,7 +365,6 @@ void StyleManager::init_trunc_names(float max_width) {
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
|
||||
// for get DPI
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/MainFrame.hpp"
|
||||
#include "slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp"
|
||||
|
||||
@@ -554,8 +553,6 @@ bool StyleManager::set_wx_font(const wxFont &wx_font, std::unique_ptr<FontFile>
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <libslic3r/AppConfig.hpp>
|
||||
#include "WxFontUtils.hpp"
|
||||
#include "fast_float/fast_float.h"
|
||||
|
||||
// StylesSerializable
|
||||
|
||||
@@ -89,6 +89,7 @@ using fn_ft_job_get_result = ft_err(FT_CALL *)(FT_JobHandle *, uint32_t timeo
|
||||
using fn_ft_tunnel_start_job = ft_err(FT_CALL *)(FT_TunnelHandle *, FT_JobHandle *);
|
||||
using fn_ft_job_cancel = ft_err(FT_CALL *)(FT_JobHandle *);
|
||||
|
||||
using fn_ft_job_msg_destroy = void(FT_CALL *)(ft_job_msg *);
|
||||
using fn_ft_job_set_msg_cb = ft_err(FT_CALL *)(FT_JobHandle *, void(FT_CALL *)(void *user, ft_job_msg msg), void *user);
|
||||
using fn_ft_job_try_get_msg = ft_err(FT_CALL *)(FT_JobHandle *, ft_job_msg *out_msg);
|
||||
using fn_ft_job_get_msg = ft_err(FT_CALL *)(FT_JobHandle *, uint32_t timeout_ms, ft_job_msg *out_msg);
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/UpdateDialogs.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/GUI/NotificationManager.hpp"
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
namespace Slic3r {
|
||||
namespace Utils {
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
// Generic command / response TCP telnet like console class.
|
||||
// Used by the MKS host to send G-code commands to test connection ("M105") and to start printing ("M23 filename", "M24").
|
||||
class TCPConsole
|
||||
{
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
|
||||
public:
|
||||
TCPConsole() : m_resolver(m_io_context), m_socket(m_io_context) { set_defaults(); }
|
||||
TCPConsole(const std::string& host_name, const std::string& port_name) : m_resolver(m_io_context), m_socket(m_io_context)
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
namespace beast = boost::beast; // from <boost/beast.hpp>
|
||||
namespace http = beast::http; // from <boost/beast/http.hpp>
|
||||
namespace websocket = beast::websocket; // from <boost/beast/websocket.hpp>
|
||||
namespace net = boost::asio; // from <boost/asio.hpp>
|
||||
using tcp = net::ip::tcp; // from <boost/asio/ip/tcp.hpp>
|
||||
|
||||
class WebSocketClient {
|
||||
public:
|
||||
@@ -31,7 +36,7 @@ public:
|
||||
}
|
||||
try {
|
||||
// Close the WebSocket connection
|
||||
ws_.close(boost::beast::websocket::close_code::normal);
|
||||
ws_.close(websocket::close_code::normal);
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
@@ -44,7 +49,7 @@ public:
|
||||
auto const results = resolver_.resolve(host, port);
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
auto ep = boost::asio::connect(ws_.next_layer(), results);
|
||||
auto ep = net::connect(ws_.next_layer(), results);
|
||||
std::string _host = host;
|
||||
//if _host last char is '/', remove it
|
||||
if(_host.size()>0&&_host[host.size()-1] == '/'){
|
||||
@@ -53,10 +58,10 @@ public:
|
||||
|
||||
// _host += ':' + std::to_string(ep.port());
|
||||
// Set a decorator to change the User-Agent of the handshake
|
||||
ws_.set_option(boost::beast::websocket::stream_base::decorator(
|
||||
[](boost::beast::websocket::request_type& req)
|
||||
ws_.set_option(websocket::stream_base::decorator(
|
||||
[](websocket::request_type& req)
|
||||
{
|
||||
req.set(boost::beast::http::field::user_agent,"ElegooSlicer");
|
||||
req.set(http::field::user_agent,"ElegooSlicer");
|
||||
}));
|
||||
// Perform the WebSocket handshake
|
||||
ws_.handshake(_host, path);
|
||||
@@ -65,25 +70,25 @@ public:
|
||||
|
||||
void send(const std::string& message){
|
||||
// Send a message
|
||||
ws_.write(boost::asio::buffer(message));
|
||||
ws_.write(net::buffer(message));
|
||||
}
|
||||
|
||||
std::string receive(int timeout = 0){
|
||||
// This buffer will hold the incoming message
|
||||
boost::beast::flat_buffer buffer;
|
||||
beast::flat_buffer buffer;
|
||||
|
||||
// Read a message into our buffer
|
||||
ws_.read(buffer);
|
||||
|
||||
// Return the message as a string
|
||||
return boost::beast::buffers_to_string(buffer.data());
|
||||
return beast::buffers_to_string(buffer.data());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
boost::asio::io_context ioc_;
|
||||
boost::asio::ip::tcp::resolver resolver_;
|
||||
boost::beast::websocket::stream<boost::asio::ip::tcp::socket> ws_;
|
||||
net::io_context ioc_;
|
||||
tcp::resolver resolver_;
|
||||
websocket::stream<tcp::socket> ws_;
|
||||
bool is_connect;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,18 +17,20 @@
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
// Put serializers in correct ADL namespaces for each type
|
||||
|
||||
namespace Slic3r {
|
||||
namespace FilamentGroupUtils {
|
||||
|
||||
inline void to_json(nlohmann::json& j, const Color& c) {
|
||||
inline void to_json(json& j, const Color& c) {
|
||||
char buf[10];
|
||||
snprintf(buf, sizeof(buf), "#%02X%02X%02X%02X", c.r, c.g, c.b, c.a);
|
||||
j = std::string(buf);
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, Color& c) {
|
||||
inline void from_json(const json& j, Color& c) {
|
||||
std::string s = j.get<std::string>();
|
||||
if (s.size() >= 7 && s[0] == '#') {
|
||||
c.r = (unsigned char)std::stoi(s.substr(1, 2), nullptr, 16);
|
||||
@@ -38,8 +40,8 @@ inline void from_json(const nlohmann::json& j, Color& c) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void to_json(nlohmann::json& j, const FilamentInfo& fi) {
|
||||
j = nlohmann::json{
|
||||
inline void to_json(json& j, const FilamentInfo& fi) {
|
||||
j = json{
|
||||
{"color", fi.color},
|
||||
{"type", fi.type},
|
||||
{"is_support", fi.is_support},
|
||||
@@ -47,15 +49,15 @@ inline void to_json(nlohmann::json& j, const FilamentInfo& fi) {
|
||||
};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentInfo& fi) {
|
||||
inline void from_json(const json& j, FilamentInfo& fi) {
|
||||
fi.color = j.at("color").get<Color>();
|
||||
j.at("type").get_to(fi.type);
|
||||
j.at("is_support").get_to(fi.is_support);
|
||||
fi.usage_type = (FilamentUsageType)j.at("usage_type").get<int>();
|
||||
}
|
||||
|
||||
inline void to_json(nlohmann::json& j, const MachineFilamentInfo& mfi) {
|
||||
j = nlohmann::json{
|
||||
inline void to_json(json& j, const MachineFilamentInfo& mfi) {
|
||||
j = json{
|
||||
{"color", mfi.color},
|
||||
{"type", mfi.type},
|
||||
{"is_support", mfi.is_support},
|
||||
@@ -65,7 +67,7 @@ inline void to_json(nlohmann::json& j, const MachineFilamentInfo& mfi) {
|
||||
};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, MachineFilamentInfo& mfi) {
|
||||
inline void from_json(const json& j, MachineFilamentInfo& mfi) {
|
||||
mfi.color = j.at("color").get<Color>();
|
||||
j.at("type").get_to(mfi.type);
|
||||
j.at("is_support").get_to(mfi.is_support);
|
||||
@@ -78,8 +80,8 @@ inline void from_json(const nlohmann::json& j, MachineFilamentInfo& mfi) {
|
||||
|
||||
namespace MultiNozzleUtils {
|
||||
|
||||
inline void to_json(nlohmann::json& j, const NozzleInfo& ni) {
|
||||
j = nlohmann::json{
|
||||
inline void to_json(json& j, const NozzleInfo& ni) {
|
||||
j = json{
|
||||
{"diameter", ni.diameter},
|
||||
{"volume_type", (int)ni.volume_type},
|
||||
{"extruder_id", ni.extruder_id},
|
||||
@@ -87,15 +89,15 @@ inline void to_json(nlohmann::json& j, const NozzleInfo& ni) {
|
||||
};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, NozzleInfo& ni) {
|
||||
inline void from_json(const json& j, NozzleInfo& ni) {
|
||||
j.at("diameter").get_to(ni.diameter);
|
||||
ni.volume_type = (NozzleVolumeType)j.at("volume_type").get<int>();
|
||||
j.at("extruder_id").get_to(ni.extruder_id);
|
||||
j.at("group_id").get_to(ni.group_id);
|
||||
}
|
||||
|
||||
inline void to_json(nlohmann::json& j, const FilamentChangeTimeParams& p) {
|
||||
j = nlohmann::json{
|
||||
inline void to_json(json& j, const FilamentChangeTimeParams& p) {
|
||||
j = json{
|
||||
{"selector_load_time", p.selector_load_time},
|
||||
{"selector_unload_time", p.selector_unload_time},
|
||||
{"standard_load_time", p.standard_load_time},
|
||||
@@ -103,7 +105,7 @@ inline void to_json(nlohmann::json& j, const FilamentChangeTimeParams& p) {
|
||||
};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentChangeTimeParams& p) {
|
||||
inline void from_json(const json& j, FilamentChangeTimeParams& p) {
|
||||
j.at("selector_load_time").get_to(p.selector_load_time);
|
||||
j.at("selector_unload_time").get_to(p.selector_unload_time);
|
||||
j.at("standard_load_time").get_to(p.standard_load_time);
|
||||
@@ -114,22 +116,22 @@ inline void from_json(const nlohmann::json& j, FilamentChangeTimeParams& p) {
|
||||
|
||||
// ============ Helper: set<int> as JSON array ============
|
||||
namespace FGTestDetail {
|
||||
inline nlohmann::json set_to_json(const std::set<int>& s) {
|
||||
return nlohmann::json(std::vector<int>(s.begin(), s.end()));
|
||||
inline json set_to_json(const std::set<int>& s) {
|
||||
return json(std::vector<int>(s.begin(), s.end()));
|
||||
}
|
||||
|
||||
inline std::set<int> json_to_set(const nlohmann::json& j) {
|
||||
inline std::set<int> json_to_set(const json& j) {
|
||||
auto v = j.get<std::vector<int>>();
|
||||
return std::set<int>(v.begin(), v.end());
|
||||
}
|
||||
|
||||
inline nlohmann::json nvt_set_to_json(const std::set<NozzleVolumeType>& s) {
|
||||
inline json nvt_set_to_json(const std::set<NozzleVolumeType>& s) {
|
||||
std::vector<int> v;
|
||||
for (auto t : s) v.push_back((int)t);
|
||||
return nlohmann::json(v);
|
||||
return json(v);
|
||||
}
|
||||
|
||||
inline std::set<NozzleVolumeType> json_to_nvt_set(const nlohmann::json& j) {
|
||||
inline std::set<NozzleVolumeType> json_to_nvt_set(const json& j) {
|
||||
std::set<NozzleVolumeType> s;
|
||||
for (auto& item : j) s.insert((NozzleVolumeType)item.get<int>());
|
||||
return s;
|
||||
@@ -137,28 +139,28 @@ inline std::set<NozzleVolumeType> json_to_nvt_set(const nlohmann::json& j) {
|
||||
} // namespace FGTestDetail
|
||||
|
||||
// ============ FilamentGroupContext::ModelInfo ============
|
||||
inline void to_json(nlohmann::json& j, const FilamentGroupContext::ModelInfo& mi) {
|
||||
inline void to_json(json& j, const FilamentGroupContext::ModelInfo& mi) {
|
||||
using namespace FGTestDetail;
|
||||
j["flush_matrix"] = mi.flush_matrix;
|
||||
j["layer_filaments"] = mi.layer_filaments;
|
||||
|
||||
j["filament_info"] = nlohmann::json::array();
|
||||
j["filament_info"] = json::array();
|
||||
for (auto& fi : mi.filament_info)
|
||||
j["filament_info"].push_back(fi);
|
||||
|
||||
j["filament_ids"] = mi.filament_ids;
|
||||
|
||||
j["unprintable_filaments"] = nlohmann::json::array();
|
||||
j["unprintable_filaments"] = json::array();
|
||||
for (auto& s : mi.unprintable_filaments)
|
||||
j["unprintable_filaments"].push_back(set_to_json(s));
|
||||
|
||||
nlohmann::json uv = nlohmann::json::object();
|
||||
json uv = json::object();
|
||||
for (auto& [fil, types] : mi.unprintable_volumes)
|
||||
uv[std::to_string(fil)] = nvt_set_to_json(types);
|
||||
j["unprintable_volumes"] = uv;
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentGroupContext::ModelInfo& mi) {
|
||||
inline void from_json(const json& j, FilamentGroupContext::ModelInfo& mi) {
|
||||
using namespace FGTestDetail;
|
||||
j.at("flush_matrix").get_to(mi.flush_matrix);
|
||||
j.at("layer_filaments").get_to(mi.layer_filaments);
|
||||
@@ -181,8 +183,8 @@ inline void from_json(const nlohmann::json& j, FilamentGroupContext::ModelInfo&
|
||||
}
|
||||
|
||||
// ============ FilamentGroupContext::GroupInfo ============
|
||||
inline void to_json(nlohmann::json& j, const FilamentGroupContext::GroupInfo& gi) {
|
||||
j = nlohmann::json{
|
||||
inline void to_json(json& j, const FilamentGroupContext::GroupInfo& gi) {
|
||||
j = json{
|
||||
{"total_filament_num", gi.total_filament_num},
|
||||
{"max_gap_threshold", gi.max_gap_threshold},
|
||||
{"mode", (int)gi.mode},
|
||||
@@ -193,7 +195,7 @@ inline void to_json(nlohmann::json& j, const FilamentGroupContext::GroupInfo& gi
|
||||
};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentGroupContext::GroupInfo& gi) {
|
||||
inline void from_json(const json& j, FilamentGroupContext::GroupInfo& gi) {
|
||||
j.at("total_filament_num").get_to(gi.total_filament_num);
|
||||
j.at("max_gap_threshold").get_to(gi.max_gap_threshold);
|
||||
gi.mode = (FGMode)j.at("mode").get<int>();
|
||||
@@ -204,12 +206,12 @@ inline void from_json(const nlohmann::json& j, FilamentGroupContext::GroupInfo&
|
||||
}
|
||||
|
||||
// ============ FilamentGroupContext::MachineInfo ============
|
||||
inline void to_json(nlohmann::json& j, const FilamentGroupContext::MachineInfo& mi) {
|
||||
inline void to_json(json& j, const FilamentGroupContext::MachineInfo& mi) {
|
||||
j["max_group_size"] = mi.max_group_size;
|
||||
|
||||
j["machine_filament_info"] = nlohmann::json::array();
|
||||
j["machine_filament_info"] = json::array();
|
||||
for (auto& vec : mi.machine_filament_info) {
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
json arr = json::array();
|
||||
for (auto& mfi : vec) arr.push_back(mfi);
|
||||
j["machine_filament_info"].push_back(arr);
|
||||
}
|
||||
@@ -218,7 +220,7 @@ inline void to_json(nlohmann::json& j, const FilamentGroupContext::MachineInfo&
|
||||
j["master_extruder_id"] = mi.master_extruder_id;
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentGroupContext::MachineInfo& mi) {
|
||||
inline void from_json(const json& j, FilamentGroupContext::MachineInfo& mi) {
|
||||
j.at("max_group_size").get_to(mi.max_group_size);
|
||||
|
||||
mi.machine_filament_info.clear();
|
||||
@@ -234,10 +236,10 @@ inline void from_json(const nlohmann::json& j, FilamentGroupContext::MachineInfo
|
||||
}
|
||||
|
||||
// ============ FilamentGroupContext::SpeedInfo ============
|
||||
inline void to_json(nlohmann::json& j, const FilamentGroupContext::SpeedInfo& si) {
|
||||
nlohmann::json fpt = nlohmann::json::object();
|
||||
inline void to_json(json& j, const FilamentGroupContext::SpeedInfo& si) {
|
||||
json fpt = json::object();
|
||||
for (auto& [fil, inner] : si.filament_print_time) {
|
||||
nlohmann::json inner_j = nlohmann::json::object();
|
||||
json inner_j = json::object();
|
||||
for (auto& [layer, time] : inner)
|
||||
inner_j[std::to_string(layer)] = time;
|
||||
fpt[std::to_string(fil)] = inner_j;
|
||||
@@ -250,7 +252,7 @@ inline void to_json(nlohmann::json& j, const FilamentGroupContext::SpeedInfo& si
|
||||
j["ams_preload_enabled"] = si.ams_preload_enabled;
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentGroupContext::SpeedInfo& si) {
|
||||
inline void from_json(const json& j, FilamentGroupContext::SpeedInfo& si) {
|
||||
si.filament_print_time.clear();
|
||||
if (j.contains("filament_print_time")) {
|
||||
for (auto& [k, v] : j.at("filament_print_time").items()) {
|
||||
@@ -267,23 +269,23 @@ inline void from_json(const nlohmann::json& j, FilamentGroupContext::SpeedInfo&
|
||||
}
|
||||
|
||||
// ============ FilamentGroupContext::NozzleInfo ============
|
||||
inline void to_json(nlohmann::json& j, const FilamentGroupContext::NozzleInfo& ni) {
|
||||
nlohmann::json enl = nlohmann::json::object();
|
||||
inline void to_json(json& j, const FilamentGroupContext::NozzleInfo& ni) {
|
||||
json enl = json::object();
|
||||
for (auto& [ext, nozzles] : ni.extruder_nozzle_list)
|
||||
enl[std::to_string(ext)] = nozzles;
|
||||
j["extruder_nozzle_list"] = enl;
|
||||
|
||||
j["nozzle_list"] = nlohmann::json::array();
|
||||
j["nozzle_list"] = json::array();
|
||||
for (auto& n : ni.nozzle_list)
|
||||
j["nozzle_list"].push_back(n);
|
||||
|
||||
nlohmann::json ns = nlohmann::json::object();
|
||||
json ns = json::object();
|
||||
for (auto& [noz, fil] : ni.nozzle_status)
|
||||
ns[std::to_string(noz)] = fil;
|
||||
j["nozzle_status"] = ns;
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentGroupContext::NozzleInfo& ni) {
|
||||
inline void from_json(const json& j, FilamentGroupContext::NozzleInfo& ni) {
|
||||
ni.extruder_nozzle_list.clear();
|
||||
for (auto& [k, v] : j.at("extruder_nozzle_list").items())
|
||||
ni.extruder_nozzle_list[std::stoi(k)] = v.get<std::vector<int>>();
|
||||
@@ -300,8 +302,8 @@ inline void from_json(const nlohmann::json& j, FilamentGroupContext::NozzleInfo&
|
||||
}
|
||||
|
||||
// ============ Full FilamentGroupContext ============
|
||||
inline void to_json(nlohmann::json& j, const FilamentGroupContext& ctx) {
|
||||
nlohmann::json mi, gi, mai, si, ni;
|
||||
inline void to_json(json& j, const FilamentGroupContext& ctx) {
|
||||
json mi, gi, mai, si, ni;
|
||||
to_json(mi, ctx.model_info);
|
||||
to_json(gi, ctx.group_info);
|
||||
to_json(mai, ctx.machine_info);
|
||||
@@ -314,7 +316,7 @@ inline void to_json(nlohmann::json& j, const FilamentGroupContext& ctx) {
|
||||
j["nozzle_info"] = ni;
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, FilamentGroupContext& ctx) {
|
||||
inline void from_json(const json& j, FilamentGroupContext& ctx) {
|
||||
from_json(j.at("model_info"), ctx.model_info);
|
||||
from_json(j.at("group_info"), ctx.group_info);
|
||||
from_json(j.at("machine_info"), ctx.machine_info);
|
||||
@@ -334,11 +336,11 @@ struct TestMetadata {
|
||||
int seed = 0;
|
||||
};
|
||||
|
||||
inline void to_json(nlohmann::json& j, const TestMetadata& m) {
|
||||
j = nlohmann::json{{"id", m.id}, {"config_type", m.config_type}, {"seed", m.seed}};
|
||||
inline void to_json(json& j, const TestMetadata& m) {
|
||||
j = json{{"id", m.id}, {"config_type", m.config_type}, {"seed", m.seed}};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, TestMetadata& m) {
|
||||
inline void from_json(const json& j, TestMetadata& m) {
|
||||
j.at("id").get_to(m.id);
|
||||
j.at("config_type").get_to(m.config_type);
|
||||
j.at("seed").get_to(m.seed);
|
||||
@@ -352,8 +354,8 @@ struct TestResult {
|
||||
std::vector<std::string> violations;
|
||||
};
|
||||
|
||||
inline void to_json(nlohmann::json& j, const TestResult& r) {
|
||||
j = nlohmann::json{
|
||||
inline void to_json(json& j, const TestResult& r) {
|
||||
j = json{
|
||||
{"filament_map", r.filament_map},
|
||||
{"flush_cost", r.flush_cost},
|
||||
{"elapsed_ms", r.elapsed_ms},
|
||||
@@ -362,7 +364,7 @@ inline void to_json(nlohmann::json& j, const TestResult& r) {
|
||||
};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, TestResult& r) {
|
||||
inline void from_json(const json& j, TestResult& r) {
|
||||
j.at("filament_map").get_to(r.filament_map);
|
||||
j.at("flush_cost").get_to(r.flush_cost);
|
||||
j.at("elapsed_ms").get_to(r.elapsed_ms);
|
||||
@@ -378,15 +380,15 @@ struct BaseResult {
|
||||
bool constraints_ok = true;
|
||||
};
|
||||
|
||||
inline void to_json(nlohmann::json& j, const BaseResult& g) {
|
||||
j = nlohmann::json{
|
||||
inline void to_json(json& j, const BaseResult& g) {
|
||||
j = json{
|
||||
{"full_score", g.full_score},
|
||||
{"flush_cost", g.flush_cost},
|
||||
{"constraints_ok", g.constraints_ok}
|
||||
};
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json& j, BaseResult& g) {
|
||||
inline void from_json(const json& j, BaseResult& g) {
|
||||
j.at("full_score").get_to(g.full_score);
|
||||
j.at("flush_cost").get_to(g.flush_cost);
|
||||
j.at("constraints_ok").get_to(g.constraints_ok);
|
||||
@@ -401,7 +403,7 @@ struct TestCase {
|
||||
|
||||
inline TestCase load_test_case(const std::string& path) {
|
||||
std::ifstream f(path);
|
||||
nlohmann::json j = nlohmann::json::parse(f);
|
||||
json j = json::parse(f);
|
||||
TestCase tc;
|
||||
tc.metadata = j.at("metadata").get<TestMetadata>();
|
||||
Slic3r::from_json(j.at("context"), tc.context);
|
||||
@@ -411,9 +413,9 @@ inline TestCase load_test_case(const std::string& path) {
|
||||
}
|
||||
|
||||
inline void save_test_case(const std::string& path, const TestCase& tc) {
|
||||
nlohmann::json j;
|
||||
json j;
|
||||
j["metadata"] = tc.metadata;
|
||||
nlohmann::json ctx_j;
|
||||
json ctx_j;
|
||||
Slic3r::to_json(ctx_j, tc.context);
|
||||
j["context"] = ctx_j;
|
||||
if (tc.base_result)
|
||||
@@ -430,14 +432,14 @@ inline void save_result(const std::string& case_path, const TestResult& result)
|
||||
else
|
||||
result_path += ".result.json";
|
||||
|
||||
nlohmann::json j = result;
|
||||
json j = result;
|
||||
std::ofstream f(result_path);
|
||||
f << j.dump(2);
|
||||
}
|
||||
|
||||
inline TestResult load_result(const std::string& result_path) {
|
||||
std::ifstream f(result_path);
|
||||
nlohmann::json j = nlohmann::json::parse(f);
|
||||
json j = json::parse(f);
|
||||
return j.get<TestResult>();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "test_utils.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <initializer_list>
|
||||
#include <vector>
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include "libslic3r/BoundingBox.hpp"
|
||||
#include "libslic3r/ExtrusionEntity.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
namespace {
|
||||
|
||||
const char *const BELOW_PAD_TEST_OBJECTS[] = {
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#include "libslic3r/BoundingBox.hpp"
|
||||
#include "libslic3r/Line.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
void test_support_model_collision(const std::string &obj_filename,
|
||||
const sla::SupportTreeConfig &input_supportcfg,
|
||||
const sla::HollowingConfig &hollowingcfg,
|
||||
|
||||
@@ -33,31 +33,33 @@ namespace Slic3r::sla { struct PadConfig; }
|
||||
namespace Slic3r::sla { struct SupportTreeConfig; }
|
||||
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
enum e_validity {
|
||||
ASSUME_NO_EMPTY = 1,
|
||||
ASSUME_MANIFOLD = 2,
|
||||
ASSUME_NO_REPAIR = 4
|
||||
};
|
||||
|
||||
void check_validity(const Slic3r::TriangleMesh &input_mesh,
|
||||
void check_validity(const TriangleMesh &input_mesh,
|
||||
int flags = ASSUME_NO_EMPTY | ASSUME_MANIFOLD |
|
||||
ASSUME_NO_REPAIR);
|
||||
|
||||
struct PadByproducts
|
||||
{
|
||||
Slic3r::ExPolygons model_contours;
|
||||
Slic3r::ExPolygons support_contours;
|
||||
Slic3r::TriangleMesh mesh;
|
||||
ExPolygons model_contours;
|
||||
ExPolygons support_contours;
|
||||
TriangleMesh mesh;
|
||||
};
|
||||
|
||||
void test_concave_hull(const Slic3r::ExPolygons &polys);
|
||||
void test_concave_hull(const ExPolygons &polys);
|
||||
|
||||
void test_pad(const std::string & obj_filename,
|
||||
const Slic3r::sla::PadConfig &padcfg,
|
||||
const sla::PadConfig &padcfg,
|
||||
PadByproducts & out);
|
||||
|
||||
inline void test_pad(const std::string & obj_filename,
|
||||
const Slic3r::sla::PadConfig &padcfg = {})
|
||||
const sla::PadConfig &padcfg = {})
|
||||
{
|
||||
PadByproducts byproducts;
|
||||
test_pad(obj_filename, padcfg, byproducts);
|
||||
@@ -67,53 +69,53 @@ struct SupportByproducts
|
||||
{
|
||||
std::string obj_fname;
|
||||
std::vector<float> slicegrid;
|
||||
std::vector<Slic3r::ExPolygons> model_slices;
|
||||
Slic3r::sla::SupportTreeBuilder supporttree;
|
||||
Slic3r::TriangleMesh input_mesh;
|
||||
std::vector<ExPolygons> model_slices;
|
||||
sla::SupportTreeBuilder supporttree;
|
||||
TriangleMesh input_mesh;
|
||||
};
|
||||
|
||||
const constexpr float CLOSING_RADIUS = 0.005f;
|
||||
|
||||
void check_support_tree_integrity(const Slic3r::sla::SupportTreeBuilder &stree,
|
||||
const Slic3r::sla::SupportTreeConfig &cfg);
|
||||
void check_support_tree_integrity(const sla::SupportTreeBuilder &stree,
|
||||
const sla::SupportTreeConfig &cfg);
|
||||
|
||||
void test_supports(const std::string &obj_filename,
|
||||
const Slic3r::sla::SupportTreeConfig &supportcfg,
|
||||
const Slic3r::sla::HollowingConfig &hollowingcfg,
|
||||
const Slic3r::sla::DrainHoles &drainholes,
|
||||
const sla::SupportTreeConfig &supportcfg,
|
||||
const sla::HollowingConfig &hollowingcfg,
|
||||
const sla::DrainHoles &drainholes,
|
||||
SupportByproducts &out);
|
||||
|
||||
inline void test_supports(const std::string &obj_filename,
|
||||
const Slic3r::sla::SupportTreeConfig &supportcfg,
|
||||
const sla::SupportTreeConfig &supportcfg,
|
||||
SupportByproducts &out)
|
||||
{
|
||||
Slic3r::sla::HollowingConfig hcfg;
|
||||
sla::HollowingConfig hcfg;
|
||||
hcfg.enabled = false;
|
||||
test_supports(obj_filename, supportcfg, hcfg, {}, out);
|
||||
}
|
||||
|
||||
inline void test_supports(const std::string &obj_filename,
|
||||
const Slic3r::sla::SupportTreeConfig &supportcfg = {})
|
||||
const sla::SupportTreeConfig &supportcfg = {})
|
||||
{
|
||||
SupportByproducts byproducts;
|
||||
test_supports(obj_filename, supportcfg, byproducts);
|
||||
}
|
||||
|
||||
void export_failed_case(const std::vector<Slic3r::ExPolygons> &support_slices,
|
||||
void export_failed_case(const std::vector<ExPolygons> &support_slices,
|
||||
const SupportByproducts &byproducts);
|
||||
|
||||
|
||||
void test_support_model_collision(
|
||||
const std::string &obj_filename,
|
||||
const Slic3r::sla::SupportTreeConfig &input_supportcfg,
|
||||
const Slic3r::sla::HollowingConfig &hollowingcfg,
|
||||
const Slic3r::sla::DrainHoles &drainholes);
|
||||
const sla::SupportTreeConfig &input_supportcfg,
|
||||
const sla::HollowingConfig &hollowingcfg,
|
||||
const sla::DrainHoles &drainholes);
|
||||
|
||||
inline void test_support_model_collision(
|
||||
const std::string &obj_filename,
|
||||
const Slic3r::sla::SupportTreeConfig &input_supportcfg = {})
|
||||
const sla::SupportTreeConfig &input_supportcfg = {})
|
||||
{
|
||||
Slic3r::sla::HollowingConfig hcfg;
|
||||
sla::HollowingConfig hcfg;
|
||||
hcfg.enabled = false;
|
||||
test_support_model_collision(obj_filename, input_supportcfg, hcfg, {});
|
||||
}
|
||||
@@ -154,8 +156,8 @@ template <class I, class II> void test_pairhash()
|
||||
|
||||
REQUIRE(a != b);
|
||||
|
||||
II hash_ab = Slic3r::sla::pairhash<I, II>(a, b);
|
||||
II hash_ba = Slic3r::sla::pairhash<I, II>(b, a);
|
||||
II hash_ab = sla::pairhash<I, II>(a, b);
|
||||
II hash_ba = sla::pairhash<I, II>(b, a);
|
||||
REQUIRE(hash_ab == hash_ba);
|
||||
|
||||
auto it = ints.find(hash_ab);
|
||||
@@ -178,23 +180,23 @@ static constexpr const TPixel FullBlack = 0;
|
||||
|
||||
template <class A, int N> constexpr int arraysize(const A (&)[N]) { return N; }
|
||||
|
||||
void check_raster_transformations(Slic3r::sla::RasterBase::Orientation o,
|
||||
Slic3r::sla::RasterBase::TMirroring mirroring);
|
||||
void check_raster_transformations(sla::RasterBase::Orientation o,
|
||||
sla::RasterBase::TMirroring mirroring);
|
||||
|
||||
Slic3r::ExPolygon square_with_hole(double v);
|
||||
ExPolygon square_with_hole(double v);
|
||||
|
||||
inline double pixel_area(TPixel px, const Slic3r::sla::PixelDim &pxdim)
|
||||
inline double pixel_area(TPixel px, const sla::PixelDim &pxdim)
|
||||
{
|
||||
return (pxdim.h_mm * pxdim.w_mm) * px * 1. / (FullWhite - FullBlack);
|
||||
}
|
||||
|
||||
double raster_white_area(const Slic3r::sla::RasterGrayscaleAA &raster);
|
||||
long raster_pxsum(const Slic3r::sla::RasterGrayscaleAA &raster);
|
||||
double raster_white_area(const sla::RasterGrayscaleAA &raster);
|
||||
long raster_pxsum(const sla::RasterGrayscaleAA &raster);
|
||||
|
||||
double predict_error(const Slic3r::ExPolygon &p, const Slic3r::sla::PixelDim &pd);
|
||||
double predict_error(const ExPolygon &p, const sla::PixelDim &pd);
|
||||
|
||||
Slic3r::sla::SupportPoints calc_support_pts(
|
||||
const Slic3r::TriangleMesh & mesh,
|
||||
const Slic3r::sla::SupportPointGenerator::Config &cfg = {});
|
||||
sla::SupportPoints calc_support_pts(
|
||||
const TriangleMesh & mesh,
|
||||
const sla::SupportPointGenerator::Config &cfg = {});
|
||||
|
||||
#endif // SLA_TEST_UTILS_HPP
|
||||
|
||||
Reference in New Issue
Block a user