mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
Auto assignement of extruder, after object's splitting to parts
This commit is contained in:
parent
e92cf311db
commit
9993f2215d
2 changed files with 37 additions and 9 deletions
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
unsigned int Model::s_auto_extruder_id = 1;
|
||||||
|
|
||||||
Model::Model(const Model &other)
|
Model::Model(const Model &other)
|
||||||
{
|
{
|
||||||
// copy materials
|
// copy materials
|
||||||
|
@ -405,9 +407,8 @@ void Model::convert_multipart_object()
|
||||||
|
|
||||||
ModelObject* object = new ModelObject(this);
|
ModelObject* object = new ModelObject(this);
|
||||||
object->input_file = this->objects.front()->input_file;
|
object->input_file = this->objects.front()->input_file;
|
||||||
|
|
||||||
unsigned int auto_extruder_id = 1;
|
reset_auto_extruder_id();
|
||||||
char str_extruder[64];
|
|
||||||
|
|
||||||
for (const ModelObject* o : this->objects)
|
for (const ModelObject* o : this->objects)
|
||||||
for (const ModelVolume* v : o->volumes)
|
for (const ModelVolume* v : o->volumes)
|
||||||
|
@ -416,12 +417,7 @@ void Model::convert_multipart_object()
|
||||||
if (new_v != nullptr)
|
if (new_v != nullptr)
|
||||||
{
|
{
|
||||||
new_v->name = o->name;
|
new_v->name = o->name;
|
||||||
|
new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string());
|
||||||
sprintf(str_extruder, "%ud", auto_extruder_id);
|
|
||||||
new_v->config.set_deserialize("extruder", str_extruder);
|
|
||||||
|
|
||||||
if (++auto_extruder_id > 4)
|
|
||||||
auto_extruder_id = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +477,28 @@ bool Model::fits_print_volume(const FullPrintConfig &config) const
|
||||||
return print_volume.contains(transformed_bounding_box());
|
return print_volume.contains(transformed_bounding_box());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Model::get_auto_extruder_id()
|
||||||
|
{
|
||||||
|
unsigned int id = s_auto_extruder_id;
|
||||||
|
|
||||||
|
if (++s_auto_extruder_id > 4)
|
||||||
|
reset_auto_extruder_id();
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Model::get_auto_extruder_id_as_string()
|
||||||
|
{
|
||||||
|
char str_extruder[64];
|
||||||
|
sprintf(str_extruder, "%ud", get_auto_extruder_id());
|
||||||
|
return str_extruder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Model::reset_auto_extruder_id()
|
||||||
|
{
|
||||||
|
s_auto_extruder_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volumes) :
|
ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volumes) :
|
||||||
name(other.name),
|
name(other.name),
|
||||||
input_file(other.input_file),
|
input_file(other.input_file),
|
||||||
|
@ -1010,6 +1028,9 @@ size_t ModelVolume::split()
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
size_t ivolume = std::find(this->object->volumes.begin(), this->object->volumes.end(), this) - this->object->volumes.begin();
|
size_t ivolume = std::find(this->object->volumes.begin(), this->object->volumes.end(), this) - this->object->volumes.begin();
|
||||||
std::string name = this->name;
|
std::string name = this->name;
|
||||||
|
|
||||||
|
Model::reset_auto_extruder_id();
|
||||||
|
|
||||||
for (TriangleMesh *mesh : meshptrs) {
|
for (TriangleMesh *mesh : meshptrs) {
|
||||||
mesh->repair();
|
mesh->repair();
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
|
@ -1019,6 +1040,7 @@ size_t ModelVolume::split()
|
||||||
char str_idx[64];
|
char str_idx[64];
|
||||||
sprintf(str_idx, "_%d", idx + 1);
|
sprintf(str_idx, "_%d", idx + 1);
|
||||||
this->object->volumes[ivolume]->name = name + str_idx;
|
this->object->volumes[ivolume]->name = name + str_idx;
|
||||||
|
this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string());
|
||||||
delete mesh;
|
delete mesh;
|
||||||
++ idx;
|
++ idx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,6 +230,8 @@ private:
|
||||||
// all objects may share mutliple materials.
|
// all objects may share mutliple materials.
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
|
static unsigned int s_auto_extruder_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Materials are owned by a model and referenced by objects through t_model_material_id.
|
// Materials are owned by a model and referenced by objects through t_model_material_id.
|
||||||
// Single material may be shared by multiple models.
|
// Single material may be shared by multiple models.
|
||||||
|
@ -288,6 +290,10 @@ public:
|
||||||
bool fits_print_volume(const FullPrintConfig &config) const;
|
bool fits_print_volume(const FullPrintConfig &config) const;
|
||||||
|
|
||||||
void print_info() const { for (const ModelObject *o : this->objects) o->print_info(); }
|
void print_info() const { for (const ModelObject *o : this->objects) o->print_info(); }
|
||||||
|
|
||||||
|
static unsigned int get_auto_extruder_id();
|
||||||
|
static std::string get_auto_extruder_id_as_string();
|
||||||
|
static void reset_auto_extruder_id();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue