| 734 | } |
| 735 | |
| 736 | std::string contours::data_string() { |
| 737 | // If there is a jump from a border to the other, we need to complete |
| 738 | // the curve from one point to another to avoid filled curves that don't |
| 739 | // make sense. |
| 740 | double _xmax = xmax(); |
| 741 | double _xmin = xmin(); |
| 742 | double _ymax = ymax(); |
| 743 | double _ymin = ymin(); |
| 744 | auto is_border_jump = [&](double x1, double y1, double x2, double y2) { |
| 745 | constexpr uint8_t NONE = 0; |
| 746 | constexpr uint8_t NORTH = 1; |
| 747 | constexpr uint8_t SOUTH = 2; |
| 748 | constexpr uint8_t WEST = 3; |
| 749 | constexpr uint8_t EAST = 4; |
| 750 | uint8_t xy1_border = NONE; |
| 751 | if (x1 <= _xmin) { |
| 752 | xy1_border = WEST; |
| 753 | } else if (x1 >= _xmax) { |
| 754 | xy1_border = EAST; |
| 755 | } else if (y1 <= _ymin) { |
| 756 | xy1_border = SOUTH; |
| 757 | } else if (y1 >= _ymax) { |
| 758 | xy1_border = NORTH; |
| 759 | } |
| 760 | if (xy1_border != NONE) { |
| 761 | uint8_t xy2_border = NONE; |
| 762 | if (x2 <= _xmin) { |
| 763 | xy2_border = WEST; |
| 764 | } else if (x2 >= _xmax) { |
| 765 | xy2_border = EAST; |
| 766 | } else if (y2 <= _ymin) { |
| 767 | xy2_border = SOUTH; |
| 768 | } else if (y2 >= _ymax) { |
| 769 | xy2_border = NORTH; |
| 770 | } |
| 771 | if (xy2_border != NONE && xy2_border != xy1_border) { |
| 772 | return true; |
| 773 | } |
| 774 | } |
| 775 | return false; |
| 776 | }; |
| 777 | |
| 778 | auto [lower_levels, upper_levels] = get_lowers_and_uppers(); |
| 779 | |
| 780 | std::stringstream ss; |
| 781 | ss.precision(10); |
| 782 | ss << std::fixed; |
| 783 | if (filled_) { |
| 784 | // Plot the line segments |
| 785 | // Create one filled curve for each segment of a contour. |
| 786 | |
| 787 | bool plot_background = _levels[0] < zmin_; |
| 788 | if (plot_background) { |
| 789 | // find background polygon level |
| 790 | auto &largest_segment_with_children = line_segments_[0]; |
| 791 | auto &largest_segment = |
| 792 | std::get<0>(largest_segment_with_children); |
| 793 | size_t line_index = std::get<0>(largest_segment); |
nothing calls this directly
no test coverage detected