Skip to content

Commit d6cf775

Browse files
authored
Merge branch 'main' into CURA-12474_set-fixed-0-gap-for-brim-support
2 parents a4fcfba + 73a0374 commit d6cf775

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

include/TreeSupportBaseCircle.h

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,27 @@ class TreeSupportBaseCircle
1818
{
1919
protected:
2020
inline static Polygon base_circle;
21-
inline static bool circle_generated = false;
21+
inline static std::once_flag flag;
2222

2323
public:
2424
inline static constexpr int64_t base_radius = 50;
2525

2626
static Polygon getBaseCircle()
2727
{
28-
if (circle_generated)
29-
{
30-
return base_circle;
31-
}
32-
else
33-
{
34-
std::mutex critical_sections;
35-
std::lock_guard<std::mutex> critical_section_progress(critical_sections);
36-
if (circle_generated)
28+
std::call_once(
29+
flag,
30+
[&]()
3731
{
38-
return base_circle;
39-
}
40-
41-
constexpr auto support_tree_circle_resolution = 12; // The number of vertices in each circle.
42-
Polygon circle;
43-
for (const uint64_t i : ranges::views::iota(0, support_tree_circle_resolution))
44-
{
45-
const AngleRadians angle = static_cast<double>(i) / support_tree_circle_resolution * TAU;
46-
circle.emplace_back(static_cast<coord_t>(std::cos(angle) * base_radius), static_cast<coord_t>(std::sin(angle) * base_radius));
47-
}
48-
base_circle = Polygon(circle);
49-
circle_generated = true;
50-
return base_circle;
51-
}
32+
constexpr auto support_tree_circle_resolution = 12; // The number of vertices in each circle.
33+
Polygon circle;
34+
for (const uint64_t i : ranges::views::iota(0, support_tree_circle_resolution))
35+
{
36+
const AngleRadians angle = static_cast<double>(i) / support_tree_circle_resolution * TAU;
37+
circle.emplace_back(static_cast<coord_t>(std::cos(angle) * base_radius), static_cast<coord_t>(std::sin(angle) * base_radius));
38+
}
39+
base_circle = Polygon(circle);
40+
});
41+
return base_circle;
5242
}
5343
};
5444

stress_benchmark/stress_benchmark.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <boost/geometry/geometries/polygon.hpp>
1818
#include <boost/geometry/io/wkt/read.hpp>
1919
#include <fmt/format.h>
20+
#include <fmt/ranges.h>
2021
#include <spdlog/spdlog.h>
2122

2223
#include "WallsComputation.h"

0 commit comments

Comments
 (0)