ENH: auto arranging won't put more than 1 TPU filament on the same plate
jira: none Change-Id: I0ac0968ac56f9969f94b73cfacaac3a97a814b2d
This commit is contained in:
parent
f9a1ed7b24
commit
02b8a79285
|
@ -76,7 +76,8 @@ class _Item {
|
||||||
public:
|
public:
|
||||||
int itemid_{ 0 };
|
int itemid_{ 0 };
|
||||||
std::vector<int> extrude_ids;
|
std::vector<int> extrude_ids;
|
||||||
int filament_temp_type = -1; // -1 means unset. otherwise should be {0,1,2}
|
std::vector<std::string> filament_types{}; /// filament type for different material judge
|
||||||
|
int filament_temp_type = -1; // -1 means unset. otherwise should be one of FilamentTempType ie {0,1,2}
|
||||||
double height{ 0 };
|
double height{ 0 };
|
||||||
double print_temp{ 0 };
|
double print_temp{ 0 };
|
||||||
double bed_temp{ 0 };
|
double bed_temp{ 0 };
|
||||||
|
|
|
@ -549,14 +549,23 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<int> extruder_ids;
|
std::set<int> extruder_ids;
|
||||||
|
std::set<int> tpu_extruder_ids;
|
||||||
for (int i = 0; i < m_items.size(); i++) {
|
for (int i = 0; i < m_items.size(); i++) {
|
||||||
Item& p = m_items[i];
|
Item& p = m_items[i];
|
||||||
if (p.is_virt_object) continue;
|
if (p.is_virt_object) continue;
|
||||||
extruder_ids.insert(p.extrude_ids.begin(),p.extrude_ids.end());
|
extruder_ids.insert(p.extrude_ids.begin(),p.extrude_ids.end());
|
||||||
|
for (int j = 0; j < p.extrude_ids.size(); j++) {
|
||||||
|
if (p.filament_types[j] == "TPU") tpu_extruder_ids.insert(p.extrude_ids[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int j = 0; j < item.extrude_ids.size(); j++) {
|
||||||
|
if (item.filament_types[j] == "TPU") tpu_extruder_ids.insert(item.extrude_ids[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not allow more than 1 TPU extruder on same plate
|
||||||
|
if (tpu_extruder_ids.size() > 1) score += LARGE_COST_TO_REJECT;
|
||||||
// add a large cost if not multi materials on same plate is not allowed
|
// add a large cost if not multi materials on same plate is not allowed
|
||||||
if (!params.allow_multi_materials_on_same_plate) {
|
else if (!params.allow_multi_materials_on_same_plate) {
|
||||||
// it's the first object, which can be multi-color
|
// it's the first object, which can be multi-color
|
||||||
bool first_object = extruder_ids.empty();
|
bool first_object = extruder_ids.empty();
|
||||||
// the two objects (previously packed items and the current item) are considered having same color if either one's colors are a subset of the other
|
// the two objects (previously packed items and the current item) are considered having same color if either one's colors are a subset of the other
|
||||||
|
@ -984,6 +993,7 @@ static void process_arrangeable(const ArrangePolygon &arrpoly,
|
||||||
item.priority(arrpoly.priority);
|
item.priority(arrpoly.priority);
|
||||||
item.itemId(arrpoly.itemid);
|
item.itemId(arrpoly.itemid);
|
||||||
item.extrude_ids = arrpoly.extrude_ids;
|
item.extrude_ids = arrpoly.extrude_ids;
|
||||||
|
item.filament_types = arrpoly.filament_types;
|
||||||
item.height = arrpoly.height;
|
item.height = arrpoly.height;
|
||||||
item.name = arrpoly.name;
|
item.name = arrpoly.name;
|
||||||
//BBS: add virtual object logic
|
//BBS: add virtual object logic
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct ArrangePolygon {
|
||||||
int row{0};
|
int row{0};
|
||||||
int col{0};
|
int col{0};
|
||||||
std::vector<int> extrude_ids{}; /// extruder_id for least extruder switch
|
std::vector<int> extrude_ids{}; /// extruder_id for least extruder switch
|
||||||
|
std::vector<std::string> filament_types{}; /// filament type for different material judge
|
||||||
int filament_temp_type{ -1 };
|
int filament_temp_type{ -1 };
|
||||||
int bed_temp{0}; ///bed temperature for different material judge
|
int bed_temp{0}; ///bed temperature for different material judge
|
||||||
int print_temp{0}; ///print temperature for different material judge
|
int print_temp{0}; ///print temperature for different material judge
|
||||||
|
|
|
@ -3952,6 +3952,11 @@ void ModelInstance::get_arrange_polygon(void *ap, const Slic3r::DynamicPrintConf
|
||||||
// static const double SIMPLIFY_TOLERANCE_MM = 0.1;
|
// static const double SIMPLIFY_TOLERANCE_MM = 0.1;
|
||||||
|
|
||||||
Geometry::Transformation trafo_instance = get_transformation();
|
Geometry::Transformation trafo_instance = get_transformation();
|
||||||
|
|
||||||
|
//BOOST_LOG_TRIVIAL(debug) << "get_arrange_polygon: " << object->name << " instance trans:\n"
|
||||||
|
// << trafo_instance.get_matrix().matrix() << "\n object trans:\n"
|
||||||
|
// << object->volumes.front()->get_transformation().get_matrix().matrix();
|
||||||
|
|
||||||
trafo_instance.set_offset(Vec3d(0, 0, get_offset(Z)));
|
trafo_instance.set_offset(Vec3d(0, 0, get_offset(Z)));
|
||||||
|
|
||||||
Polygon p = get_object()->convex_hull_2d(trafo_instance.get_matrix());
|
Polygon p = get_object()->convex_hull_2d(trafo_instance.get_matrix());
|
||||||
|
|
|
@ -668,6 +668,25 @@ inline std::string filter_characters(const std::string& str, const std::string&
|
||||||
return filteredStr;
|
return filteredStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// custom vector wrapper for outputting to log
|
||||||
|
template<typename T> struct VectorFormatter
|
||||||
|
{
|
||||||
|
const std::vector<T> &vec;
|
||||||
|
|
||||||
|
explicit VectorFormatter(const std::vector<T> &v) : vec(v) {}
|
||||||
|
|
||||||
|
friend std::ostream &operator<<(std::ostream &os, const VectorFormatter<T> &vf)
|
||||||
|
{
|
||||||
|
os << "[";
|
||||||
|
for (size_t i = 0; i < vf.vec.size(); ++i) {
|
||||||
|
os << vf.vec[i];
|
||||||
|
if (i != vf.vec.size() - 1) { os << ", "; }
|
||||||
|
}
|
||||||
|
os << "]";
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
#if WIN32
|
#if WIN32
|
||||||
|
|
|
@ -100,8 +100,30 @@ void ArrangeJob::clear_input()
|
||||||
ArrangePolygon ArrangeJob::prepare_arrange_polygon(void* model_instance)
|
ArrangePolygon ArrangeJob::prepare_arrange_polygon(void* model_instance)
|
||||||
{
|
{
|
||||||
ModelInstance* instance = (ModelInstance*)model_instance;
|
ModelInstance* instance = (ModelInstance*)model_instance;
|
||||||
const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config();
|
auto preset_bundle = wxGetApp().preset_bundle;
|
||||||
return get_instance_arrange_poly(instance, config);
|
const Slic3r::DynamicPrintConfig& config = preset_bundle->full_config();
|
||||||
|
ArrangePolygon ap = get_instance_arrange_poly(instance, config);
|
||||||
|
|
||||||
|
// get filament types such as PLA, ABS, etc.
|
||||||
|
ap.filament_types.clear();
|
||||||
|
for (size_t i = 0; i < preset_bundle->filament_presets.size(); ++i) {
|
||||||
|
auto iter = std::find(ap.extrude_ids.begin(), ap.extrude_ids.end(), i + 1);
|
||||||
|
if (iter == ap.extrude_ids.end()) continue;
|
||||||
|
|
||||||
|
std::string filament_name = preset_bundle->filament_presets[i];
|
||||||
|
for (int f_index = 0; f_index < preset_bundle->filaments.size(); f_index++) {
|
||||||
|
PresetCollection *filament_presets = &preset_bundle->filaments;
|
||||||
|
Preset *preset = &filament_presets->preset(f_index);
|
||||||
|
int size = preset_bundle->filaments.size();
|
||||||
|
if (preset && filament_name.compare(preset->name) == 0) {
|
||||||
|
std::string display_filament_type;
|
||||||
|
std::string filament_type = preset->config.get_filament_type(display_filament_type);
|
||||||
|
ap.filament_types.push_back(filament_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrangeJob::prepare_selected() {
|
void ArrangeJob::prepare_selected() {
|
||||||
|
@ -633,7 +655,8 @@ void ArrangeJob::process()
|
||||||
BOOST_LOG_TRIVIAL(warning)<< "Arrange full params: "<< params.to_json();
|
BOOST_LOG_TRIVIAL(warning)<< "Arrange full params: "<< params.to_json();
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("arrange: items selected before arranging: %1%") % m_selected.size();
|
BOOST_LOG_TRIVIAL(info) << boost::format("arrange: items selected before arranging: %1%") % m_selected.size();
|
||||||
for (auto selected : m_selected) {
|
for (auto selected : m_selected) {
|
||||||
BOOST_LOG_TRIVIAL(debug) << selected.name << ", extruder: " << selected.extrude_ids.back() << ", bed: " << selected.bed_idx
|
BOOST_LOG_TRIVIAL(debug) << selected.name << ", extruder: " << VectorFormatter( selected.extrude_ids)
|
||||||
|
<< ", filament types: " << VectorFormatter(selected.filament_types) << ", bed: " << selected.bed_idx
|
||||||
<< ", filemant_type:" << selected.filament_temp_type << ", trans: " << selected.translation.transpose()
|
<< ", filemant_type:" << selected.filament_temp_type << ", trans: " << selected.translation.transpose()
|
||||||
<< ", rotation: " << selected.rotation;
|
<< ", rotation: " << selected.rotation;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue