WIP: Slicing from GUI.

This commit is contained in:
bubnikv 2018-10-18 18:06:40 +02:00
parent 857863102d
commit a45e9c0a03
6 changed files with 167 additions and 56 deletions

View file

@ -1238,7 +1238,7 @@ void GCode::process_layer(
const size_t single_object_idx)
{
assert(! layers.empty());
assert(! layer_tools.extruders.empty());
// assert(! layer_tools.extruders.empty());
// Either printing all copies of all objects, or just a single copy of a single object.
assert(single_object_idx == size_t(-1) || layers.size() == 1);

View file

@ -19,33 +19,28 @@
namespace Slic3r {
unsigned int Model::s_auto_extruder_id = 1;
unsigned int Model::s_auto_extruder_id = 1;
ModelID ModelBase::s_last_id = 0;
Model::Model(const Model &other)
Model::Model(const Model &rhs)
{
*this = rhs;
}
Model& Model::operator=(const Model &rhs)
{
m_id = rhs.m_id;
// copy materials
for (const auto &m : other.materials)
for (const auto &m : rhs.materials)
this->add_material(m.first, *m.second);
// copy objects
this->objects.reserve(other.objects.size());
for (const ModelObject *o : other.objects)
this->objects.reserve(rhs.objects.size());
for (const ModelObject *o : rhs.objects)
this->add_object(*o, true);
}
Model& Model::operator=(Model other)
{
this->swap(other);
return *this;
}
void Model::swap(Model &other)
{
std::swap(this->materials, other.materials);
std::swap(this->objects, other.objects);
}
Model Model::read_from_file(const std::string &input_file, DynamicPrintConfig *config, bool add_default_instances)
{
Model model;
@ -499,33 +494,11 @@ ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volum
for (ModelVolume *model_volume : other.volumes)
this->add_volume(*model_volume);
}
this->instances.reserve(other.instances.size());
for (const ModelInstance *model_instance : other.instances)
this->add_instance(*model_instance);
}
ModelObject& ModelObject::operator=(ModelObject other)
{
this->swap(other);
return *this;
}
void ModelObject::swap(ModelObject &other)
{
std::swap(this->m_id, other.m_id);
std::swap(this->input_file, other.input_file);
std::swap(this->instances, other.instances);
std::swap(this->volumes, other.volumes);
std::swap(this->config, other.config);
std::swap(this->layer_height_ranges, other.layer_height_ranges);
std::swap(this->layer_height_profile, other.layer_height_profile);
std::swap(this->layer_height_profile_valid, other.layer_height_profile_valid);
std::swap(this->origin_translation, other.origin_translation);
std::swap(m_bounding_box, other.m_bounding_box);
std::swap(m_bounding_box_valid, other.m_bounding_box_valid);
}
ModelObject::~ModelObject()
{
this->clear_volumes();

View file

@ -37,6 +37,8 @@ typedef size_t ModelID;
// Base for Model, ModelObject, ModelVolume, ModelInstance or ModelMaterial to provide a unique ID
// to synchronize the front end (UI) with the back end (BackgroundSlicingProcess / Print / PrintObject).
// Achtung! The s_last_id counter is not thread safe, so it is expected, that the ModelBase derived instances
// are only instantiated from the main thread.
class ModelBase
{
public:
@ -168,8 +170,6 @@ protected:
private:
ModelObject(Model *model) : layer_height_profile_valid(false), m_model(model), origin_translation(Vec3d::Zero()), m_bounding_box_valid(false) {}
ModelObject(Model *model, const ModelObject &other, bool copy_volumes = true);
ModelObject& operator= (ModelObject other);
void swap(ModelObject &other);
~ModelObject();
// Parent object, owning this ModelObject.
@ -352,9 +352,8 @@ public:
ModelObjectPtrs objects;
Model() {}
Model(const Model &other);
Model& operator= (Model other);
void swap(Model &other);
Model(const Model &rhs);
Model& operator=(const Model &rhs);
~Model() { this->clear_objects(); this->clear_materials(); }
// XXX: use fs::path ?