mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-06 05:24:01 -06:00
New slicing algorithm based on a topological approach rather than numeric. It should be much more robust
This commit is contained in:
parent
de88144649
commit
a9e7204fc6
6 changed files with 339 additions and 271 deletions
24
t/stl.t
24
t/stl.t
|
@ -13,12 +13,12 @@ use Slic3r;
|
|||
use Slic3r::Geometry qw(X Y Z A B);
|
||||
use XXX;
|
||||
|
||||
my $mesh = Slic3r::TriangleMesh->new;
|
||||
|
||||
my @lines;
|
||||
my $z = 20;
|
||||
my @points = ([3, 4], [8, 5], [1, 9]); # XY coordinates of the facet vertices
|
||||
|
||||
my $mesh = Slic3r::TriangleMesh->new(facets => [], vertices => []);
|
||||
|
||||
is_deeply lines(20, 20, 20), [
|
||||
[ $points[0], $points[1] ],
|
||||
[ $points[1], $points[2] ],
|
||||
|
@ -40,8 +40,8 @@ is_deeply lines(28, 20, 30), [ ], 'lower vertex on la
|
|||
my @z = (24, 10, 16);
|
||||
is_deeply lines(@z), [
|
||||
[
|
||||
line_plane_intersection([ vertices(@z)->[2], vertices(@z)->[0] ]),
|
||||
line_plane_intersection([ vertices(@z)->[0], vertices(@z)->[1] ]),
|
||||
line_plane_intersection([ vertices(@z)->[2], vertices(@z)->[0] ]),
|
||||
]
|
||||
], 'two edges intersect';
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ is_deeply lines(28, 20, 30), [ ], 'lower vertex on la
|
|||
my @z = (24, 10, 20);
|
||||
is_deeply lines(@z), [
|
||||
[
|
||||
$points[2],
|
||||
line_plane_intersection([ vertices(@z)->[0], vertices(@z)->[1] ]),
|
||||
$points[2],
|
||||
]
|
||||
], 'one vertex on plane and one edge intersects';
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ is_deeply lines(28, 20, 30), [ ], 'lower vertex on la
|
|||
], 'one vertex on plane and one edge intersects';
|
||||
}
|
||||
|
||||
my @lower = $mesh->intersect_facet(0, vertices(22, 20, 20), $z);
|
||||
my @upper = $mesh->intersect_facet(0, vertices(20, 20, 10), $z);
|
||||
my @lower = intersect(22, 20, 20);
|
||||
my @upper = intersect(20, 20, 10);
|
||||
is $lower[0]->facet_edge, 'bottom', 'bottom edge on layer';
|
||||
is $upper[0]->facet_edge, 'top', 'upper edge on layer';
|
||||
|
||||
|
@ -106,8 +106,18 @@ sub vertices {
|
|||
[ ($#{$mesh->vertices}-2) .. $#{$mesh->vertices} ]
|
||||
}
|
||||
|
||||
sub add_facet {
|
||||
push @{$mesh->facets}, [ [0,0,0], @{vertices(@_)} ];
|
||||
$mesh->BUILD;
|
||||
}
|
||||
|
||||
sub intersect {
|
||||
add_facet(@_);
|
||||
return $mesh->intersect_facet($#{$mesh->facets}, $z);
|
||||
}
|
||||
|
||||
sub lines {
|
||||
my @lines = $mesh->intersect_facet(0, vertices(@_), $z);
|
||||
my @lines = intersect(@_);
|
||||
$_->a->[X] = sprintf('%.0f', $_->a->[X]) for @lines;
|
||||
$_->a->[Y] = sprintf('%.0f', $_->a->[Y]) for @lines;
|
||||
$_->b->[X] = sprintf('%.0f', $_->b->[X]) for @lines;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue