| 2896 | } |
| 2897 | |
| 2898 | class timer { |
| 2899 | public: |
| 2900 | class entry { |
| 2901 | public: |
| 2902 | entry() {} |
| 2903 | |
| 2904 | entry(std::map<std::string, std::chrono::high_resolution_clock::time_point>::const_iterator start_it) |
| 2905 | : start_it(start_it) {} |
| 2906 | |
| 2907 | void stop() { |
| 2908 | if (start_it) { |
| 2909 | auto end = std::chrono::high_resolution_clock::now(); |
| 2910 | auto duration = std::chrono::duration<double, std::milli>(end - start_it.value()->second).count(); |
| 2911 | std::cerr << "Timing for " << start_it.value()->first << ": " << duration << " ms" << std::endl; |
| 2912 | } |
| 2913 | } |
| 2914 | |
| 2915 | private: |
| 2916 | std::optional<std::map<std::string, std::chrono::high_resolution_clock::time_point>::const_iterator> start_it; |
| 2917 | }; |
| 2918 | |
| 2919 | timer(bool enabled = true) : enabled_(enabled) {} |
| 2920 | |
| 2921 | entry start(const std::string& name) { |
| 2922 | if (enabled_) { |
| 2923 | return entry(timings_.insert({name, std::chrono::high_resolution_clock::now()}).first); |
| 2924 | } else { |
| 2925 | return entry(); |
| 2926 | } |
| 2927 | } |
| 2928 | |
| 2929 | private: |
| 2930 | std::map< |
| 2931 | std::string, |
| 2932 | std::chrono::high_resolution_clock::time_point> |
| 2933 | timings_; |
| 2934 | |
| 2935 | bool enabled_; |
| 2936 | }; |
| 2937 | |
| 2938 | void arrange_cgal_polygons(svgfill::arrange_polygon_settings settings, const std::vector<Polygon_2>& input_polygons_, std::vector<Polygon_2>& output_polygons, double polygon_offset_distance = -1.) { |
| 2939 | static const double OVERLAP_RESOLUTION_DISTANCE = 1.e-1; |