Reworked the ClipperLib / Polygon types to use
the tbb::scallable_allocator to better scale on multiple threads.
This commit is contained in:
parent
b0cc0e98fa
commit
9cde96993e
38 changed files with 261 additions and 241 deletions
|
@ -2,7 +2,7 @@ get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
|||
add_executable(${_TEST_NAME}_tests ${_TEST_NAME}_tests_main.cpp printer_parts.cpp printer_parts.hpp)
|
||||
|
||||
# mold linker for successful linking needs also to link TBB library and link it before libslic3r.
|
||||
target_link_libraries(${_TEST_NAME}_tests test_common TBB::tbb libnest2d )
|
||||
target_link_libraries(${_TEST_NAME}_tests test_common TBB::tbb TBB::tbbmalloc libnest2d )
|
||||
set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests")
|
||||
|
||||
# catch_discover_tests(${_TEST_NAME}_tests TEST_PREFIX "${_TEST_NAME}: ")
|
||||
|
|
|
@ -83,7 +83,7 @@ TEST_CASE("Line::perpendicular_to", "[Geometry]") {
|
|||
|
||||
TEST_CASE("Polygon::contains works properly", "[Geometry]"){
|
||||
// this test was failing on Windows (GH #1950)
|
||||
Slic3r::Polygon polygon(std::vector<Point>({
|
||||
Slic3r::Polygon polygon(Points({
|
||||
Point(207802834,-57084522),
|
||||
Point(196528149,-37556190),
|
||||
Point(173626821,-25420928),
|
||||
|
@ -145,7 +145,7 @@ SCENARIO("polygon_is_convex works") {
|
|||
|
||||
TEST_CASE("Creating a polyline generates the obvious lines", "[Geometry]"){
|
||||
Slic3r::Polyline polyline;
|
||||
polyline.points = std::vector<Point>({Point(0, 0), Point(10, 0), Point(20, 0)});
|
||||
polyline.points = Points({Point(0, 0), Point(10, 0), Point(20, 0)});
|
||||
REQUIRE(polyline.lines().at(0).a == Point(0,0));
|
||||
REQUIRE(polyline.lines().at(0).b == Point(10,0));
|
||||
REQUIRE(polyline.lines().at(1).a == Point(10,0));
|
||||
|
@ -153,7 +153,7 @@ TEST_CASE("Creating a polyline generates the obvious lines", "[Geometry]"){
|
|||
}
|
||||
|
||||
TEST_CASE("Splitting a Polygon generates a polyline correctly", "[Geometry]"){
|
||||
Slic3r::Polygon polygon(std::vector<Point>({Point(0, 0), Point(10, 0), Point(5, 5)}));
|
||||
Slic3r::Polygon polygon(Points({Point(0, 0), Point(10, 0), Point(5, 5)}));
|
||||
Slic3r::Polyline split = polygon.split_at_index(1);
|
||||
REQUIRE(split.points[0]==Point(10,0));
|
||||
REQUIRE(split.points[1]==Point(5,5));
|
||||
|
@ -164,7 +164,7 @@ TEST_CASE("Splitting a Polygon generates a polyline correctly", "[Geometry]"){
|
|||
|
||||
SCENARIO("BoundingBox", "[Geometry]") {
|
||||
WHEN("Bounding boxes are scaled") {
|
||||
BoundingBox bb(std::vector<Point>({Point(0, 1), Point(10, 2), Point(20, 2)}));
|
||||
BoundingBox bb(Points({Point(0, 1), Point(10, 2), Point(20, 2)}));
|
||||
bb.scale(2);
|
||||
REQUIRE(bb.min == Point(0,2));
|
||||
REQUIRE(bb.max == Point(40,4));
|
||||
|
@ -193,7 +193,7 @@ SCENARIO("BoundingBox", "[Geometry]") {
|
|||
TEST_CASE("Offseting a line generates a polygon correctly", "[Geometry]"){
|
||||
Slic3r::Polyline tmp = { Point(10,10), Point(20,10) };
|
||||
Slic3r::Polygon area = offset(tmp,5).at(0);
|
||||
REQUIRE(area.area() == Slic3r::Polygon(std::vector<Point>({Point(10,5),Point(20,5),Point(20,15),Point(10,15)})).area());
|
||||
REQUIRE(area.area() == Slic3r::Polygon(Points({Point(10,5),Point(20,5),Point(20,15),Point(10,15)})).area());
|
||||
}
|
||||
|
||||
SCENARIO("Circle Fit, TaubinFit with Newton's method", "[Geometry]") {
|
||||
|
@ -308,7 +308,7 @@ TEST_CASE("smallest_enclosing_circle_welzl", "[Geometry]") {
|
|||
|
||||
SCENARIO("Path chaining", "[Geometry]") {
|
||||
GIVEN("A path") {
|
||||
std::vector<Point> points = { Point(26,26),Point(52,26),Point(0,26),Point(26,52),Point(26,0),Point(0,52),Point(52,52),Point(52,0) };
|
||||
Points points = { Point(26,26),Point(52,26),Point(0,26),Point(26,52),Point(26,0),Point(0,52),Point(52,52),Point(52,0) };
|
||||
THEN("Chained with no diagonals (thus 26 units long)") {
|
||||
std::vector<Points::size_type> indices = chain_points(points);
|
||||
for (Points::size_type i = 0; i + 1 < indices.size(); ++ i) {
|
||||
|
@ -431,7 +431,7 @@ SCENARIO("Calculating angles", "[Geometry]")
|
|||
SCENARIO("Polygon convex/concave detection", "[Geometry]"){
|
||||
static constexpr const double angle_threshold = M_PI / 3.;
|
||||
GIVEN(("A Square with dimension 100")){
|
||||
auto square = Slic3r::Polygon /*new_scale*/(std::vector<Point>({
|
||||
auto square = Slic3r::Polygon /*new_scale*/(Points({
|
||||
Point(100,100),
|
||||
Point(200,100),
|
||||
Point(200,200),
|
||||
|
@ -447,7 +447,7 @@ SCENARIO("Polygon convex/concave detection", "[Geometry]"){
|
|||
}
|
||||
}
|
||||
GIVEN("A Square with an extra colinearvertex"){
|
||||
auto square = Slic3r::Polygon /*new_scale*/(std::vector<Point>({
|
||||
auto square = Slic3r::Polygon /*new_scale*/(Points({
|
||||
Point(150,100),
|
||||
Point(200,100),
|
||||
Point(200,200),
|
||||
|
@ -459,7 +459,7 @@ SCENARIO("Polygon convex/concave detection", "[Geometry]"){
|
|||
}
|
||||
}
|
||||
GIVEN("A Square with an extra collinear vertex in different order"){
|
||||
auto square = Slic3r::Polygon /*new_scale*/(std::vector<Point>({
|
||||
auto square = Slic3r::Polygon /*new_scale*/(Points({
|
||||
Point(200,200),
|
||||
Point(100,200),
|
||||
Point(100,100),
|
||||
|
@ -472,7 +472,7 @@ SCENARIO("Polygon convex/concave detection", "[Geometry]"){
|
|||
}
|
||||
|
||||
GIVEN("A triangle"){
|
||||
auto triangle = Slic3r::Polygon(std::vector<Point>({
|
||||
auto triangle = Slic3r::Polygon(Points({
|
||||
Point(16000170,26257364),
|
||||
Point(714223,461012),
|
||||
Point(31286371,461008)
|
||||
|
@ -484,7 +484,7 @@ SCENARIO("Polygon convex/concave detection", "[Geometry]"){
|
|||
}
|
||||
|
||||
GIVEN("A triangle with an extra collinear point"){
|
||||
auto triangle = Slic3r::Polygon(std::vector<Point>({
|
||||
auto triangle = Slic3r::Polygon(Points({
|
||||
Point(16000170,26257364),
|
||||
Point(714223,461012),
|
||||
Point(20000000,461012),
|
||||
|
@ -498,7 +498,7 @@ SCENARIO("Polygon convex/concave detection", "[Geometry]"){
|
|||
GIVEN("A polygon with concave vertices with angles of specifically 4/3pi"){
|
||||
// Two concave vertices of this polygon have angle = PI*4/3, so this test fails
|
||||
// if epsilon is not used.
|
||||
auto polygon = Slic3r::Polygon(std::vector<Point>({
|
||||
auto polygon = Slic3r::Polygon(Points({
|
||||
Point(60246458,14802768),Point(64477191,12360001),
|
||||
Point(63727343,11060995),Point(64086449,10853608),
|
||||
Point(66393722,14850069),Point(66034704,15057334),
|
||||
|
@ -516,7 +516,7 @@ SCENARIO("Polygon convex/concave detection", "[Geometry]"){
|
|||
}
|
||||
|
||||
TEST_CASE("Triangle Simplification does not result in less than 3 points", "[Geometry]"){
|
||||
auto triangle = Slic3r::Polygon(std::vector<Point>({
|
||||
auto triangle = Slic3r::Polygon(Points({
|
||||
Point(16000170,26257364), Point(714223,461012), Point(31286371,461008)
|
||||
}));
|
||||
REQUIRE(triangle.simplify(250000).at(0).points.size() == 3);
|
||||
|
|
|
@ -8,7 +8,7 @@ add_executable(${_TEST_NAME}_tests ${_TEST_NAME}_tests_main.cpp
|
|||
sla_archive_readwrite_tests.cpp)
|
||||
|
||||
# mold linker for successful linking needs also to link TBB library and link it before libslic3r.
|
||||
target_link_libraries(${_TEST_NAME}_tests test_common TBB::tbb libslic3r)
|
||||
target_link_libraries(${_TEST_NAME}_tests test_common TBB::tbb TBB::tbbmalloc libslic3r)
|
||||
set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests")
|
||||
|
||||
if (WIN32)
|
||||
|
|
|
@ -6,7 +6,7 @@ add_executable(${_TEST_NAME}_tests
|
|||
)
|
||||
|
||||
# mold linker for successful linking needs also to link TBB library and link it before libslic3r.
|
||||
target_link_libraries(${_TEST_NAME}_tests test_common TBB::tbb libslic3r_gui libslic3r)
|
||||
target_link_libraries(${_TEST_NAME}_tests test_common TBB::tbb TBB::tbbmalloc libslic3r_gui libslic3r)
|
||||
if (MSVC)
|
||||
target_link_libraries(${_TEST_NAME}_tests Setupapi.lib)
|
||||
endif ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue