diff --git a/t/geometry.t b/t/geometry.t index 20736b50..643900c1 100644 --- a/t/geometry.t +++ b/t/geometry.t @@ -69,25 +69,25 @@ isnt Slic3r::Geometry::line_intersection($line1, $line2, 1), undef, 'line_inters my $polygons = [ Slic3r::Polygon->new( # contour, ccw - [459190000, 5152739000], [147261000, 4612464000], [147261000, 3487535000], [339887000, 3153898000], - [437497000, 3438430000], [454223000, 3522515000], [523621000, 3626378000], [627484000, 3695776000], - [750000000, 3720147000], [872515000, 3695776000], [976378000, 3626378000], [1045776000, 3522515000], - [1070147000, 3400000000], [1045776000, 3277484000], [976378000, 3173621000], [872515000, 3104223000], - [827892000, 3095347000], [698461000, 2947261000], [2540810000, 2947261000], [2852739000, 3487535000], - [2852739000, 4612464000], [2540810000, 5152739000], + [45919000, 515273900], [14726100, 461246400], [14726100, 348753500], [33988700, 315389800], + [43749700, 343843000], [45422300, 352251500], [52362100, 362637800], [62748400, 369577600], + [75000000, 372014700], [87251500, 369577600], [97637800, 362637800], [104577600, 352251500], + [107014700, 340000000], [104577600, 327748400], [97637800, 317362100], [87251500, 310422300], + [82789200, 309534700], [69846100, 294726100], [254081000, 294726100], [285273900, 348753500], + [285273900, 461246400], [254081000, 515273900], ), Slic3r::Polygon->new( # hole, cw - [750000000, 5020147000], [872515000, 4995776000], [976378000, 4926378000], [1045776000, 4822515000], - [1070147000, 4700000000], [1045776000, 4577484000], [976378000, 4473621000], [872515000, 4404223000], - [750000000, 4379853000], [627484000, 4404223000], [523621000, 4473621000], [454223000, 4577484000], - [429853000, 4700000000], [454223000, 4822515000], [523621000, 4926378000], [627484000, 4995776000], + [75000000, 502014700], [87251500, 499577600], [97637800, 492637800], [104577600, 482251500], + [107014700, 470000000], [104577600, 457748400], [97637800, 447362100], [87251500, 440422300], + [75000000, 437985300], [62748400, 440422300], [52362100, 447362100], [45422300, 457748400], + [42985300, 470000000], [45422300, 482251500], [52362100, 492637800], [62748400, 499577600], ), ]; my $points = [ - Slic3r::Point->new(736310778.185108, 3717423926.892399788), - Slic3r::Point->new(736310778.185108, 5017423926.8924), + Slic3r::Point->new(73631077, 371742392), + Slic3r::Point->new(73631077, 501742392), ]; is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_points'; diff --git a/t/polyclip.t b/t/polyclip.t index 1711abfd..548b6ba6 100644 --- a/t/polyclip.t +++ b/t/polyclip.t @@ -114,7 +114,7 @@ is_deeply $intersection, [ [120, 120], [180, 160] ], 'internal lines are preserv #========================================================== { - my $large_circle = Slic3r::Polygon->new( # ccw + my $large_circle = Slic3r::Polygon->new_scale( # ccw [151.8639,288.1192], [133.2778,284.6011], [115.0091,279.6997], [98.2859,270.8606], [82.2734,260.7933], [68.8974,247.4181], [56.5622,233.0777], [47.7228,216.3558], [40.1617,199.0172], [36.6431,180.4328], [34.932,165.2312], [37.5567,165.1101], [41.0547,142.9903], [36.9056,141.4295], [40.199,124.1277], @@ -127,7 +127,7 @@ is_deeply $intersection, [ [120, 120], [180, 160] ], 'internal lines are preserv ); ok $large_circle->is_counter_clockwise, "contour is counter-clockwise"; - my $small_circle = Slic3r::Polygon->new( # cw + my $small_circle = Slic3r::Polygon->new_scale( # cw [158.227,215.9007], [164.5136,215.9007], [175.15,214.5007], [184.5576,210.6044], [190.2268,207.8743], [199.1462,201.0306], [209.0146,188.346], [213.5135,177.4829], [214.6979,168.4866], [216.1025,162.3325], [214.6463,151.2703], [213.2471,145.1399], [209.0146,134.9203], [199.1462,122.2357], [189.8944,115.1366], @@ -139,12 +139,12 @@ is_deeply $intersection, [ [120, 120], [180, 160] ], 'internal lines are preserv ok $small_circle->is_clockwise, "hole is clockwise"; my $expolygon = Slic3r::ExPolygon->new($large_circle, $small_circle); - $line = Slic3r::Line->new([152.742,288.086671142818], [152.742,34.166466971035]); + $line = Slic3r::Line->new_scale([152.742,288.086671142818], [152.742,34.166466971035]); my $intersections = $expolygon->clip_line($line); is_deeply [ map $_->pp, @$intersections ], [ - [ [152, 287], [152, 214], ], - [ [152, 107], [152, 35] ], + [ [152742000, 288086661], [152742000, 215178843], ], + [ [152742000, 108087507], [152742000, 35166477] ], ], 'line is clipped to square with hole'; } diff --git a/xs/src/Point.cpp b/xs/src/Point.cpp index 28a468f7..b39a06c1 100644 --- a/xs/src/Point.cpp +++ b/xs/src/Point.cpp @@ -112,8 +112,10 @@ void Point::from_SV(SV* point_sv) { AV* point_av = (AV*)SvRV(point_sv); - this->x = (long)SvIV(*av_fetch(point_av, 0, 0)); - this->y = (long)SvIV(*av_fetch(point_av, 1, 0)); + // get a double from Perl and round it, otherwise + // it would get truncated + this->x = lrint(SvNV(*av_fetch(point_av, 0, 0))); + this->y = lrint(SvNV(*av_fetch(point_av, 1, 0))); } void