mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-27 02:31:10 -06:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_sinking_objects_collision
This commit is contained in:
commit
2e779d8594
16 changed files with 166 additions and 67 deletions
|
|
@ -617,19 +617,35 @@ void AMFParserContext::endElement(const char * /* name */)
|
|||
case NODE_TYPE_VOLUME:
|
||||
{
|
||||
assert(m_object && m_volume);
|
||||
// Verify validity of face indices.
|
||||
for (Vec3i face : m_volume_facets)
|
||||
for (unsigned int tri_id : face)
|
||||
if (tri_id < 0 || tri_id >= m_object_vertices.size()) {
|
||||
this->stop("Malformed triangle mesh");
|
||||
return;
|
||||
}
|
||||
if (m_volume_facets.empty()) {
|
||||
this->stop("An empty triangle mesh found");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
TriangleMesh triangle_mesh { std::move(m_object_vertices), std::move(m_volume_facets) };
|
||||
if (triangle_mesh.volume() < 0)
|
||||
triangle_mesh.flip_triangles();
|
||||
m_volume->set_mesh(std::move(triangle_mesh));
|
||||
// Verify validity of face indices, find the vertex span.
|
||||
int min_id = m_volume_facets.front()[0];
|
||||
int max_id = min_id;
|
||||
for (const Vec3i& face : m_volume_facets) {
|
||||
for (const int tri_id : face) {
|
||||
if (tri_id < 0 || tri_id >= int(m_object_vertices.size())) {
|
||||
this->stop("Malformed triangle mesh");
|
||||
return;
|
||||
}
|
||||
min_id = std::min(min_id, tri_id);
|
||||
max_id = std::max(max_id, tri_id);
|
||||
}
|
||||
}
|
||||
|
||||
// rebase indices to the current vertices list
|
||||
for (Vec3i &face : m_volume_facets)
|
||||
face -= Vec3i(min_id, min_id, min_id);
|
||||
|
||||
indexed_triangle_set its { std::move(m_volume_facets), { m_object_vertices.begin() + min_id, m_object_vertices.begin() + max_id + 1 } };
|
||||
its_compactify_vertices(its);
|
||||
if (its_volume(its) < 0)
|
||||
its_flip_triangles(its);
|
||||
m_volume->set_mesh(std::move(its));
|
||||
}
|
||||
|
||||
// stores the volume matrix taken from the metadata, if present
|
||||
|
|
@ -646,7 +662,6 @@ void AMFParserContext::endElement(const char * /* name */)
|
|||
|
||||
m_volume->calculate_convex_hull();
|
||||
m_volume_facets.clear();
|
||||
m_object_vertices.clear();
|
||||
m_volume = nullptr;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1456,7 +1456,7 @@ void GCodeProcessor::apply_config_simplify3d(const std::string& filename)
|
|||
|
||||
begin = skip_whitespaces(begin, end);
|
||||
end = remove_eols(begin, end);
|
||||
if (begin != end)
|
||||
if (begin != end) {
|
||||
if (*begin == ';') {
|
||||
// Comment.
|
||||
begin = skip_whitespaces(++ begin, end);
|
||||
|
|
@ -1485,6 +1485,7 @@ void GCodeProcessor::apply_config_simplify3d(const std::string& filename)
|
|||
// Some non-empty G-code line detected, stop parsing config comments.
|
||||
reader.quit_parsing();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (m_result.extruders_count == 0)
|
||||
|
|
|
|||
|
|
@ -1300,7 +1300,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
num_extruders,
|
||||
painting_extruders,
|
||||
*print_object_regions,
|
||||
[&print_object, it_print_object, it_print_object_end, &update_apply_status](const PrintRegionConfig &old_config, const PrintRegionConfig &new_config, const t_config_option_keys &diff_keys) {
|
||||
[it_print_object, it_print_object_end, &update_apply_status](const PrintRegionConfig &old_config, const PrintRegionConfig &new_config, const t_config_option_keys &diff_keys) {
|
||||
for (auto it = it_print_object; it != it_print_object_end; ++it)
|
||||
if ((*it)->m_shared_regions != nullptr)
|
||||
update_apply_status((*it)->invalidate_state_by_config_options(old_config, new_config, diff_keys));
|
||||
|
|
|
|||
|
|
@ -325,20 +325,24 @@ void TriangleMesh::mirror(const Axis axis)
|
|||
void TriangleMesh::transform(const Transform3d& t, bool fix_left_handed)
|
||||
{
|
||||
its_transform(its, t);
|
||||
if (fix_left_handed && t.matrix().block(0, 0, 3, 3).determinant() < 0.)
|
||||
double det = t.matrix().block(0, 0, 3, 3).determinant();
|
||||
if (fix_left_handed && det < 0.) {
|
||||
its_flip_triangles(its);
|
||||
else
|
||||
m_stats.volume = - m_stats.volume;
|
||||
det = -det;
|
||||
}
|
||||
m_stats.volume *= det;
|
||||
update_bounding_box(this->its, this->m_stats);
|
||||
}
|
||||
|
||||
void TriangleMesh::transform(const Matrix3d& m, bool fix_left_handed)
|
||||
{
|
||||
its_transform(its, m);
|
||||
if (fix_left_handed && m.determinant() < 0.)
|
||||
double det = m.block(0, 0, 3, 3).determinant();
|
||||
if (fix_left_handed && det < 0.) {
|
||||
its_flip_triangles(its);
|
||||
else
|
||||
m_stats.volume = - m_stats.volume;
|
||||
det = -det;
|
||||
}
|
||||
m_stats.volume *= det;
|
||||
update_bounding_box(this->its, this->m_stats);
|
||||
}
|
||||
|
||||
|
|
@ -486,7 +490,7 @@ TriangleMesh TriangleMesh::convex_hull_3d() const
|
|||
std::vector<int> map_dst_vertices;
|
||||
#ifndef NDEBUG
|
||||
Vec3f centroid = Vec3f::Zero();
|
||||
for (auto pt : this->its.vertices)
|
||||
for (const stl_vertex& pt : this->its.vertices)
|
||||
centroid += pt;
|
||||
centroid /= float(this->its.vertices.size());
|
||||
#endif // NDEBUG
|
||||
|
|
@ -1282,7 +1286,7 @@ bool its_write_stl_ascii(const char *file, const char *label, const std::vector<
|
|||
|
||||
fprintf(fp, "solid %s\n", label);
|
||||
|
||||
for (const stl_triangle_vertex_indices face : indices) {
|
||||
for (const stl_triangle_vertex_indices& face : indices) {
|
||||
Vec3f vertex[3] = { vertices[face(0)], vertices[face(1)], vertices[face(2)] };
|
||||
Vec3f normal = (vertex[1] - vertex[0]).cross(vertex[2] - vertex[1]).normalized();
|
||||
fprintf(fp, " facet normal % .8E % .8E % .8E\n", normal(0), normal(1), normal(2));
|
||||
|
|
@ -1322,7 +1326,7 @@ bool its_write_stl_binary(const char *file, const char *label, const std::vector
|
|||
stl_facet f;
|
||||
f.extra[0] = 0;
|
||||
f.extra[1] = 0;
|
||||
for (const stl_triangle_vertex_indices face : indices) {
|
||||
for (const stl_triangle_vertex_indices& face : indices) {
|
||||
f.vertex[0] = vertices[face(0)];
|
||||
f.vertex[1] = vertices[face(1)];
|
||||
f.vertex[2] = vertices[face(2)];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue