1st installment of volumes centering fixes (WIP)
This commit is contained in:
parent
3e28905621
commit
80bae6dd98
10 changed files with 251 additions and 10 deletions
|
@ -1456,7 +1456,9 @@ namespace Slic3r {
|
||||||
|
|
||||||
// splits volume out of imported geometry
|
// splits volume out of imported geometry
|
||||||
unsigned int triangles_count = volume_data.last_triangle_id - volume_data.first_triangle_id + 1;
|
unsigned int triangles_count = volume_data.last_triangle_id - volume_data.first_triangle_id + 1;
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
ModelVolume* volume = object.add_volume(TriangleMesh());
|
ModelVolume* volume = object.add_volume(TriangleMesh());
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
stl_file& stl = volume->mesh.stl;
|
stl_file& stl = volume->mesh.stl;
|
||||||
stl.stats.type = inmemory;
|
stl.stats.type = inmemory;
|
||||||
stl.stats.number_of_facets = (uint32_t)triangles_count;
|
stl.stats.number_of_facets = (uint32_t)triangles_count;
|
||||||
|
@ -1477,7 +1479,9 @@ namespace Slic3r {
|
||||||
|
|
||||||
stl_get_size(&stl);
|
stl_get_size(&stl);
|
||||||
volume->mesh.repair();
|
volume->mesh.repair();
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
volume->center_geometry();
|
volume->center_geometry();
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
volume->calculate_convex_hull();
|
volume->calculate_convex_hull();
|
||||||
|
|
||||||
// apply volume's name and config data
|
// apply volume's name and config data
|
||||||
|
@ -1845,6 +1849,11 @@ namespace Slic3r {
|
||||||
{
|
{
|
||||||
stream << " <" << VERTEX_TAG << " ";
|
stream << " <" << VERTEX_TAG << " ";
|
||||||
Vec3d v = matrix * stl.v_shared[i].cast<double>();
|
Vec3d v = matrix * stl.v_shared[i].cast<double>();
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
std::cout << to_string((Vec3d)stl.v_shared[i].cast<double>()) << " --> " << to_string(v) << std::endl;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
stream << "x=\"" << v(0) << "\" ";
|
stream << "x=\"" << v(0) << "\" ";
|
||||||
stream << "y=\"" << v(1) << "\" ";
|
stream << "y=\"" << v(1) << "\" ";
|
||||||
stream << "z=\"" << v(2) << "\" />\n";
|
stream << "z=\"" << v(2) << "\" />\n";
|
||||||
|
|
|
@ -279,8 +279,10 @@ void AMFParserContext::startElement(const char *name, const char **atts)
|
||||||
node_type_new = NODE_TYPE_VERTICES;
|
node_type_new = NODE_TYPE_VERTICES;
|
||||||
else if (strcmp(name, "volume") == 0) {
|
else if (strcmp(name, "volume") == 0) {
|
||||||
assert(! m_volume);
|
assert(! m_volume);
|
||||||
m_volume = m_object->add_volume(TriangleMesh());
|
//#################################################################################################################################################################################
|
||||||
node_type_new = NODE_TYPE_VOLUME;
|
m_volume = m_object->add_volume(TriangleMesh());
|
||||||
|
//#################################################################################################################################################################################
|
||||||
|
node_type_new = NODE_TYPE_VOLUME;
|
||||||
}
|
}
|
||||||
} else if (m_path[2] == NODE_TYPE_INSTANCE) {
|
} else if (m_path[2] == NODE_TYPE_INSTANCE) {
|
||||||
assert(m_instance);
|
assert(m_instance);
|
||||||
|
|
|
@ -282,7 +282,9 @@ static void extract_model_from_archive(
|
||||||
group_to_model_object[group_id] = model_object;
|
group_to_model_object[group_id] = model_object;
|
||||||
} else {
|
} else {
|
||||||
// This is not the 1st mesh of a group. Add it to the ModelObject.
|
// This is not the 1st mesh of a group. Add it to the ModelObject.
|
||||||
|
//#################################################################################################################################################################################
|
||||||
volume = model_object->add_volume(std::move(mesh));
|
volume = model_object->add_volume(std::move(mesh));
|
||||||
|
//#################################################################################################################################################################################
|
||||||
volume->name = name;
|
volume->name = name;
|
||||||
}
|
}
|
||||||
// Set the extruder to the volume.
|
// Set the extruder to the volume.
|
||||||
|
|
|
@ -1303,13 +1303,24 @@ void Transformation::Flags::set(bool dont_translate, bool dont_rotate, bool dont
|
||||||
}
|
}
|
||||||
|
|
||||||
Transformation::Transformation()
|
Transformation::Transformation()
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
: m_offset(Vec3d::Zero())
|
: m_offset(Vec3d::Zero())
|
||||||
, m_rotation(Vec3d::Zero())
|
, m_rotation(Vec3d::Zero())
|
||||||
, m_scaling_factor(Vec3d::Ones())
|
, m_scaling_factor(Vec3d::Ones())
|
||||||
, m_mirror(Vec3d::Ones())
|
, m_mirror(Vec3d::Ones())
|
||||||
, m_matrix(Transform3d::Identity())
|
, m_matrix(Transform3d::Identity())
|
||||||
, m_dirty(false)
|
, m_dirty(false)
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
{
|
{
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
reset();
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
}
|
}
|
||||||
|
|
||||||
Transformation::Transformation(const Transform3d& transform)
|
Transformation::Transformation(const Transform3d& transform)
|
||||||
|
@ -1428,6 +1439,20 @@ void Transformation::set_from_transform(const Transform3d& transform)
|
||||||
// std::cout << "something went wrong in extracting data from matrix" << std::endl;
|
// std::cout << "something went wrong in extracting data from matrix" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
void Transformation::reset()
|
||||||
|
{
|
||||||
|
m_offset = Vec3d::Zero();
|
||||||
|
m_rotation = Vec3d::Zero();
|
||||||
|
m_scaling_factor = Vec3d::Ones();
|
||||||
|
m_mirror = Vec3d::Ones();
|
||||||
|
m_matrix = Transform3d::Identity();
|
||||||
|
m_dirty = false;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
const Transform3d& Transformation::get_matrix(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
|
const Transform3d& Transformation::get_matrix(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
|
||||||
{
|
{
|
||||||
if (m_dirty || m_flags.needs_update(dont_translate, dont_rotate, dont_scale, dont_mirror))
|
if (m_dirty || m_flags.needs_update(dont_translate, dont_rotate, dont_scale, dont_mirror))
|
||||||
|
|
|
@ -251,6 +251,12 @@ public:
|
||||||
|
|
||||||
void set_from_transform(const Transform3d& transform);
|
void set_from_transform(const Transform3d& transform);
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
void reset();
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
const Transform3d& get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const;
|
const Transform3d& get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const;
|
||||||
|
|
||||||
Transformation operator * (const Transformation& other) const;
|
Transformation operator * (const Transformation& other) const;
|
||||||
|
|
|
@ -164,7 +164,9 @@ ModelObject* Model::add_object(const char *name, const char *path, const Triangl
|
||||||
this->objects.push_back(new_object);
|
this->objects.push_back(new_object);
|
||||||
new_object->name = name;
|
new_object->name = name;
|
||||||
new_object->input_file = path;
|
new_object->input_file = path;
|
||||||
|
//#################################################################################################################################################################################
|
||||||
ModelVolume *new_volume = new_object->add_volume(mesh);
|
ModelVolume *new_volume = new_object->add_volume(mesh);
|
||||||
|
//#################################################################################################################################################################################
|
||||||
new_volume->name = name;
|
new_volume->name = name;
|
||||||
new_object->invalidate_bounding_box();
|
new_object->invalidate_bounding_box();
|
||||||
return new_object;
|
return new_object;
|
||||||
|
@ -176,7 +178,9 @@ ModelObject* Model::add_object(const char *name, const char *path, TriangleMesh
|
||||||
this->objects.push_back(new_object);
|
this->objects.push_back(new_object);
|
||||||
new_object->name = name;
|
new_object->name = name;
|
||||||
new_object->input_file = path;
|
new_object->input_file = path;
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
ModelVolume *new_volume = new_object->add_volume(std::move(mesh));
|
ModelVolume *new_volume = new_object->add_volume(std::move(mesh));
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
new_volume->name = name;
|
new_volume->name = name;
|
||||||
new_object->invalidate_bounding_box();
|
new_object->invalidate_bounding_box();
|
||||||
return new_object;
|
return new_object;
|
||||||
|
@ -481,10 +485,39 @@ void Model::convert_multipart_object(unsigned int max_extruders)
|
||||||
|
|
||||||
reset_auto_extruder_id();
|
reset_auto_extruder_id();
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
//#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
// for (const ModelObject* o : this->objects)
|
||||||
|
// {
|
||||||
|
// const ModelInstance* i = o->instances.front();
|
||||||
|
// const Geometry::Transformation& t = i->get_transformation();
|
||||||
|
// for (const ModelVolume* v : o->volumes)
|
||||||
|
// {
|
||||||
|
////$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
|
// ModelVolume* new_v = object->add_volume(*v);
|
||||||
|
////$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
|
// if (new_v != nullptr)
|
||||||
|
// {
|
||||||
|
// new_v->name = o->name;
|
||||||
|
// new_v->set_transformation(t * new_v->get_transformation());
|
||||||
|
// new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string(max_extruders));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (const ModelInstance* i : this->objects.front()->instances)
|
||||||
|
// {
|
||||||
|
// ModelInstance* inst = object->add_instance(*i);
|
||||||
|
// inst->set_transformation(Geometry::Transformation());
|
||||||
|
// }
|
||||||
|
//#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
for (const ModelObject* o : this->objects)
|
for (const ModelObject* o : this->objects)
|
||||||
for (const ModelVolume* v : o->volumes)
|
for (const ModelVolume* v : o->volumes)
|
||||||
{
|
{
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
ModelVolume* new_v = object->add_volume(*v);
|
ModelVolume* new_v = object->add_volume(*v);
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
if (new_v != nullptr)
|
if (new_v != nullptr)
|
||||||
{
|
{
|
||||||
new_v->name = o->name;
|
new_v->name = o->name;
|
||||||
|
@ -494,6 +527,9 @@ void Model::convert_multipart_object(unsigned int max_extruders)
|
||||||
|
|
||||||
for (const ModelInstance* i : this->objects.front()->instances)
|
for (const ModelInstance* i : this->objects.front()->instances)
|
||||||
object->add_instance(*i);
|
object->add_instance(*i);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
//#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
this->clear_objects();
|
this->clear_objects();
|
||||||
this->objects.push_back(object);
|
this->objects.push_back(object);
|
||||||
|
@ -641,6 +677,11 @@ ModelVolume* ModelObject::add_volume(const TriangleMesh &mesh)
|
||||||
{
|
{
|
||||||
ModelVolume* v = new ModelVolume(this, mesh);
|
ModelVolume* v = new ModelVolume(this, mesh);
|
||||||
this->volumes.push_back(v);
|
this->volumes.push_back(v);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
v->center_geometry();
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -649,6 +690,11 @@ ModelVolume* ModelObject::add_volume(TriangleMesh &&mesh)
|
||||||
{
|
{
|
||||||
ModelVolume* v = new ModelVolume(this, std::move(mesh));
|
ModelVolume* v = new ModelVolume(this, std::move(mesh));
|
||||||
this->volumes.push_back(v);
|
this->volumes.push_back(v);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
v->center_geometry();
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -657,6 +703,11 @@ ModelVolume* ModelObject::add_volume(const ModelVolume &other)
|
||||||
{
|
{
|
||||||
ModelVolume* v = new ModelVolume(this, other);
|
ModelVolume* v = new ModelVolume(this, other);
|
||||||
this->volumes.push_back(v);
|
this->volumes.push_back(v);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
v->center_geometry();
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -665,6 +716,11 @@ ModelVolume* ModelObject::add_volume(const ModelVolume &other, TriangleMesh &&me
|
||||||
{
|
{
|
||||||
ModelVolume* v = new ModelVolume(this, other, std::move(mesh));
|
ModelVolume* v = new ModelVolume(this, other, std::move(mesh));
|
||||||
this->volumes.push_back(v);
|
this->volumes.push_back(v);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
v->center_geometry();
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -675,6 +731,30 @@ void ModelObject::delete_volume(size_t idx)
|
||||||
delete *i;
|
delete *i;
|
||||||
this->volumes.erase(i);
|
this->volumes.erase(i);
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
if (this->volumes.size() == 1)
|
||||||
|
{
|
||||||
|
// only one volume left
|
||||||
|
// we need to collapse the volume transform into the instances transforms because now when selecting this volume
|
||||||
|
// it will be seen as a single full instance ans so its volume transform may be ignored
|
||||||
|
ModelVolume* v = this->volumes.front();
|
||||||
|
Transform3d v_t = v->get_transformation().get_matrix();
|
||||||
|
// Transform3d v_t = v->get_transformation().get_matrix(true);
|
||||||
|
for (ModelInstance* inst : this->instances)
|
||||||
|
{
|
||||||
|
// Vec3d offset = inst->get_offset();
|
||||||
|
inst->set_transformation(Geometry::Transformation(inst->get_transformation().get_matrix() * v_t));
|
||||||
|
// inst->set_transformation(Geometry::Transformation(inst->get_transformation().get_matrix(true) * v_t));
|
||||||
|
// inst->set_offset(offset);
|
||||||
|
}
|
||||||
|
Geometry::Transformation t;
|
||||||
|
// t.set_offset(v->get_offset());
|
||||||
|
v->set_transformation(t);
|
||||||
|
v->set_new_unique_id();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
if (this->volumes.size() == 1)
|
if (this->volumes.size() == 1)
|
||||||
{
|
{
|
||||||
// only one volume left
|
// only one volume left
|
||||||
|
@ -691,6 +771,9 @@ void ModelObject::delete_volume(size_t idx)
|
||||||
v->set_offset(Vec3d::Zero());
|
v->set_offset(Vec3d::Zero());
|
||||||
v->set_new_unique_id();
|
v->set_new_unique_id();
|
||||||
}
|
}
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
|
@ -868,15 +951,39 @@ BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
BoundingBoxf3 ModelObject::full_raw_mesh_bounding_box() const
|
||||||
|
{
|
||||||
|
BoundingBoxf3 bb;
|
||||||
|
for (const ModelVolume *v : this->volumes)
|
||||||
|
{
|
||||||
|
TriangleMesh vol_mesh(v->mesh);
|
||||||
|
vol_mesh.transform(v->get_matrix());
|
||||||
|
bb.merge(vol_mesh.bounding_box());
|
||||||
|
}
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
void ModelObject::center_around_origin()
|
void ModelObject::center_around_origin()
|
||||||
{
|
{
|
||||||
// calculate the displacements needed to
|
// calculate the displacements needed to
|
||||||
// center this object around the origin
|
// center this object around the origin
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
BoundingBoxf3 bb = full_raw_mesh_bounding_box();
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
BoundingBoxf3 bb;
|
BoundingBoxf3 bb;
|
||||||
for (ModelVolume *v : this->volumes)
|
for (ModelVolume *v : this->volumes)
|
||||||
if (v->is_model_part())
|
if (v->is_model_part())
|
||||||
bb.merge(v->mesh.bounding_box());
|
bb.merge(v->mesh.bounding_box());
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// Shift is the vector from the center of the bounding box to the origin
|
// Shift is the vector from the center of the bounding box to the origin
|
||||||
Vec3d shift = -bb.center();
|
Vec3d shift = -bb.center();
|
||||||
|
|
||||||
|
@ -1040,9 +1147,12 @@ ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, b
|
||||||
|
|
||||||
volume->set_transformation(Geometry::Transformation(instance_matrix * volume_matrix));
|
volume->set_transformation(Geometry::Transformation(instance_matrix * volume_matrix));
|
||||||
|
|
||||||
|
//#################################################################################################################################################################################
|
||||||
if (keep_upper) { upper->add_volume(*volume); }
|
if (keep_upper) { upper->add_volume(*volume); }
|
||||||
if (keep_lower) { lower->add_volume(*volume); }
|
if (keep_lower) { lower->add_volume(*volume); }
|
||||||
} else {
|
//#################################################################################################################################################################################
|
||||||
|
}
|
||||||
|
else {
|
||||||
TriangleMesh upper_mesh, lower_mesh;
|
TriangleMesh upper_mesh, lower_mesh;
|
||||||
|
|
||||||
// Transform the mesh by the combined transformation matrix
|
// Transform the mesh by the combined transformation matrix
|
||||||
|
@ -1067,14 +1177,18 @@ ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, b
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keep_upper && upper_mesh.facets_count() > 0) {
|
if (keep_upper && upper_mesh.facets_count() > 0) {
|
||||||
ModelVolume* vol = upper->add_volume(upper_mesh);
|
//#################################################################################################################################################################################
|
||||||
vol->name = volume->name;
|
ModelVolume* vol = upper->add_volume(upper_mesh);
|
||||||
|
//#################################################################################################################################################################################
|
||||||
|
vol->name = volume->name;
|
||||||
vol->config = volume->config;
|
vol->config = volume->config;
|
||||||
vol->set_material(volume->material_id(), *volume->material());
|
vol->set_material(volume->material_id(), *volume->material());
|
||||||
}
|
}
|
||||||
if (keep_lower && lower_mesh.facets_count() > 0) {
|
if (keep_lower && lower_mesh.facets_count() > 0) {
|
||||||
ModelVolume* vol = lower->add_volume(lower_mesh);
|
//#################################################################################################################################################################################
|
||||||
vol->name = volume->name;
|
ModelVolume* vol = lower->add_volume(lower_mesh);
|
||||||
|
//#################################################################################################################################################################################
|
||||||
|
vol->name = volume->name;
|
||||||
vol->config = volume->config;
|
vol->config = volume->config;
|
||||||
vol->set_material(volume->material_id(), *volume->material());
|
vol->set_material(volume->material_id(), *volume->material());
|
||||||
|
|
||||||
|
@ -1152,8 +1266,10 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
|
||||||
new_object->instances.reserve(this->instances.size());
|
new_object->instances.reserve(this->instances.size());
|
||||||
for (const ModelInstance *model_instance : this->instances)
|
for (const ModelInstance *model_instance : this->instances)
|
||||||
new_object->add_instance(*model_instance);
|
new_object->add_instance(*model_instance);
|
||||||
|
//#################################################################################################################################################################################
|
||||||
ModelVolume* new_vol = new_object->add_volume(*volume, std::move(*mesh));
|
ModelVolume* new_vol = new_object->add_volume(*volume, std::move(*mesh));
|
||||||
new_vol->center_geometry();
|
new_vol->center_geometry();
|
||||||
|
//#################################################################################################################################################################################
|
||||||
|
|
||||||
for (ModelInstance* model_instance : new_object->instances)
|
for (ModelInstance* model_instance : new_object->instances)
|
||||||
{
|
{
|
||||||
|
@ -1321,10 +1437,24 @@ int ModelVolume::extruder_id() const
|
||||||
|
|
||||||
void ModelVolume::center_geometry()
|
void ModelVolume::center_geometry()
|
||||||
{
|
{
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
Vec3d shift = mesh.bounding_box().center();
|
||||||
|
if (!shift.isApprox(Vec3d::Zero()))
|
||||||
|
{
|
||||||
|
mesh.translate(-(float)shift(0), -(float)shift(1), -(float)shift(2));
|
||||||
|
m_convex_hull.translate(-(float)shift(0), -(float)shift(1), -(float)shift(2));
|
||||||
|
translate(shift);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
Vec3d shift = -mesh.bounding_box().center();
|
Vec3d shift = -mesh.bounding_box().center();
|
||||||
mesh.translate((float)shift(0), (float)shift(1), (float)shift(2));
|
mesh.translate((float)shift(0), (float)shift(1), (float)shift(2));
|
||||||
m_convex_hull.translate((float)shift(0), (float)shift(1), (float)shift(2));
|
m_convex_hull.translate((float)shift(0), (float)shift(1), (float)shift(2));
|
||||||
translate(-shift);
|
translate(-shift);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelVolume::calculate_convex_hull()
|
void ModelVolume::calculate_convex_hull()
|
||||||
|
@ -1400,7 +1530,9 @@ size_t ModelVolume::split(unsigned int max_extruders)
|
||||||
this->object->volumes.insert(this->object->volumes.begin() + (++ivolume), new ModelVolume(object, *this, std::move(*mesh)));
|
this->object->volumes.insert(this->object->volumes.begin() + (++ivolume), new ModelVolume(object, *this, std::move(*mesh)));
|
||||||
|
|
||||||
this->object->volumes[ivolume]->set_offset(Vec3d::Zero());
|
this->object->volumes[ivolume]->set_offset(Vec3d::Zero());
|
||||||
|
//#################################################################################################################################################################################
|
||||||
this->object->volumes[ivolume]->center_geometry();
|
this->object->volumes[ivolume]->center_geometry();
|
||||||
|
//#################################################################################################################################################################################
|
||||||
this->object->volumes[ivolume]->translate(offset);
|
this->object->volumes[ivolume]->translate(offset);
|
||||||
this->object->volumes[ivolume]->name = name + "_" + std::to_string(idx + 1);
|
this->object->volumes[ivolume]->name = name + "_" + std::to_string(idx + 1);
|
||||||
this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string(max_extruders));
|
this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string(max_extruders));
|
||||||
|
|
|
@ -223,6 +223,12 @@ public:
|
||||||
BoundingBoxf3 raw_bounding_box() const;
|
BoundingBoxf3 raw_bounding_box() const;
|
||||||
// A snug bounding box around the transformed non-modifier object volumes.
|
// A snug bounding box around the transformed non-modifier object volumes.
|
||||||
BoundingBoxf3 instance_bounding_box(size_t instance_idx, bool dont_translate = false) const;
|
BoundingBoxf3 instance_bounding_box(size_t instance_idx, bool dont_translate = false) const;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
// Bounding box of non-transformed (non-rotated, non-scaled, non-translated) sum of all object volumes.
|
||||||
|
BoundingBoxf3 full_raw_mesh_bounding_box() const;
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
void center_around_origin();
|
void center_around_origin();
|
||||||
void ensure_on_bed();
|
void ensure_on_bed();
|
||||||
void translate_instances(const Vec3d& vector);
|
void translate_instances(const Vec3d& vector);
|
||||||
|
|
|
@ -62,3 +62,14 @@
|
||||||
#define ENABLE_GENERIC_SUBPARTS_PLACEMENT (1 && ENABLE_1_42_0_ALPHA4)
|
#define ENABLE_GENERIC_SUBPARTS_PLACEMENT (1 && ENABLE_1_42_0_ALPHA4)
|
||||||
// Reworked management of bed shape changes
|
// Reworked management of bed shape changes
|
||||||
#define ENABLE_REWORKED_BED_SHAPE_CHANGE (1 && ENABLE_1_42_0_ALPHA4)
|
#define ENABLE_REWORKED_BED_SHAPE_CHANGE (1 && ENABLE_1_42_0_ALPHA4)
|
||||||
|
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
//====================
|
||||||
|
// 1.42.0.alpha5 techs
|
||||||
|
//====================
|
||||||
|
#define ENABLE_1_42_0_ALPHA5 1
|
||||||
|
|
||||||
|
// Bunch of fixes related to volumes centering
|
||||||
|
#define ENABLE_VOLUMES_CENTERING_FIXES (1 && ENABLE_1_42_0_ALPHA5)
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
|
@ -845,9 +845,17 @@ void ObjectList::load_part( ModelObject* model_object,
|
||||||
delta = model_object->origin_translation - object->origin_translation;
|
delta = model_object->origin_translation - object->origin_translation;
|
||||||
}
|
}
|
||||||
for (auto volume : object->volumes) {
|
for (auto volume : object->volumes) {
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
volume->center_geometry();
|
volume->center_geometry();
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
volume->translate(delta);
|
volume->translate(delta);
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
auto new_volume = model_object->add_volume(*volume);
|
auto new_volume = model_object->add_volume(*volume);
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
new_volume->set_type(static_cast<ModelVolume::Type>(type));
|
new_volume->set_type(static_cast<ModelVolume::Type>(type));
|
||||||
new_volume->name = boost::filesystem::path(input_file).filename().string();
|
new_volume->name = boost::filesystem::path(input_file).filename().string();
|
||||||
|
|
||||||
|
@ -892,13 +900,21 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const int
|
||||||
}
|
}
|
||||||
mesh.repair();
|
mesh.repair();
|
||||||
|
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
auto new_volume = (*m_objects)[obj_idx]->add_volume(mesh);
|
auto new_volume = (*m_objects)[obj_idx]->add_volume(mesh);
|
||||||
|
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
new_volume->set_type(static_cast<ModelVolume::Type>(type));
|
new_volume->set_type(static_cast<ModelVolume::Type>(type));
|
||||||
|
|
||||||
#if !ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
#if !ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||||
new_volume->set_offset(Vec3d(0.0, 0.0, (*m_objects)[obj_idx]->origin_translation(2) - mesh.stl.stats.min(2)));
|
new_volume->set_offset(Vec3d(0.0, 0.0, (*m_objects)[obj_idx]->origin_translation(2) - mesh.stl.stats.min(2)));
|
||||||
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
new_volume->center_geometry();
|
new_volume->center_geometry();
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||||
|
|
|
@ -1319,6 +1319,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||||
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
|
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
|
||||||
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
|
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
|
||||||
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
|
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
bool config_applied = false;
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
Slic3r::Model model;
|
Slic3r::Model model;
|
||||||
try {
|
try {
|
||||||
|
@ -1344,6 +1349,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||||
Preset::normalize(config);
|
Preset::normalize(config);
|
||||||
wxGetApp().preset_bundle->load_config_model(filename.string(), std::move(config));
|
wxGetApp().preset_bundle->load_config_model(filename.string(), std::move(config));
|
||||||
wxGetApp().load_current_presets();
|
wxGetApp().load_current_presets();
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
config_applied = true;
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
}
|
}
|
||||||
wxGetApp().app_config->update_config_dir(path.parent_path().string());
|
wxGetApp().app_config->update_config_dir(path.parent_path().string());
|
||||||
}
|
}
|
||||||
|
@ -1363,7 +1373,12 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||||
{
|
{
|
||||||
// The model should now be initialized
|
// The model should now be initialized
|
||||||
|
|
||||||
if (model.looks_like_multipart_object()) {
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
if (!type_3mf && !(type_any_amf && config_applied)) {
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
if (model.looks_like_multipart_object()) {
|
||||||
// wxMessageDialog dlg(q, _(L(
|
// wxMessageDialog dlg(q, _(L(
|
||||||
// "This file contains several objects positioned at multiple heights. "
|
// "This file contains several objects positioned at multiple heights. "
|
||||||
// "Instead of considering them as multiple objects, should I consider\n"
|
// "Instead of considering them as multiple objects, should I consider\n"
|
||||||
|
@ -1372,14 +1387,31 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||||
// if (dlg.ShowModal() == wxID_YES) {
|
// if (dlg.ShowModal() == wxID_YES) {
|
||||||
model.convert_multipart_object(nozzle_dmrs->values.size());
|
model.convert_multipart_object(nozzle_dmrs->values.size());
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
if (type_3mf || type_any_amf) {
|
if (type_3mf || type_any_amf) {
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
for (ModelObject* model_object : model.objects) {
|
for (ModelObject* model_object : model.objects) {
|
||||||
model_object->center_around_origin();
|
model_object->center_around_origin();
|
||||||
model_object->ensure_on_bed();
|
model_object->ensure_on_bed();
|
||||||
}
|
}
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
}
|
}
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// check multi-part object adding for the SLA-printing
|
// check multi-part object adding for the SLA-printing
|
||||||
if (printer_technology == ptSLA)
|
if (printer_technology == ptSLA)
|
||||||
|
|
Loading…
Reference in a new issue