Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_sequential_limits
This commit is contained in:
commit
0d8a1c3d2a
@ -899,6 +899,39 @@ void its_shrink_to_fit(indexed_triangle_set &its)
|
||||
its.vertices.shrink_to_fit();
|
||||
}
|
||||
|
||||
template<typename TransformVertex>
|
||||
Polygon its_convex_hull_2d_above(const indexed_triangle_set &its, const TransformVertex &transform_fn, const float z)
|
||||
{
|
||||
Points all_pts;
|
||||
for (const stl_triangle_vertex_indices &tri : its.indices) {
|
||||
const Vec3f pts[3] = { transform_fn(its.vertices[tri(0)]), transform_fn(its.vertices[tri(1)]), transform_fn(its.vertices[tri(2)]) };
|
||||
int iprev = 3;
|
||||
for (int iedge = 0; iedge < 3; ++ iedge) {
|
||||
const Vec3f &p1 = pts[iprev];
|
||||
const Vec3f &p2 = pts[iedge];
|
||||
if ((p1.z() < z && p2.z() > z) || (p2.z() < z && p1.z() > z)) {
|
||||
// Edge crosses the z plane. Calculate intersection point with the plane.
|
||||
float t = z / (p2.z() - p1.z());
|
||||
all_pts.emplace_back(scaled<coord_t>(p1.x() + (p2.x() - p1.x()) * t), scaled<coord_t>(p2.x() + (p2.y() - p2.y()) * t));
|
||||
}
|
||||
if (p2.z() > z)
|
||||
all_pts.emplace_back(scaled<coord_t>(p2.x()), scaled<coord_t>(p2.y()));
|
||||
iprev = iedge;
|
||||
}
|
||||
}
|
||||
return Geometry::convex_hull(std::move(all_pts));
|
||||
}
|
||||
|
||||
Polygon its_convex_hull_2d_above(const indexed_triangle_set &its, const Matrix3f &m, const float z)
|
||||
{
|
||||
return its_convex_hull_2d_above(its, [m](const Vec3f &p){ return m * p; }, z);
|
||||
}
|
||||
|
||||
Polygon its_convex_hull_2d_above(const indexed_triangle_set &its, const Transform3f &t, const float z)
|
||||
{
|
||||
return its_convex_hull_2d_above(its, [t](const Vec3f &p){ return t * p; }, z);
|
||||
}
|
||||
|
||||
// Generate the vertex list for a cube solid of arbitrary size in X/Y/Z.
|
||||
TriangleMesh make_cube(double x, double y, double z)
|
||||
{
|
||||
|
@ -113,6 +113,9 @@ int its_compactify_vertices(indexed_triangle_set &its, bool shrink_to_fit = true
|
||||
// Shrink the vectors of its.vertices and its.faces to a minimum size by reallocating the two vectors.
|
||||
void its_shrink_to_fit(indexed_triangle_set &its);
|
||||
|
||||
Polygon its_convex_hull_2d_above(const indexed_triangle_set &its, const Matrix3f &m, const float z);
|
||||
Polygon its_convex_hull_2d_above(const indexed_triangle_set &its, const Transform3f &t, const float z);
|
||||
|
||||
TriangleMesh make_cube(double x, double y, double z);
|
||||
|
||||
// Generate a TriangleMesh of a cylinder
|
||||
|
@ -37,8 +37,12 @@ void RotoptimizeJob::prepare()
|
||||
|
||||
m_selected_object_ids.clear();
|
||||
m_selected_object_ids.reserve(sel.size());
|
||||
for (auto &[obj_idx, ignore] : sel)
|
||||
m_selected_object_ids.emplace_back(obj_idx);
|
||||
|
||||
for (const auto &s : sel) {
|
||||
int obj_id;
|
||||
std::tie(obj_id, std::ignore) = s;
|
||||
m_selected_object_ids.emplace_back(obj_id);
|
||||
}
|
||||
}
|
||||
|
||||
void RotoptimizeJob::process()
|
||||
|
Loading…
Reference in New Issue
Block a user