MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / copy

Method copy

src/core/virtual_path.cpp:619–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

617}
618
619void VirtualPath::copy(
620 const SplitPathCoord& first,
621 const SplitPathCoord& last,
622 MapCoordVector& out_coords ) const
623{
624 Q_ASSERT(!empty());
625 Q_ASSERT(first.path_coords == &path_coords);
626 Q_ASSERT(last.path_coords == &path_coords);
627
628 auto& flags = coords.flags;
629
630 // Handle first coordinate and its flags.
631 if (out_coords.empty() ||
632 out_coords.back().isHolePoint() ||
633 !out_coords.back().isPositionEqualTo(MapCoord(first.pos)) )
634 {
635 out_coords.emplace_back(first.pos);
636 }
637
638 auto first_flags = out_coords.back().flags() & MapCoord::MaskCopiedFlagsAtStart;
639 if (first.param == 0.0f)
640 first_flags |= flags[first.index].flags() & MapCoord::MaskCopiedFlagsAtStart;
641 out_coords.back().setFlags(first_flags);
642
643 if (first.index == last.index)
644 {
645 out_coords.back().setCurveStart(last.is_curve_end && last.param != first.param);
646 }
647 else
648 {
649 out_coords.back().setCurveStart(first.is_curve_start);
650
651 auto stop_index = last.index;
652 if (last.param == 0.0f)
653 {
654 stop_index -= last.is_curve_end ? 3 : 1;
655 }
656
657 auto index = first.index + 1;
658 if (first.is_curve_start)
659 {
660 out_coords.emplace_back(first.curve_start[0]);
661 out_coords.emplace_back(first.curve_start[1]);
662 index += 2;
663 }
664
665 for (; index <= stop_index; ++index)
666 {
667 out_coords.emplace_back(coords[index]);
668 out_coords.back().setFlags(flags[index].flags());
669 }
670 }
671
672 if (out_coords.back().isCurveStart())
673 {
674 Q_ASSERT(last.is_curve_end);
675 out_coords.emplace_back(last.curve_end[0]);
676 out_coords.emplace_back(last.curve_end[1]);

Callers 12

traceBoundaryMethod · 0.45
drawPixmapMethod · 0.45
drawImageMethod · 0.45
drawPixmapMethod · 0.45
drawImageMethod · 0.45
drawOntoTemplateImplMethod · 0.45
drawOntoTemplateUndoMethod · 0.45
changePathBoundsMethod · 0.45
processContinuousLineMethod · 0.45
createPointedLineCapMethod · 0.45
createDashGroupsMethod · 0.45
paintEventMethod · 0.45

Calls 10

isHolePointMethod · 0.80
backMethod · 0.80
isPositionEqualToMethod · 0.80
setFlagsMethod · 0.80
setCurveStartMethod · 0.80
isCurveStartMethod · 0.80
MapCoordClass · 0.70
emptyMethod · 0.45
flagsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected