Fixed some issues with front end / back end synchronization.

This commit is contained in:
bubnikv 2018-11-05 17:52:55 +01:00
parent a4e6b326b5
commit 7ffa22191d
4 changed files with 12 additions and 17 deletions

View File

@ -254,6 +254,7 @@ void Model::clear_materials()
ModelMaterial* Model::add_material(t_model_material_id material_id)
{
assert(! material_id.empty());
ModelMaterial* material = this->get_material(material_id);
if (material == nullptr)
material = this->materials[material_id] = new ModelMaterial(this);
@ -262,6 +263,7 @@ ModelMaterial* Model::add_material(t_model_material_id material_id)
ModelMaterial* Model::add_material(t_model_material_id material_id, const ModelMaterial &other)
{
assert(! material_id.empty());
// delete existing material if any
ModelMaterial* material = this->get_material(material_id);
delete material;
@ -1134,7 +1136,8 @@ void ModelVolume::set_material_id(t_model_material_id material_id)
{
m_material_id = material_id;
// ensure m_material_id references an existing material
this->object->get_model()->add_material(material_id);
if (! material_id.empty())
this->object->get_model()->add_material(material_id);
}
ModelMaterial* ModelVolume::material() const
@ -1145,15 +1148,8 @@ ModelMaterial* ModelVolume::material() const
void ModelVolume::set_material(t_model_material_id material_id, const ModelMaterial &material)
{
m_material_id = material_id;
this->object->get_model()->add_material(material_id, material);
}
ModelMaterial* ModelVolume::assign_unique_material()
{
Model* model = this->get_object()->get_model();
// as material-id "0" is reserved by the AMF spec we start from 1
m_material_id = 1 + model->materials.size(); // watchout for implicit cast
return model->add_material(m_material_id);
if (! material_id.empty())
this->object->get_model()->add_material(material_id, material);
}
void ModelVolume::calculate_convex_hull()

View File

@ -22,7 +22,6 @@ class ModelInstance;
class ModelMaterial;
class ModelObject;
class ModelVolume;
class PresetBundle;
class Print;
typedef std::string t_model_material_id;
@ -323,8 +322,6 @@ public:
void rotate(double angle, const Vec3d& axis);
void mirror(Axis axis);
ModelMaterial* assign_unique_material();
void calculate_convex_hull();
const TriangleMesh& get_convex_hull() const;
@ -391,14 +388,15 @@ private:
mesh(std::move(mesh)), m_convex_hull(std::move(convex_hull)), m_type(MODEL_PART), object(object) {}
#if ENABLE_MODELVOLUME_TRANSFORM
// Copying an existing volume, therefore this volume will get a copy of the ID assigned.
ModelVolume(ModelObject *object, const ModelVolume &other) :
ModelBase(other), // copy the ID
name(other.name), mesh(other.mesh), m_convex_hull(other.m_convex_hull), config(other.config), m_type(other.m_type), object(object), m_transformation(other.m_transformation)
{
this->set_material_id(other.material_id());
}
// Providing a new mesh, therefore this volume will get a new unique ID assigned.
ModelVolume(ModelObject *object, const ModelVolume &other, const TriangleMesh &&mesh) :
ModelBase(other), // copy the ID
name(other.name), mesh(std::move(mesh)), config(other.config), m_type(other.m_type), object(object), m_transformation(other.m_transformation)
{
this->set_material_id(other.material_id());
@ -406,12 +404,15 @@ private:
calculate_convex_hull();
}
#else
// Copying an existing volume, therefore this volume will get a copy of the ID assigned.
ModelVolume(ModelObject *object, const ModelVolume &other) :
ModelBase(other), // copy the ID
name(other.name), mesh(other.mesh), m_convex_hull(other.m_convex_hull), config(other.config), m_type(other.m_type), object(object)
{
if (! other.material_id().empty())
this->set_material_id(other.material_id());
}
// Providing a new mesh, therefore this volume will get a new unique ID assigned.
ModelVolume(ModelObject *object, const ModelVolume &other, TriangleMesh &&mesh) :
name(other.name), mesh(std::move(mesh)), config(other.config), m_type(other.m_type), object(object)
{

View File

@ -633,7 +633,7 @@ void PrintObject::detect_surfaces_type()
// should be visible.
bool interface_shells = m_config.interface_shells.value;
for (int idx_region = 0; idx_region < m_print->m_regions.size(); ++ idx_region) {
for (int idx_region = 0; idx_region < this->region_volumes.size(); ++ idx_region) {
BOOST_LOG_TRIVIAL(debug) << "Detecting solid surfaces for region " << idx_region << " in parallel - start";
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
for (Layer *layer : m_layers)

View File

@ -286,8 +286,6 @@ ModelMaterial::attributes()
%code%{ THIS->set_type(ModelVolume::SUPPORT_BLOCKER); %};
size_t split(unsigned int max_extruders);
ModelMaterial* assign_unique_material();
};