mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-21 20:18:17 +08:00
Fix for issue #2536
This commit is contained in:
parent
4a71c42f9b
commit
670a563226
@ -318,7 +318,7 @@ class AutoArranger {};
|
|||||||
// management and spatial index structures for acceleration.
|
// management and spatial index structures for acceleration.
|
||||||
template<class TBin>
|
template<class TBin>
|
||||||
class _ArrBase {
|
class _ArrBase {
|
||||||
protected:
|
public:
|
||||||
|
|
||||||
// Useful type shortcuts...
|
// Useful type shortcuts...
|
||||||
using Placer = TPacker<TBin>;
|
using Placer = TPacker<TBin>;
|
||||||
@ -328,6 +328,8 @@ protected:
|
|||||||
using Distance = TCoord<PointImpl>;
|
using Distance = TCoord<PointImpl>;
|
||||||
using Pile = TMultiShape<PolygonImpl>;
|
using Pile = TMultiShape<PolygonImpl>;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
Packer m_pck;
|
Packer m_pck;
|
||||||
PConfig m_pconf; // Placement configuration
|
PConfig m_pconf; // Placement configuration
|
||||||
double m_bin_area;
|
double m_bin_area;
|
||||||
@ -564,7 +566,10 @@ public:
|
|||||||
// 2D shape from top view.
|
// 2D shape from top view.
|
||||||
using ShapeData2D = std::vector<std::pair<Slic3r::ModelInstance*, Item>>;
|
using ShapeData2D = std::vector<std::pair<Slic3r::ModelInstance*, Item>>;
|
||||||
|
|
||||||
ShapeData2D projectModelFromTop(const Slic3r::Model &model, const WipeTowerInfo& wti) {
|
ShapeData2D projectModelFromTop(const Slic3r::Model &model,
|
||||||
|
const WipeTowerInfo &wti,
|
||||||
|
double tolerance)
|
||||||
|
{
|
||||||
ShapeData2D ret;
|
ShapeData2D ret;
|
||||||
|
|
||||||
// Count all the items on the bin (all the object's instances)
|
// Count all the items on the bin (all the object's instances)
|
||||||
@ -589,18 +594,29 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model, const WipeTowerInfo&
|
|||||||
ModelInstance *finst = objptr->instances.front();
|
ModelInstance *finst = objptr->instances.front();
|
||||||
Vec3d rotation = finst->get_rotation();
|
Vec3d rotation = finst->get_rotation();
|
||||||
rotation.z() = 0.;
|
rotation.z() = 0.;
|
||||||
Transform3d trafo_instance = Geometry::assemble_transform(Vec3d::Zero(), rotation, finst->get_scaling_factor(), finst->get_mirror());
|
Transform3d trafo_instance = Geometry::assemble_transform(
|
||||||
|
Vec3d::Zero(),
|
||||||
|
rotation,
|
||||||
|
finst->get_scaling_factor(),
|
||||||
|
finst->get_mirror());
|
||||||
Polygon p = objptr->convex_hull_2d(trafo_instance);
|
Polygon p = objptr->convex_hull_2d(trafo_instance);
|
||||||
|
|
||||||
assert(!p.points.empty());
|
assert(!p.points.empty());
|
||||||
|
|
||||||
// this may happen for malformed models, see: https://github.com/prusa3d/PrusaSlicer/issues/2209
|
// this may happen for malformed models, see:
|
||||||
if (p.points.empty())
|
// https://github.com/prusa3d/PrusaSlicer/issues/2209
|
||||||
continue;
|
if (p.points.empty()) continue;
|
||||||
|
|
||||||
|
if(tolerance > EPSILON) {
|
||||||
|
Polygons pp { p };
|
||||||
|
pp = p.simplify(double(scaled(tolerance)));
|
||||||
|
if (!pp.empty()) p = pp.front();
|
||||||
|
}
|
||||||
|
|
||||||
p.reverse();
|
p.reverse();
|
||||||
assert(!p.is_counter_clockwise());
|
assert(!p.is_counter_clockwise());
|
||||||
p.append(p.first_point());
|
|
||||||
clpath = Slic3rMultiPoint_to_ClipperPath(p);
|
clpath = Slic3rMultiPoint_to_ClipperPath(p);
|
||||||
|
auto firstp = clpath.front(); clpath.emplace_back(firstp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d rotation0 = objptr->instances.front()->get_rotation();
|
Vec3d rotation0 = objptr->instances.front()->get_rotation();
|
||||||
@ -782,7 +798,7 @@ bool arrange(Model &model, // The model with the geometries
|
|||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
// Get the 2D projected shapes with their 3D model instance pointers
|
// Get the 2D projected shapes with their 3D model instance pointers
|
||||||
auto shapemap = arr::projectModelFromTop(model, wti);
|
auto shapemap = arr::projectModelFromTop(model, wti, 0.1);
|
||||||
|
|
||||||
// Copy the references for the shapes only as the arranger expects a
|
// Copy the references for the shapes only as the arranger expects a
|
||||||
// sequence of objects convertible to Item or ClipperPolygon
|
// sequence of objects convertible to Item or ClipperPolygon
|
||||||
@ -883,7 +899,7 @@ void find_new_position(const Model &model,
|
|||||||
WipeTowerInfo& wti)
|
WipeTowerInfo& wti)
|
||||||
{
|
{
|
||||||
// Get the 2D projected shapes with their 3D model instance pointers
|
// Get the 2D projected shapes with their 3D model instance pointers
|
||||||
auto shapemap = arr::projectModelFromTop(model, wti);
|
auto shapemap = arr::projectModelFromTop(model, wti, 0.1);
|
||||||
|
|
||||||
// Copy the references for the shapes only as the arranger expects a
|
// Copy the references for the shapes only as the arranger expects a
|
||||||
// sequence of objects convertible to Item or ClipperPolygon
|
// sequence of objects convertible to Item or ClipperPolygon
|
||||||
|
Loading…
x
Reference in New Issue
Block a user