MCPcopy Create free account
hub / github.com/AngusJohnson/Clipper2 / OffsetOpenPath

Method OffsetOpenPath

CPP/Clipper2Lib/src/clipper.offset.cpp:395–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395void ClipperOffset::OffsetOpenPath(Group& group, const Path64& path)
396{
397 // do the line start cap
398 if (deltaCallback64_) group_delta_ = deltaCallback64_(path, norms, 0, 0);
399
400 if (std::fabs(group_delta_) <= floating_point_tolerance)
401 path_out.emplace_back(path[0]);
402 else
403 {
404 switch (end_type_)
405 {
406 case EndType::Butt:
407 DoBevel(path, 0, 0);
408 break;
409 case EndType::Round:
410 DoRound(path, 0, 0, PI);
411 break;
412 default:
413 DoSquare(path, 0, 0);
414 break;
415 }
416 }
417
418 size_t highI = path.size() - 1;
419 // offset the left side going forward
420 for (Path64::size_type j = 1, k = 0; j < highI; k = j, ++j)
421 OffsetPoint(group, path, j, k);
422
423 // reverse normals
424 for (size_t i = highI; i > 0; --i)
425 norms[i] = PointD(-norms[i - 1].x, -norms[i - 1].y);
426 norms[0] = norms[highI];
427
428 // do the line end cap
429 if (deltaCallback64_)
430 group_delta_ = deltaCallback64_(path, norms, highI, highI);
431
432 if (std::fabs(group_delta_) <= floating_point_tolerance)
433 path_out.emplace_back(path[highI]);
434 else
435 {
436 switch (end_type_)
437 {
438 case EndType::Butt:
439 DoBevel(path, highI, highI);
440 break;
441 case EndType::Round:
442 DoRound(path, highI, highI, PI);
443 break;
444 default:
445 DoSquare(path, highI, highI);
446 break;
447 }
448 }
449
450 for (size_t j = highI -1, k = highI; j > 0; k = j, --j)
451 OffsetPoint(group, path, j, k);
452 solution->emplace_back(path_out);

Callers

nothing calls this directly

Calls 1

PointDClass · 0.85

Tested by

no test coverage detected