Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_layout

This commit is contained in:
enricoturri1966 2020-06-11 14:04:08 +02:00
commit 8c998e5f08
26 changed files with 503 additions and 355 deletions

View file

@ -23,7 +23,7 @@ extern void update_custom_gcode_per_print_z_from_config(Info& info, DynamicPrint
info.gcodes.reserve(colorprint_values.size());
int i = 0;
for (auto val : colorprint_values)
info.gcodes.emplace_back(Item{ val, ColorChangeCode, 1, colors[(++i)%7] });
info.gcodes.emplace_back(Item{ val, ColorChange, 1, colors[(++i)%7] });
info.mode = SingleExtruder;
}
@ -43,11 +43,11 @@ extern void check_mode_for_custom_gcode_per_print_z(Info& info)
bool is_single_extruder = true;
for (auto item : info.gcodes)
{
if (item.gcode == ToolChangeCode) {
if (item.type == ToolChange) {
info.mode = MultiAsSingle;
return;
}
if (item.gcode == ColorChangeCode && item.extruder > 1)
if (item.type == ColorChange && item.extruder > 1)
is_single_extruder = false;
}
@ -60,7 +60,7 @@ std::vector<std::pair<double, unsigned int>> custom_tool_changes(const Info& cus
{
std::vector<std::pair<double, unsigned int>> custom_tool_changes;
for (const Item& custom_gcode : custom_gcode_per_print_z.gcodes)
if (custom_gcode.gcode == ToolChangeCode) {
if (custom_gcode.type == ToolChange) {
// If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders
assert(custom_gcode.extruder >= 0);
custom_tool_changes.emplace_back(custom_gcode.print_z, static_cast<unsigned int>(size_t(custom_gcode.extruder) > num_extruders ? 1 : custom_gcode.extruder));

View file

@ -8,38 +8,40 @@ namespace Slic3r {
class DynamicPrintConfig;
// Additional Codes which can be set by user using DoubleSlider
static constexpr char ColorChangeCode[] = "M600";
static constexpr char PausePrintCode[] = "M601";
static constexpr char ToolChangeCode[] = "tool_change";
enum CustomGcodeType
{
cgtColorChange,
cgtPausePrint,
};
namespace CustomGCode {
enum Type
{
ColorChange,
PausePrint,
ToolChange,
Template,
Custom
};
struct Item
{
bool operator<(const Item& rhs) const { return this->print_z < rhs.print_z; }
bool operator==(const Item& rhs) const
{
return (rhs.print_z == this->print_z ) &&
(rhs.gcode == this->gcode ) &&
(rhs.type == this->type ) &&
(rhs.extruder == this->extruder ) &&
(rhs.color == this->color );
(rhs.color == this->color ) &&
(rhs.extra == this->extra );
}
bool operator!=(const Item& rhs) const { return ! (*this == rhs); }
double print_z;
std::string gcode;
Type type;
int extruder; // Informative value for ColorChangeCode and ToolChangeCode
// "gcode" == ColorChangeCode => M600 will be applied for "extruder" extruder
// "gcode" == ToolChangeCode => for whole print tool will be switched to "extruder" extruder
std::string color; // if gcode is equal to PausePrintCode,
// this field is used for save a short message shown on Printer display
std::string extra; // this field is used for the extra data like :
// - G-code text for the Type::Custom
// - message text for the Type::PausePrint
};
enum Mode

View file

@ -1197,13 +1197,32 @@ namespace Slic3r {
}
if (code.first != "code")
continue;
pt::ptree tree = code.second;
double print_z = tree.get<double> ("<xmlattr>.print_z" );
std::string gcode = tree.get<std::string> ("<xmlattr>.gcode" );
int extruder = tree.get<int> ("<xmlattr>.extruder" );
std::string color = tree.get<std::string> ("<xmlattr>.color" );
m_model->custom_gcode_per_print_z.gcodes.push_back(CustomGCode::Item{print_z, gcode, extruder, color}) ;
pt::ptree tree = code.second;
double print_z = tree.get<double> ("<xmlattr>.print_z" );
int extruder = tree.get<int> ("<xmlattr>.extruder");
std::string color = tree.get<std::string> ("<xmlattr>.color" );
CustomGCode::Type type;
std::string extra;
if (tree.find("type") == tree.not_found())
{
// It means that data was saved in old version (2.2.0 and older) of PrusaSlicer
// read old data ...
std::string gcode = tree.get<std::string> ("<xmlattr>.gcode");
// ... and interpret them to the new data
type = gcode == "M600" ? CustomGCode::ColorChange :
gcode == "M601" ? CustomGCode::PausePrint :
gcode == "tool_change" ? CustomGCode::ToolChange : CustomGCode::Custom;
extra = type == CustomGCode::PausePrint ? color :
type == CustomGCode::Custom ? gcode : "";
}
else
{
type = static_cast<CustomGCode::Type>(tree.get<int>("<xmlattr>.type"));
extra = tree.get<std::string>("<xmlattr>.extra");
}
m_model->custom_gcode_per_print_z.gcodes.push_back(CustomGCode::Item{print_z, type, extruder, color, extra}) ;
}
}
}
@ -1982,7 +2001,7 @@ namespace Slic3r {
bool _add_sla_drain_holes_file_to_archive(mz_zip_archive& archive, Model& model);
bool _add_print_config_file_to_archive(mz_zip_archive& archive, const DynamicPrintConfig &config);
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, const IdToObjectDataMap &objects_data);
bool _add_custom_gcode_per_print_z_file_to_archive(mz_zip_archive& archive, Model& model);
bool _add_custom_gcode_per_print_z_file_to_archive(mz_zip_archive& archive, Model& model, const DynamicPrintConfig* config);
};
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data)
@ -2082,7 +2101,7 @@ namespace Slic3r {
// Adds custom gcode per height file ("Metadata/Prusa_Slicer_custom_gcode_per_print_z.xml").
// All custom gcode per height of whole Model are stored here
if (!_add_custom_gcode_per_print_z_file_to_archive(archive, model))
if (!_add_custom_gcode_per_print_z_file_to_archive(archive, model, config))
{
close_zip_writer(&archive);
boost::filesystem::remove(filename);
@ -2702,7 +2721,7 @@ namespace Slic3r {
return true;
}
bool _3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive( mz_zip_archive& archive, Model& model)
bool _3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive( mz_zip_archive& archive, Model& model, const DynamicPrintConfig* config)
{
std::string out = "";
@ -2714,11 +2733,20 @@ bool _3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive( mz_zip_archiv
for (const CustomGCode::Item& code : model.custom_gcode_per_print_z.gcodes)
{
pt::ptree& code_tree = main_tree.add("code", "");
// store minX and maxZ
// store data of custom_gcode_per_print_z
code_tree.put("<xmlattr>.print_z" , code.print_z );
code_tree.put("<xmlattr>.gcode" , code.gcode );
code_tree.put("<xmlattr>.type" , static_cast<int>(code.type));
code_tree.put("<xmlattr>.extruder" , code.extruder );
code_tree.put("<xmlattr>.color" , code.color );
code_tree.put("<xmlattr>.extra" , code.extra );
// add gcode field data for the old version of the PrusaSlicer
std::string gcode = code.type == CustomGCode::ColorChange ? config->opt_string("color_change_gcode") :
code.type == CustomGCode::PausePrint ? config->opt_string("pause_print_gcode") :
code.type == CustomGCode::Template ? config->opt_string("template_custom_gcode") :
code.type == CustomGCode::ToolChange ? "tool_change" : code.extra;
code_tree.put("<xmlattr>.gcode" , gcode );
}
pt::ptree& mode_tree = main_tree.add("mode", "");

View file

@ -240,7 +240,7 @@ struct AMFParserContext
// Current instance allocated for an amf/constellation/instance subtree.
Instance *m_instance;
// Generic string buffer for vertices, face indices, metadata etc.
std::string m_value[4];
std::string m_value[5];
// Pointer to config to update if config data are stored inside the amf file
DynamicPrintConfig *m_config;
@ -314,9 +314,26 @@ void AMFParserContext::startElement(const char *name, const char **atts)
if (strcmp(name, "code") == 0) {
node_type_new = NODE_TYPE_GCODE_PER_HEIGHT;
m_value[0] = get_attribute(atts, "print_z");
m_value[1] = get_attribute(atts, "gcode");
m_value[2] = get_attribute(atts, "extruder");
m_value[3] = get_attribute(atts, "color");
m_value[1] = get_attribute(atts, "extruder");
m_value[2] = get_attribute(atts, "color");
if (get_attribute(atts, "type"))
{
m_value[3] = get_attribute(atts, "type");
m_value[4] = get_attribute(atts, "extra");
}
else
{
// It means that data was saved in old version (2.2.0 and older) of PrusaSlicer
// read old data ...
std::string gcode = get_attribute(atts, "gcode");
// ... and interpret them to the new data
CustomGCode::Type type= gcode == "M600" ? CustomGCode::ColorChange :
gcode == "M601" ? CustomGCode::PausePrint :
gcode == "tool_change" ? CustomGCode::ToolChange : CustomGCode::Custom;
m_value[3] = std::to_string(static_cast<int>(type));
m_value[4] = type == CustomGCode::PausePrint ? m_value[2] :
type == CustomGCode::Custom ? gcode : "";
}
}
else if (strcmp(name, "mode") == 0) {
node_type_new = NODE_TYPE_CUSTOM_GCODE_MODE;
@ -640,12 +657,13 @@ void AMFParserContext::endElement(const char * /* name */)
break;
case NODE_TYPE_GCODE_PER_HEIGHT: {
double print_z = double(atof(m_value[0].c_str()));
const std::string& gcode = m_value[1];
int extruder = atoi(m_value[2].c_str());
const std::string& color = m_value[3];
double print_z = double(atof(m_value[0].c_str()));
int extruder = atoi(m_value[1].c_str());
const std::string& color= m_value[2];
CustomGCode::Type type = static_cast<CustomGCode::Type>(atoi(m_value[3].c_str()));
const std::string& extra= m_value[4];
m_model.custom_gcode_per_print_z.gcodes.push_back(CustomGCode::Item{print_z, gcode, extruder, color});
m_model.custom_gcode_per_print_z.gcodes.push_back(CustomGCode::Item{print_z, type, extruder, color, extra});
for (std::string& val: m_value)
val.clear();
@ -1253,9 +1271,17 @@ bool store_amf(const char* path, Model* model, const DynamicPrintConfig* config,
pt::ptree& code_tree = main_tree.add("code", "");
// store custom_gcode_per_print_z gcodes information
code_tree.put("<xmlattr>.print_z" , code.print_z );
code_tree.put("<xmlattr>.gcode" , code.gcode );
code_tree.put("<xmlattr>.type" , static_cast<int>(code.type));
code_tree.put("<xmlattr>.extruder" , code.extruder );
code_tree.put("<xmlattr>.color" , code.color );
code_tree.put("<xmlattr>.extra" , code.extra );
// add gcode field data for the old version of the PrusaSlicer
std::string gcode = code.type == CustomGCode::ColorChange ? config->opt_string("color_change_gcode") :
code.type == CustomGCode::PausePrint ? config->opt_string("pause_print_gcode") :
code.type == CustomGCode::Template ? config->opt_string("template_custom_gcode") :
code.type == CustomGCode::ToolChange ? "tool_change" : code.extra;
code_tree.put("<xmlattr>.gcode" , gcode );
}
pt::ptree& mode_tree = main_tree.add("mode", "");

View file

@ -1778,17 +1778,18 @@ namespace ProcessLayer
const CustomGCode::Item *custom_gcode,
// ID of the first extruder printing this layer.
unsigned int first_extruder_id,
bool single_extruder_printer)
const PrintConfig &config)
{
std::string gcode;
bool single_extruder_printer = config.nozzle_diameter.size() == 1;
if (custom_gcode != nullptr) {
// Extruder switches are processed by LayerTools, they should be filtered out.
assert(custom_gcode->gcode != ToolChangeCode);
assert(custom_gcode->type != CustomGCode::ToolChange);
const std::string &custom_code = custom_gcode->gcode;
bool color_change = custom_code == ColorChangeCode;
bool tool_change = custom_code == ToolChangeCode;
CustomGCode::Type gcode_type = custom_gcode->type;
bool color_change = gcode_type == CustomGCode::ColorChange;
bool tool_change = gcode_type == CustomGCode::ToolChange;
// Tool Change is applied as Color Change for a single extruder printer only.
assert(! tool_change || single_extruder_printer);
@ -1796,8 +1797,8 @@ namespace ProcessLayer
int m600_extruder_before_layer = -1;
if (color_change && custom_gcode->extruder > 0)
m600_extruder_before_layer = custom_gcode->extruder - 1;
else if (custom_code == PausePrintCode)
pause_print_msg = custom_gcode->color;
else if (gcode_type == CustomGCode::PausePrint)
pause_print_msg = custom_gcode->extra;
// we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
if (color_change || tool_change)
@ -1813,17 +1814,18 @@ namespace ProcessLayer
// && !MMU1
) {
//! FIXME_in_fw show message during print pause
gcode += "M601\n"; // pause print
gcode += config.pause_print_gcode;// pause print
gcode += "\n";
gcode += "M117 Change filament for Extruder " + std::to_string(m600_extruder_before_layer) + "\n";
}
else {
gcode += ColorChangeCode;
gcode += config.color_change_gcode;//ColorChangeCode;
gcode += "\n";
}
}
else
{
if (custom_code == PausePrintCode) // Pause print
if (gcode_type == CustomGCode::PausePrint) // Pause print
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Pause_Print_Tag + "\n";
@ -1832,15 +1834,21 @@ namespace ProcessLayer
gcode += "M117 " + pause_print_msg + "\n";
// add tag for time estimator
gcode += "; " + GCodeTimeEstimator::Pause_Print_Tag + "\n";
gcode += config.pause_print_gcode;
}
else // custom Gcode
else
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Custom_Code_Tag + "\n";
// add tag for time estimator
//gcode += "; " + GCodeTimeEstimator::Custom_Code_Tag + "\n";
if (gcode_type == CustomGCode::Template) // Template Cistom Gcode
gcode += config.template_custom_gcode;
else // custom Gcode
gcode += custom_gcode->extra;
}
gcode += custom_code + "\n";
gcode += "\n";
}
}
@ -2017,7 +2025,7 @@ void GCode::process_layer(
if (single_object_instance_idx == size_t(-1)) {
// Normal (non-sequential) print.
gcode += ProcessLayer::emit_custom_gcode_per_print_z(layer_tools.custom_gcode, first_extruder_id, print.config().nozzle_diameter.size() == 1);
gcode += ProcessLayer::emit_custom_gcode_per_print_z(layer_tools.custom_gcode, first_extruder_id, print.config());
}
// Extrude skirt at the print_z of the raft layers and normal object layers
// not at the print_z of the interlaced support material layers.

View file

@ -492,7 +492,7 @@ void ToolOrdering::assign_custom_gcodes(const Print &print)
for (unsigned int i : lt.extruders)
extruder_printing_above[i] = true;
// Skip all custom G-codes above this layer and skip all extruder switches.
for (; custom_gcode_it != custom_gcode_per_print_z.gcodes.rend() && (custom_gcode_it->print_z > lt.print_z + EPSILON || custom_gcode_it->gcode == ToolChangeCode); ++ custom_gcode_it);
for (; custom_gcode_it != custom_gcode_per_print_z.gcodes.rend() && (custom_gcode_it->print_z > lt.print_z + EPSILON || custom_gcode_it->type == CustomGCode::ToolChange); ++ custom_gcode_it);
if (custom_gcode_it == custom_gcode_per_print_z.gcodes.rend())
// Custom G-codes were processed.
break;
@ -504,8 +504,8 @@ void ToolOrdering::assign_custom_gcodes(const Print &print)
print_z_below = it_lt_below->print_z;
if (custom_gcode.print_z > print_z_below + 0.5 * EPSILON) {
// The custom G-code applies to the current layer.
bool color_change = custom_gcode.gcode == ColorChangeCode;
bool tool_change = custom_gcode.gcode == ToolChangeCode;
bool color_change = custom_gcode.type == CustomGCode::ColorChange;
bool tool_change = custom_gcode.type == CustomGCode::ToolChange;
bool pause_or_custom_gcode = ! color_change && ! tool_change;
bool apply_color_change = ! ignore_tool_and_color_changes &&
// If it is color change, it will actually be useful as the exturder above will print.

View file

@ -188,7 +188,7 @@ namespace Slic3r {
_calculate_time(0);
if (m_needs_custom_gcode_times && (m_custom_gcode_time_cache != 0.0f))
m_custom_gcode_times.push_back({ cgtColorChange, m_custom_gcode_time_cache });
m_custom_gcode_times.push_back({CustomGCode::ColorChange, m_custom_gcode_time_cache });
#if ENABLE_MOVE_STATS
_log_moves_stats();
@ -678,7 +678,7 @@ namespace Slic3r {
return _get_time_minutes(get_time());
}
std::vector<std::pair<CustomGcodeType, float>> GCodeTimeEstimator::get_custom_gcode_times() const
std::vector<std::pair<CustomGCode::Type, float>> GCodeTimeEstimator::get_custom_gcode_times() const
{
return m_custom_gcode_times;
}
@ -722,9 +722,9 @@ namespace Slic3r {
return ret;
}
std::vector<std::pair<CustomGcodeType, std::string>> GCodeTimeEstimator::get_custom_gcode_times_dhm(bool include_remaining) const
std::vector<std::pair<CustomGCode::Type, std::string>> GCodeTimeEstimator::get_custom_gcode_times_dhm(bool include_remaining) const
{
std::vector<std::pair<CustomGcodeType, std::string>> ret;
std::vector<std::pair<CustomGCode::Type, std::string>> ret;
float total_time = 0.0f;
for (auto t : m_custom_gcode_times)
@ -1470,7 +1470,7 @@ namespace Slic3r {
size_t pos = comment.find(Color_Change_Tag);
if (pos != comment.npos)
{
_process_custom_gcode_tag(cgtColorChange);
_process_custom_gcode_tag(CustomGCode::ColorChange);
return true;
}
@ -1478,14 +1478,14 @@ namespace Slic3r {
pos = comment.find(Pause_Print_Tag);
if (pos != comment.npos)
{
_process_custom_gcode_tag(cgtPausePrint);
_process_custom_gcode_tag(CustomGCode::PausePrint);
return true;
}
return false;
}
void GCodeTimeEstimator::_process_custom_gcode_tag(CustomGcodeType code)
void GCodeTimeEstimator::_process_custom_gcode_tag(CustomGCode::Type code)
{
PROFILE_FUNC();
m_needs_custom_gcode_times = true;

View file

@ -234,7 +234,7 @@ namespace Slic3r {
// data to calculate custom code times
bool m_needs_custom_gcode_times;
std::vector<std::pair<CustomGcodeType, float>> m_custom_gcode_times;
std::vector<std::pair<CustomGCode::Type, float>> m_custom_gcode_times;
float m_custom_gcode_time_cache;
#if ENABLE_MOVE_STATS
@ -358,7 +358,7 @@ namespace Slic3r {
std::string get_time_minutes() const;
// Returns the estimated time, in seconds, for each custom gcode
std::vector<std::pair<CustomGcodeType, float>> get_custom_gcode_times() const;
std::vector<std::pair<CustomGCode::Type, float>> get_custom_gcode_times() const;
// Returns the estimated time, in format DDd HHh MMm SSs, for each color
// If include_remaining==true the strings will be formatted as: "time for color (remaining time at color start)"
@ -370,7 +370,7 @@ namespace Slic3r {
// Returns the estimated time, in format DDd HHh MMm, for each custom_gcode
// If include_remaining==true the strings will be formatted as: "time for custom_gcode (remaining time at color start)"
std::vector<std::pair<CustomGcodeType, std::string>> get_custom_gcode_times_dhm(bool include_remaining) const;
std::vector<std::pair<CustomGCode::Type, std::string>> get_custom_gcode_times_dhm(bool include_remaining) const;
// Return an estimate of the memory consumed by the time estimator.
size_t memory_used() const;
@ -453,7 +453,7 @@ namespace Slic3r {
bool _process_tags(const GCodeReader::GCodeLine& line);
// Processes ColorChangeTag and PausePrintTag
void _process_custom_gcode_tag(CustomGcodeType code);
void _process_custom_gcode_tag(CustomGCode::Type code);
// Simulates firmware st_synchronize() call
void _simulate_st_synchronize(float additional_time);

View file

@ -499,12 +499,12 @@ static bool custom_per_printz_gcodes_tool_changes_differ(const std::vector<Custo
auto it_a = va.begin();
auto it_b = vb.begin();
while (it_a != va.end() || it_b != vb.end()) {
if (it_a != va.end() && it_a->gcode != ToolChangeCode) {
if (it_a != va.end() && it_a->type != CustomGCode::ToolChange) {
// Skip any CustomGCode items, which are not tool changes.
++ it_a;
continue;
}
if (it_b != vb.end() && it_b->gcode != ToolChangeCode) {
if (it_b != vb.end() && it_b->type != CustomGCode::ToolChange) {
// Skip any CustomGCode items, which are not tool changes.
++ it_b;
continue;
@ -512,8 +512,8 @@ static bool custom_per_printz_gcodes_tool_changes_differ(const std::vector<Custo
if (it_a == va.end() || it_b == vb.end())
// va or vb contains more Tool Changes than the other.
return true;
assert(it_a->gcode == ToolChangeCode);
assert(it_b->gcode == ToolChangeCode);
assert(it_a->type == CustomGCode::ToolChange);
assert(it_b->type == CustomGCode::ToolChange);
if (*it_a != *it_b)
// The two Tool Changes differ.
return true;

View file

@ -300,8 +300,8 @@ struct PrintStatistics
PrintStatistics() { clear(); }
std::string estimated_normal_print_time;
std::string estimated_silent_print_time;
std::vector<std::pair<CustomGcodeType, std::string>> estimated_normal_custom_gcode_print_times;
std::vector<std::pair<CustomGcodeType, std::string>> estimated_silent_custom_gcode_print_times;
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_normal_custom_gcode_print_times;
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_silent_custom_gcode_print_times;
double total_used_filament;
double total_extruded_volume;
double total_cost;

View file

@ -1909,6 +1909,33 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionStrings { "; Filament gcode\n" });
def = this->add("color_change_gcode", coString);
def->label = L("Color change G-code");
def->tooltip = L("This G-code will be used as a code for the color change");
def->multiline = true;
def->full_width = true;
def->height = 12;
def->mode = comExpert;
def->set_default_value(new ConfigOptionString("M600"));
def = this->add("pause_print_gcode", coString);
def->label = L("Pause Print G-code");
def->tooltip = L("This G-code will be used as a code for the pause print");
def->multiline = true;
def->full_width = true;
def->height = 12;
def->mode = comExpert;
def->set_default_value(new ConfigOptionString("M601"));
def = this->add("template_custom_gcode", coString);
def->label = L("Custom G-code");
def->tooltip = L("This G-code will be used as a custom code");
def->multiline = true;
def->full_width = true;
def->height = 12;
def->mode = comExpert;
def->set_default_value(new ConfigOptionString(""));
def = this->add("single_extruder_multi_material", coBool);
def->label = L("Single Extruder Multi Material");
def->tooltip = L("The printer multiplexes filaments into a single hot end.");

View file

@ -699,6 +699,9 @@ public:
ConfigOptionBool remaining_times;
ConfigOptionBool silent_mode;
ConfigOptionFloat extra_loading_move;
ConfigOptionString color_change_gcode;
ConfigOptionString pause_print_gcode;
ConfigOptionString template_custom_gcode;
std::string get_extrusion_axis() const
{
@ -772,6 +775,9 @@ protected:
OPT_PTR(remaining_times);
OPT_PTR(silent_mode);
OPT_PTR(extra_loading_move);
OPT_PTR(color_change_gcode);
OPT_PTR(pause_print_gcode);
OPT_PTR(template_custom_gcode);
}
};

View file

@ -97,7 +97,7 @@ std::unique_ptr<TriangleMesh> generate_interior(const TriangleMesh & mesh,
_generate_interior(mesh, ctl, hc.min_thickness, voxel_scale,
hc.closing_distance));
if (meshptr) {
if (meshptr && !meshptr->empty()) {
// This flips the normals to be outward facing...
meshptr->require_shared_vertices();

View file

@ -28,17 +28,25 @@ void reproject_support_points(const EigenMesh3D &mesh, std::vector<PointType> &p
inline void reproject_points_and_holes(ModelObject *object)
{
bool has_sppoints = !object->sla_support_points.empty();
bool has_holes = !object->sla_drain_holes.empty();
if (!object || (!has_holes && !has_sppoints)) return;
// Disabling reprojection of holes as they have a significant offset away
// from the model body which tolerates minor geometrical changes.
//
// TODO: uncomment and ensure the right offset of the hole points if
// reprojection would still be necessary.
// bool has_holes = !object->sla_drain_holes.empty();
EigenMesh3D emesh{object->raw_mesh()};
if (!object || (/*!has_holes &&*/ !has_sppoints)) return;
TriangleMesh rmsh = object->raw_mesh();
rmsh.require_shared_vertices();
EigenMesh3D emesh{rmsh};
if (has_sppoints)
reproject_support_points(emesh, object->sla_support_points);
if (has_holes)
reproject_support_points(emesh, object->sla_drain_holes);
// if (has_holes)
// reproject_support_points(emesh, object->sla_drain_holes);
}
}}