OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{ClipperUtils.cpp} Namespace Reference

Functions

C2::ClipType to_c2 (ClipType type)
C2::FillRule to_c2 (PolyFillType type)
C2::JoinType to_c2 (JoinType type)
C2::EndType to_c2 (EndType type)
int64_t px (const Point &pt)
int64_t py (const Point &pt)
int64_t px (const C2::Point64 &pt)
int64_t py (const C2::Point64 &pt)
template<typename PathsProvider>
C2::Paths64 to_paths64 (PathsProvider &&paths)
template<class PathT>
bool append_offset_path (C2::Paths64 &out, const PathT &path, double shortest, C2::EndType end)
Points c2_to_points (const C2::Path64 &path)
Polygons c2_to_polygons (const C2::Paths64 &paths)
Polylines c2_to_polylines (const C2::Paths64 &paths)
size_t c2_count_expolygons (const C2::PolyPath64 &outer)
void c2_append_expolygons (const C2::PolyPath64 &outer, ExPolygons &out, std::vector< const C2::Path64 * > &stray_holes)
bool path_encloses (const Polygon &outer, const Polygon &inner)
void c2_attach_stray_holes (ExPolygons &out, size_t first, const std::vector< const C2::Path64 * > &stray_holes)
ExPolygons c2_to_expolygons (const C2::PolyTree64 &tree)
template<class TOut>
void c2_clip (C2::ClipType type, const C2::Paths64 &subject, const C2::Paths64 &clip, C2::FillRule fill, TOut &out)
Polylines c2_clip_open (C2::ClipType type, const C2::Paths64 &subject, const C2::Paths64 &clip)
void c2_offset_setup (C2::ClipperOffset &co, float delta, JoinType joinType, double miterLimit, double capTolerance=0.)
bool c2_offset_as_group (const C2::Paths64 &paths, const std::vector< double > &areas)
template<class TOut>
void c2_offset_closed_paths (C2::Paths64 &&paths, float delta, JoinType joinType, double miterLimit, TOut &out)
template<class PathsT, class TOut>
void c2_offset_closed (PathsT &&src, float delta, JoinType joinType, double miterLimit, TOut &out)
template<class PathsProvider, class TOut>
void c2_offset2_closed (PathsProvider &&src, float delta1, float delta2, JoinType joinType, double miterLimit, TOut &out)
const ExPolygon & expolygon_of (const ExPolygon &expoly)
const ExPolygon & expolygon_of (const ExPolygon *expoly)
const ExPolygon & expolygon_of (const Surface &surface)
const ExPolygon & expolygon_of (const Surface *surface)
template<class ExPolygonRange, class TOut>
void c2_offset_expolygons (const ExPolygonRange &src, float delta, JoinType joinType, double miterLimit, TOut &out)
template<class ExPolygonRange>
Polygons c2_expolygons_offset (const ExPolygonRange &src, float delta, JoinType joinType, double miterLimit)
template<class ExPolygonRange>
ExPolygons c2_expolygons_offset_ex (const ExPolygonRange &src, float delta, JoinType joinType, double miterLimit)
template<class PathsProvider>
Polygons c2_offset_lines (PathsProvider &&src, float delta, JoinType joinType, double miterLimit, EndType endType, double capTolerance=0.)
template<class PathsProvider>
C2::Paths64 c2_clip_paths (PathsProvider &&clip, ApplySafetyOffset do_safety_offset)

Function Documentation

◆ append_offset_path()

template<class PathT>
bool Slic3r::anonymous_namespace{ClipperUtils.cpp}::append_offset_path ( C2::Paths64 & out,
const PathT & path,
double shortest,
C2::EndType end )
229{
230 int high = int(path.size()) - 1;
231 if (high < 0)
232 return false;
233 const double shortest2 = shortest * shortest;
234 auto same = [shortest2](const auto &a, const auto &b) {
235 const double dx = double(px(a) - px(b));
236 const double dy = double(py(a) - py(b));
237 return shortest2 > 0. ? dx * dx + dy * dy < shortest2 : dx == 0. && dy == 0.;
238 };
239 if (end == C2::EndType::Polygon || end == C2::EndType::Joined)
240 while (high > 0 && same(path[high], path[0]))
241 -- high;
242 C2::Path64 dst;
243 dst.reserve(high + 1);
244 dst.emplace_back(px(path[0]), py(path[0]));
245 for (int i = 1, last = 0; i <= high; ++ i)
246 if (! same(path[i], path[last])) {
247 dst.emplace_back(px(path[i]), py(path[i]));
248 last = i;
249 }
250 if (end == C2::EndType::Polygon && dst.size() < 3)
251 return false;
252 out.emplace_back(std::move(dst));
253 return true;
254}
int64_t py(const Point &pt)
Definition ClipperUtils.cpp:208
int64_t px(const Point &pt)
Definition ClipperUtils.cpp:207

References append_offset_path(), and px().

Referenced by append_offset_path(), c2_offset_closed(), c2_offset_expolygons(), and c2_offset_lines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_append_expolygons()

void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_append_expolygons ( const C2::PolyPath64 & outer,
ExPolygons & out,
std::vector< const C2::Path64 * > & stray_holes )
299{
300 if (C2::Area(outer.Polygon()) < 0.) {
301 stray_holes.emplace_back(&outer.Polygon());
302 for (const auto &island : outer)
303 c2_append_expolygons(*island, out, stray_holes);
304 return;
305 }
306 // Indexed, as the recursion below may reallocate out.
307 const size_t idx = out.size();
308 out.emplace_back().contour.points = c2_to_points(outer.Polygon());
309 out[idx].holes.reserve(outer.Count());
310 for (const auto &child : outer)
311 if (C2::Area(child->Polygon()) > 0.)
312 c2_append_expolygons(*child, out, stray_holes);
313 else {
314 out[idx].holes.emplace_back().points = c2_to_points(child->Polygon());
315 // Islands inside the hole.
316 for (const auto &island : *child)
317 c2_append_expolygons(*island, out, stray_holes);
318 }
319}
void c2_append_expolygons(const C2::PolyPath64 &outer, ExPolygons &out, std::vector< const C2::Path64 * > &stray_holes)
Definition ClipperUtils.cpp:298
Points c2_to_points(const C2::Path64 &path)
Definition ClipperUtils.cpp:256

References c2_append_expolygons(), and c2_to_points().

Referenced by c2_append_expolygons(), and c2_to_expolygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_attach_stray_holes()

void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_attach_stray_holes ( ExPolygons & out,
size_t first,
const std::vector< const C2::Path64 * > & stray_holes )
342{
343 if (stray_holes.empty())
344 return;
346 std::vector<AABBTreeIndirect::BoundingBoxWrapper> bboxes;
347 bboxes.reserve(out.size() - first);
348 for (size_t i = first; i < out.size(); ++ i)
349 bboxes.emplace_back(i, get_extents(out[i].contour));
350 Tree tree;
351 tree.build_modify_input(bboxes);
352 // Contour areas, computed when a contour first becomes a candidate.
353 std::vector<double> areas(out.size(), 0.);
354 std::vector<size_t> candidates;
355 for (const C2::Path64 *path : stray_holes) {
356 Polygon hole;
357 hole.points = c2_to_points(*path);
358 const double hole_area = - C2::Area(*path);
359 const BoundingBox bbox = get_extents(hole);
360 const Tree::BoundingBox hole_bbox(bbox.min, bbox.max);
361 candidates.clear();
363 [&hole_bbox](const Tree::Node &node) { return node.bbox.contains(hole_bbox); },
364 [&candidates](const Tree::Node &node) { candidates.emplace_back(node.idx); return true; });
365 for (size_t idx : candidates)
366 if (areas[idx] == 0.)
367 areas[idx] = out[idx].contour.area();
368 std::sort(candidates.begin(), candidates.end(), [&areas](size_t a, size_t b) { return areas[a] < areas[b]; });
369 auto larger = std::upper_bound(candidates.begin(), candidates.end(), hole_area, [&areas](double area, size_t idx) { return area < areas[idx]; });
370 if (auto it = std::find_if(larger, candidates.end(), [&out, &hole](size_t idx) { return path_encloses(out[idx].contour, hole); });
371 it == candidates.end())
372 // Nothing around it: keep the path as Clipper2 returned it.
373 out.emplace_back().contour = std::move(hole);
374 else
375 out[*it].holes.emplace_back(std::move(hole));
376 }
377}
Definition AABBTreeIndirect.hpp:45
PointType max
Definition BoundingBox.hpp:21
PointType min
Definition BoundingBox.hpp:20
Definition BoundingBox.hpp:212
Points points
Definition MultiPoint.hpp:22
Definition Polygon.hpp:31
void traverse(const Tree< Dims, T > &tree, Predicate &&pred, Fn &&callback)
Definition AABBTreeIndirect.hpp:986
BoundingBox get_extents(const ExPolygonsWithIds &e)
Definition Emboss.cpp:1374
double area(const ExPolygon &poly)
Definition ExPolygon.hpp:511
const Polygon & contour(const ExPolygon &p)
Definition AGGRaster.hpp:30

References Slic3r::area(), c2_attach_stray_holes(), c2_to_points(), Slic3r::contour(), Slic3r::get_extents(), Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::MultiPoint::points, and Slic3r::AABBTreeIndirect::traverse().

Referenced by c2_attach_stray_holes(), and c2_to_expolygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_clip()

template<class TOut>
void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_clip ( C2::ClipType type,
const C2::Paths64 & subject,
const C2::Paths64 & clip,
C2::FillRule fill,
TOut & out )
395{
396 C2::Clipper64 clipper;
397 // Clipper2 keeps collinear vertices by default, Clipper1 removed them.
398 clipper.PreserveCollinear(false);
399 clipper.AddSubject(subject);
400 if (! clip.empty())
401 clipper.AddClip(clip);
402 clipper.Execute(type, fill, out);
403}

References c2_clip().

Referenced by c2_clip(), and c2_offset_closed_paths().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_clip_open()

Polylines Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_clip_open ( C2::ClipType type,
const C2::Paths64 & subject,
const C2::Paths64 & clip )
406{
407 C2::Clipper64 clipper;
408 clipper.PreserveCollinear(false);
409 clipper.AddOpenSubject(subject);
410 if (! clip.empty())
411 clipper.AddClip(clip);
412 C2::Paths64 closed, open;
413 clipper.Execute(type, C2::FillRule::NonZero, closed, open);
414 return c2_to_polylines(open);
415}
Polylines c2_to_polylines(const C2::Paths64 &paths)
Definition ClipperUtils.cpp:274

References c2_clip_open(), and c2_to_polylines().

Referenced by c2_clip_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_clip_paths()

template<class PathsProvider>
C2::Paths64 Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_clip_paths ( PathsProvider && clip,
ApplySafetyOffset do_safety_offset )
572{
573 if (do_safety_offset == ApplySafetyOffset::No)
574 return to_paths64(std::forward<PathsProvider>(clip));
575 C2::Paths64 out;
576 c2_offset_closed(std::forward<PathsProvider>(clip), ClipperSafetyOffset, DefaultJoinType, DefaultMiterLimit, out);
577 return out;
578}
C2::Paths64 to_paths64(PathsProvider &&paths)
Definition ClipperUtils.cpp:213
void c2_offset_closed(PathsT &&src, float delta, JoinType joinType, double miterLimit, TOut &out)
Definition ClipperUtils.cpp:479
static constexpr const double DefaultMiterLimit
Definition ClipperUtils.hpp:40
static constexpr const JoinType DefaultJoinType
Definition ClipperUtils.hpp:32
@ No
Definition ClipperUtils.hpp:50
static constexpr const float ClipperSafetyOffset
Definition ClipperUtils.hpp:30

References c2_clip_paths(), c2_offset_closed(), Slic3r::ClipperSafetyOffset, Slic3r::DefaultJoinType, Slic3r::DefaultMiterLimit, Slic3r::No, and to_paths64().

Referenced by c2_clip_paths().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_count_expolygons()

size_t Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_count_expolygons ( const C2::PolyPath64 & outer)
285{
286 size_t cnt = 1;
287 for (const auto &hole : outer)
288 for (const auto &island : *hole)
289 cnt += c2_count_expolygons(*island);
290 return cnt;
291}
size_t c2_count_expolygons(const C2::PolyPath64 &outer)
Definition ClipperUtils.cpp:284

References c2_count_expolygons().

Referenced by c2_count_expolygons(), and c2_to_expolygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_expolygons_offset()

template<class ExPolygonRange>
Polygons Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_expolygons_offset ( const ExPolygonRange & src,
float delta,
JoinType joinType,
double miterLimit )
535{
536 C2::Paths64 out;
537 c2_offset_expolygons(src, delta, joinType, miterLimit, out);
538 return c2_to_polygons(out);
539}
void c2_offset_expolygons(const ExPolygonRange &src, float delta, JoinType joinType, double miterLimit, TOut &out)
Definition ClipperUtils.cpp:504
Polygons c2_to_polygons(const C2::Paths64 &paths)
Definition ClipperUtils.cpp:265

References c2_expolygons_offset(), c2_offset_expolygons(), and c2_to_polygons().

Referenced by c2_expolygons_offset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_expolygons_offset_ex()

template<class ExPolygonRange>
ExPolygons Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_expolygons_offset_ex ( const ExPolygonRange & src,
float delta,
JoinType joinType,
double miterLimit )
543{
544 C2::PolyTree64 out;
545 c2_offset_expolygons(src, delta, joinType, miterLimit, out);
546 return c2_to_expolygons(out);
547}
ExPolygons c2_to_expolygons(const C2::PolyTree64 &tree)
Definition ClipperUtils.cpp:379

References c2_expolygons_offset_ex(), c2_offset_expolygons(), and c2_to_expolygons().

Referenced by c2_expolygons_offset_ex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_offset2_closed()

template<class PathsProvider, class TOut>
void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_offset2_closed ( PathsProvider && src,
float delta1,
float delta2,
JoinType joinType,
double miterLimit,
TOut & out )
491{
492 C2::Paths64 first;
493 c2_offset_closed(std::forward<PathsProvider>(src), delta1, joinType, miterLimit, first);
494 c2_offset_closed(first, delta2, joinType, miterLimit, out);
495}

References c2_offset2_closed(), and c2_offset_closed().

Referenced by c2_offset2_closed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_offset_as_group()

bool Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_offset_as_group ( const C2::Paths64 & paths,
const std::vector< double > & areas )
432{
433 std::vector<C2::Rect64> contours;
434 for (size_t i = 0; i < paths.size(); ++ i)
435 if (areas[i] > 0.)
436 contours.emplace_back(C2::GetBounds(paths[i]));
437 for (size_t i = 0; i < paths.size(); ++ i)
438 if (areas[i] < 0.) {
439 const C2::Rect64 hole = C2::GetBounds(paths[i]);
440 if (std::none_of(contours.begin(), contours.end(), [&hole](const C2::Rect64 &r) {
441 return r.left < hole.left && r.right > hole.right && r.top < hole.top && r.bottom > hole.bottom;
442 }))
443 return false;
444 }
445 return true;
446}

References c2_offset_as_group().

Referenced by c2_offset_as_group(), and c2_offset_closed_paths().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_offset_closed()

template<class PathsT, class TOut>
void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_offset_closed ( PathsT && src,
float delta,
JoinType joinType,
double miterLimit,
TOut & out )
480{
481 const double shortest = std::abs(delta * ClipperOffsetShortestEdgeFactor);
482 C2::Paths64 paths;
483 paths.reserve(src.size());
484 for (const auto &path : src)
485 append_offset_path(paths, path, shortest, C2::EndType::Polygon);
486 c2_offset_closed_paths(std::move(paths), delta, joinType, miterLimit, out);
487}
bool append_offset_path(C2::Paths64 &out, const PathT &path, double shortest, C2::EndType end)
Definition ClipperUtils.cpp:228
void c2_offset_closed_paths(C2::Paths64 &&paths, float delta, JoinType joinType, double miterLimit, TOut &out)
Definition ClipperUtils.cpp:449
static constexpr const double ClipperOffsetShortestEdgeFactor
Definition ClipperUtils.hpp:47

References append_offset_path(), c2_offset_closed(), c2_offset_closed_paths(), and Slic3r::ClipperOffsetShortestEdgeFactor.

Referenced by c2_clip_paths(), c2_offset2_closed(), c2_offset_closed(), and c2_offset_lines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_offset_closed_paths()

template<class TOut>
void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_offset_closed_paths ( C2::Paths64 && paths,
float delta,
JoinType joinType,
double miterLimit,
TOut & out )
450{
451 std::vector<double> areas;
452 areas.reserve(paths.size());
453 for (const C2::Path64 &path : paths)
454 areas.emplace_back(C2::Area(path));
455 C2::ClipperOffset co;
456 c2_offset_setup(co, delta, joinType, miterLimit);
457 if (c2_offset_as_group(paths, areas)) {
458 // Clipper2 would grow degenerate paths even for a negative offset.
459 if (delta < 0. && std::all_of(areas.begin(), areas.end(), [](double a) { return a == 0.; }))
460 return;
461 co.AddPaths(paths, to_c2(joinType), C2::EndType::Polygon);
462 co.Execute(delta, out);
463 return;
464 }
465 C2::Paths64 offsetted, single;
466 for (size_t i = 0; i < paths.size(); ++ i) {
467 if (areas[i] == 0. && delta < 0.)
468 continue;
469 co.Clear();
470 co.AddPath(paths[i], to_c2(joinType), C2::EndType::Polygon);
471 // Clipper2 reverses a lone CW path, so the flipped sign shrinks it as a hole.
472 co.Execute(areas[i] < 0. ? - delta : delta, single);
473 append(offsetted, std::move(single));
474 }
475 c2_clip(C2::ClipType::Union, offsetted, {}, delta > 0. ? C2::FillRule::NonZero : C2::FillRule::Positive, out);
476}
void c2_offset_setup(C2::ClipperOffset &co, float delta, JoinType joinType, double miterLimit, double capTolerance=0.)
Definition ClipperUtils.cpp:419
C2::ClipType to_c2(ClipType type)
Definition ClipperUtils.cpp:167
void c2_clip(C2::ClipType type, const C2::Paths64 &subject, const C2::Paths64 &clip, C2::FillRule fill, TOut &out)
Definition ClipperUtils.cpp:394
bool c2_offset_as_group(const C2::Paths64 &paths, const std::vector< double > &areas)
Definition ClipperUtils.cpp:431
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:157

References Slic3r::append(), c2_clip(), c2_offset_as_group(), c2_offset_closed_paths(), c2_offset_setup(), and to_c2().

Referenced by c2_offset_closed(), and c2_offset_closed_paths().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_offset_expolygons()

template<class ExPolygonRange, class TOut>
void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_offset_expolygons ( const ExPolygonRange & src,
float delta,
JoinType joinType,
double miterLimit,
TOut & out )
505{
506 const double shortest = std::abs(delta * ClipperOffsetShortestEdgeFactor);
507 C2::Paths64 paths;
508 for (const auto &item : src) {
509 const ExPolygon &expoly = expolygon_of(item);
510 if (! append_offset_path(paths, expoly.contour.points, shortest, C2::EndType::Polygon))
511 continue;
512 if (const double area = C2::Area(paths.back()); area == 0.) {
513 // A degenerate contour vanishes when shrunk and encloses no hole when grown.
514 if (delta < 0.)
515 paths.pop_back();
516 continue;
517 } else if (area < 0.)
518 std::reverse(paths.back().begin(), paths.back().end());
519 for (const Polygon &hole : expoly.holes)
520 if (append_offset_path(paths, hole.points, shortest, C2::EndType::Polygon)) {
521 if (const double area = C2::Area(paths.back()); area == 0.)
522 paths.pop_back();
523 else if (area > 0.)
524 std::reverse(paths.back().begin(), paths.back().end());
525 }
526 }
527 C2::ClipperOffset co;
528 c2_offset_setup(co, delta, joinType, miterLimit);
529 co.AddPaths(paths, to_c2(joinType), C2::EndType::Polygon);
530 co.Execute(delta, out);
531}
Definition ExPolygon.hpp:23
Polygon contour
Definition ExPolygon.hpp:42
Polygons holes
Definition ExPolygon.hpp:43
const ExPolygon & expolygon_of(const ExPolygon &expoly)
Definition ClipperUtils.cpp:497

References append_offset_path(), Slic3r::area(), c2_offset_expolygons(), c2_offset_setup(), Slic3r::ClipperOffsetShortestEdgeFactor, Slic3r::ExPolygon::contour, expolygon_of(), Slic3r::ExPolygon::holes, Slic3r::MultiPoint::points, and to_c2().

Referenced by c2_expolygons_offset(), c2_expolygons_offset_ex(), and c2_offset_expolygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_offset_lines()

template<class PathsProvider>
Polygons Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_offset_lines ( PathsProvider && src,
float delta,
JoinType joinType,
double miterLimit,
EndType endType,
double capTolerance = 0. )
551{
552 C2::Paths64 out;
553 if (endType == etClosedPolygon) {
554 c2_offset_closed(std::forward<PathsProvider>(src), delta, joinType, miterLimit, out);
555 return c2_to_polygons(out);
556 }
557 const C2::EndType end = to_c2(endType);
558 const double shortest = std::abs(delta * ClipperOffsetShortestEdgeFactor);
559 C2::Paths64 paths;
560 paths.reserve(src.size());
561 for (const Points &path : src)
562 append_offset_path(paths, path, shortest, end);
563 C2::ClipperOffset co;
564 c2_offset_setup(co, delta, joinType, miterLimit, capTolerance);
565 co.AddPaths(paths, to_c2(joinType), end);
566 co.Execute(delta, out);
567 return c2_to_polygons(out);
568}
@ etClosedPolygon
Definition ClipperUtils.hpp:22
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73

References append_offset_path(), c2_offset_closed(), c2_offset_lines(), c2_offset_setup(), c2_to_polygons(), Slic3r::ClipperOffsetShortestEdgeFactor, Slic3r::etClosedPolygon, and to_c2().

Referenced by c2_offset_lines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_offset_setup()

void Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_offset_setup ( C2::ClipperOffset & co,
float delta,
JoinType joinType,
double miterLimit,
double capTolerance = 0. )
420{
421 const double max_arc_tolerance = std::abs(delta) * 0.25;
422 if (joinType == jtRound)
423 co.ArcTolerance(miterLimit > 0. ? std::min(miterLimit, max_arc_tolerance) : 0.25);
424 else {
425 co.MiterLimit(std::max(miterLimit, 2.));
426 co.ArcTolerance(std::min(capTolerance > 0. ? capTolerance : 0.25, max_arc_tolerance));
427 }
428}
@ jtRound
Definition ClipperUtils.hpp:21

References c2_offset_setup(), and Slic3r::jtRound.

Referenced by c2_offset_closed_paths(), c2_offset_expolygons(), c2_offset_lines(), and c2_offset_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_to_expolygons()

ExPolygons Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_to_expolygons ( const C2::PolyTree64 & tree)
380{
381 size_t cnt = 0;
382 for (const auto &outer : tree)
383 cnt += c2_count_expolygons(*outer);
384 ExPolygons out;
385 out.reserve(cnt);
386 std::vector<const C2::Path64*> stray_holes;
387 for (const auto &outer : tree)
388 c2_append_expolygons(*outer, out, stray_holes);
389 c2_attach_stray_holes(out, 0, stray_holes);
390 return out;
391}
void c2_attach_stray_holes(ExPolygons &out, size_t first, const std::vector< const C2::Path64 * > &stray_holes)
Definition ClipperUtils.cpp:341
std::vector< ExPolygon > ExPolygons
Definition ExPolygon.hpp:20

References c2_append_expolygons(), c2_attach_stray_holes(), c2_count_expolygons(), and c2_to_expolygons().

Referenced by c2_expolygons_offset_ex(), and c2_to_expolygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_to_points()

Points Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_to_points ( const C2::Path64 & path)
inline
257{
258 Points out;
259 out.reserve(path.size());
260 for (const C2::Point64 &pt : path)
261 out.emplace_back(pt.x, pt.y);
262 return out;
263}

References c2_to_points().

Referenced by c2_append_expolygons(), c2_attach_stray_holes(), c2_to_points(), c2_to_polygons(), and c2_to_polylines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_to_polygons()

Polygons Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_to_polygons ( const C2::Paths64 & paths)
266{
267 Polygons out;
268 out.reserve(paths.size());
269 for (const C2::Path64 &path : paths)
270 out.emplace_back().points = c2_to_points(path);
271 return out;
272}
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:22

References c2_to_points(), and c2_to_polygons().

Referenced by c2_expolygons_offset(), c2_offset_lines(), and c2_to_polygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c2_to_polylines()

Polylines Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_to_polylines ( const C2::Paths64 & paths)
275{
276 Polylines out;
277 out.reserve(paths.size());
278 for (const C2::Path64 &path : paths)
279 out.emplace_back(c2_to_points(path));
280 return out;
281}
std::vector< Polyline > Polylines
Definition Polyline.hpp:22

References c2_to_points(), and c2_to_polylines().

Referenced by c2_clip_open(), and c2_to_polylines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expolygon_of() [1/4]

const ExPolygon & Slic3r::anonymous_namespace{ClipperUtils.cpp}::expolygon_of ( const ExPolygon & expoly)
inline
497{ return expoly; }

References expolygon_of().

Referenced by c2_offset_expolygons(), expolygon_of(), expolygon_of(), expolygon_of(), and expolygon_of().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expolygon_of() [2/4]

const ExPolygon & Slic3r::anonymous_namespace{ClipperUtils.cpp}::expolygon_of ( const ExPolygon * expoly)
inline
498{ return *expoly; }

References expolygon_of().

Here is the call graph for this function:

◆ expolygon_of() [3/4]

const ExPolygon & Slic3r::anonymous_namespace{ClipperUtils.cpp}::expolygon_of ( const Surface & surface)
inline
499{ return surface.expolygon; }
ExPolygon expolygon
Definition Surface.hpp:46

References Slic3r::Surface::expolygon, and expolygon_of().

Here is the call graph for this function:

◆ expolygon_of() [4/4]

const ExPolygon & Slic3r::anonymous_namespace{ClipperUtils.cpp}::expolygon_of ( const Surface * surface)
inline
500{ return surface->expolygon; }

References Slic3r::Surface::expolygon, and expolygon_of().

Here is the call graph for this function:

◆ path_encloses()

bool Slic3r::anonymous_namespace{ClipperUtils.cpp}::path_encloses ( const Polygon & outer,
const Polygon & inner )
328{
329 // The rounding of the two paths, and of the projection Polygon::on_boundary() measures to.
330 static constexpr double touching = 3.;
331 for (const Point &pt : inner.points)
332 if (! outer.on_boundary(pt, touching))
333 return contains(outer, pt, true);
334 const std::optional<Point> pt = ClipperUtils::interior_point(inner);
335 return pt && contains(outer, *pt, true);
336}
Definition Point.hpp:199
bool on_boundary(const Point &point, double eps) const
Definition Polygon.hpp:75
std::optional< Point > interior_point(const Polygon &polygon)
Definition ClipperUtils.cpp:935
bool contains(const std::vector< T > &vector, const Point &point)
Definition Geometry.cpp:55

References Slic3r::Geometry::contains(), Slic3r::ClipperUtils::interior_point(), Slic3r::Polygon::on_boundary(), path_encloses(), and Slic3r::MultiPoint::points.

Referenced by path_encloses().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ px() [1/2]

int64_t Slic3r::anonymous_namespace{ClipperUtils.cpp}::px ( const C2::Point64 & pt)
inline
209{ return pt.x; }

References px().

Here is the call graph for this function:

◆ px() [2/2]

int64_t Slic3r::anonymous_namespace{ClipperUtils.cpp}::px ( const Point & pt)
inline
207{ return pt.x(); }

References px().

Referenced by append_offset_path(), px(), and px().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ py() [1/2]

int64_t Slic3r::anonymous_namespace{ClipperUtils.cpp}::py ( const C2::Point64 & pt)
inline
210{ return pt.y; }

◆ py() [2/2]

int64_t Slic3r::anonymous_namespace{ClipperUtils.cpp}::py ( const Point & pt)
inline
208{ return pt.y(); }

◆ to_c2() [1/4]

C2::ClipType Slic3r::anonymous_namespace{ClipperUtils.cpp}::to_c2 ( ClipType type)
168{
169 switch (type) {
170 case ctIntersection: return C2::ClipType::Intersection;
171 case ctUnion: return C2::ClipType::Union;
172 case ctDifference: return C2::ClipType::Difference;
173 default: return C2::ClipType::Xor;
174 }
175}
@ ctUnion
Definition ClipperUtils.hpp:24
@ ctDifference
Definition ClipperUtils.hpp:24
@ ctIntersection
Definition ClipperUtils.hpp:24

References Slic3r::ctDifference, Slic3r::ctIntersection, Slic3r::ctUnion, and to_c2().

Referenced by c2_offset_closed_paths(), c2_offset_expolygons(), c2_offset_lines(), to_c2(), to_c2(), to_c2(), and to_c2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_c2() [2/4]

C2::EndType Slic3r::anonymous_namespace{ClipperUtils.cpp}::to_c2 ( EndType type)
197{
198 switch (type) {
199 case etClosedPolygon: return C2::EndType::Polygon;
200 case etClosedLine: return C2::EndType::Joined;
201 case etOpenSquare: return C2::EndType::Square;
202 case etOpenRound: return C2::EndType::Round;
203 default: return C2::EndType::Butt;
204 }
205}
@ etOpenSquare
Definition ClipperUtils.hpp:22
@ etOpenRound
Definition ClipperUtils.hpp:22
@ etClosedLine
Definition ClipperUtils.hpp:22

References Slic3r::etClosedLine, Slic3r::etClosedPolygon, Slic3r::etOpenRound, Slic3r::etOpenSquare, and to_c2().

Here is the call graph for this function:

◆ to_c2() [3/4]

C2::JoinType Slic3r::anonymous_namespace{ClipperUtils.cpp}::to_c2 ( JoinType type)
188{
189 switch (type) {
190 case jtSquare: return C2::JoinType::Square;
191 case jtRound: return C2::JoinType::Round;
192 default: return C2::JoinType::Miter;
193 }
194}
@ jtSquare
Definition ClipperUtils.hpp:21

References Slic3r::jtRound, Slic3r::jtSquare, and to_c2().

Here is the call graph for this function:

◆ to_c2() [4/4]

C2::FillRule Slic3r::anonymous_namespace{ClipperUtils.cpp}::to_c2 ( PolyFillType type)
178{
179 switch (type) {
180 case pftEvenOdd: return C2::FillRule::EvenOdd;
181 case pftNonZero: return C2::FillRule::NonZero;
182 case pftPositive: return C2::FillRule::Positive;
183 default: return C2::FillRule::Negative;
184 }
185}
@ pftEvenOdd
Definition ClipperUtils.hpp:23
@ pftPositive
Definition ClipperUtils.hpp:23
@ pftNonZero
Definition ClipperUtils.hpp:23

References Slic3r::pftEvenOdd, Slic3r::pftNonZero, Slic3r::pftPositive, and to_c2().

Here is the call graph for this function:

◆ to_paths64()

template<typename PathsProvider>
C2::Paths64 Slic3r::anonymous_namespace{ClipperUtils.cpp}::to_paths64 ( PathsProvider && paths)
214{
215 C2::Paths64 out;
216 out.reserve(paths.size());
217 for (const Points &path : paths) {
218 C2::Path64 &dst = out.emplace_back();
219 dst.reserve(path.size());
220 for (const Point &pt : path)
221 dst.emplace_back(pt.x(), pt.y());
222 }
223 return out;
224}

References to_paths64().

Referenced by c2_clip_paths(), and to_paths64().

Here is the call graph for this function:
Here is the caller graph for this function: