Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2018-02-28 13:41:04 +0300
committerEnrico Turri <enricoturri@seznam.cz>2018-02-28 13:41:04 +0300
commit0ec68eb35b0c863aece86fee98807cb299d69124 (patch)
tree6ce130d6a3b39dbc4d3c9c1feaca55d948583753 /xs/src/libslic3r/TriangleMesh.cpp
parentbcc68ca45062503cdf0e758ef57306b55b75d004 (diff)
Fix for issue #661 (ExPolygons generation)
Diffstat (limited to 'xs/src/libslic3r/TriangleMesh.cpp')
-rw-r--r--xs/src/libslic3r/TriangleMesh.cpp69
1 files changed, 39 insertions, 30 deletions
diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp
index 1cdfb091d..ffbe507ef 100644
--- a/xs/src/libslic3r/TriangleMesh.cpp
+++ b/xs/src/libslic3r/TriangleMesh.cpp
@@ -1186,40 +1186,46 @@ void TriangleMeshSlicer::make_expolygons(const Polygons &loops, ExPolygons* slic
loops correctly in some edge cases when original model had overlapping facets
*/
- std::vector<double> area;
- std::vector<size_t> sorted_area; // vector of indices
- for (Polygons::const_iterator loop = loops.begin(); loop != loops.end(); ++ loop) {
- area.push_back(loop->area());
- sorted_area.push_back(loop - loops.begin());
- }
-
- // outer first
- std::sort(sorted_area.begin(), sorted_area.end(),
- [&area](size_t a, size_t b) { return std::abs(area[a]) > std::abs(area[b]); });
-
- // we don't perform a safety offset now because it might reverse cw loops
- Polygons p_slices;
- for (std::vector<size_t>::const_iterator loop_idx = sorted_area.begin(); loop_idx != sorted_area.end(); ++ loop_idx) {
- /* we rely on the already computed area to determine the winding order
- of the loops, since the Orientation() function provided by Clipper
- would do the same, thus repeating the calculation */
- Polygons::const_iterator loop = loops.begin() + *loop_idx;
- if (area[*loop_idx] > +EPSILON)
- p_slices.push_back(*loop);
- else if (area[*loop_idx] < -EPSILON)
- //FIXME This is arbitrary and possibly very slow.
- // If the hole is inside a polygon, then there is no need to diff.
- // If the hole intersects a polygon boundary, then diff it, but then
- // there is no guarantee of an ordering of the loops.
- // Maybe we can test for the intersection before running the expensive diff algorithm?
- p_slices = diff(p_slices, *loop);
- }
+ /* The following lines are commented out because they can generate wrong polygons,
+ see for example issue #661 */
+
+ //std::vector<double> area;
+ //std::vector<size_t> sorted_area; // vector of indices
+ //for (Polygons::const_iterator loop = loops.begin(); loop != loops.end(); ++ loop) {
+ // area.push_back(loop->area());
+ // sorted_area.push_back(loop - loops.begin());
+ //}
+ //
+ //// outer first
+ //std::sort(sorted_area.begin(), sorted_area.end(),
+ // [&area](size_t a, size_t b) { return std::abs(area[a]) > std::abs(area[b]); });
+
+ //// we don't perform a safety offset now because it might reverse cw loops
+ //Polygons p_slices;
+ //for (std::vector<size_t>::const_iterator loop_idx = sorted_area.begin(); loop_idx != sorted_area.end(); ++ loop_idx) {
+ // /* we rely on the already computed area to determine the winding order
+ // of the loops, since the Orientation() function provided by Clipper
+ // would do the same, thus repeating the calculation */
+ // Polygons::const_iterator loop = loops.begin() + *loop_idx;
+ // if (area[*loop_idx] > +EPSILON)
+ // p_slices.push_back(*loop);
+ // else if (area[*loop_idx] < -EPSILON)
+ // //FIXME This is arbitrary and possibly very slow.
+ // // If the hole is inside a polygon, then there is no need to diff.
+ // // If the hole intersects a polygon boundary, then diff it, but then
+ // // there is no guarantee of an ordering of the loops.
+ // // Maybe we can test for the intersection before running the expensive diff algorithm?
+ // p_slices = diff(p_slices, *loop);
+ //}
// perform a safety offset to merge very close facets (TODO: find test case for this)
double safety_offset = scale_(0.0499);
//FIXME see https://github.com/prusa3d/Slic3r/issues/520
// double safety_offset = scale_(0.0001);
- ExPolygons ex_slices = offset2_ex(p_slices, +safety_offset, -safety_offset);
+
+ /* The following line is commented out because it can generate wrong polygons,
+ see for example issue #661 */
+ //ExPolygons ex_slices = offset2_ex(p_slices, +safety_offset, -safety_offset);
#ifdef SLIC3R_TRIANGLEMESH_DEBUG
size_t holes_count = 0;
@@ -1230,7 +1236,10 @@ void TriangleMeshSlicer::make_expolygons(const Polygons &loops, ExPolygons* slic
#endif
// append to the supplied collection
- expolygons_append(*slices, ex_slices);
+ /* Fix for issue #661 { */
+ expolygons_append(*slices, offset2_ex(union_(loops, false), +safety_offset, -safety_offset));
+ //expolygons_append(*slices, ex_slices);
+ /* } */
}
void TriangleMeshSlicer::make_expolygons(std::vector<IntersectionLine> &lines, ExPolygons* slices) const