mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 06:57:36 -06:00
Lots of changes and refactoring after testing with hollow objects
This commit is contained in:
parent
26b05ab155
commit
18c7aef1a7
15 changed files with 716 additions and 494 deletions
|
@ -3,24 +3,23 @@ use Moo;
|
|||
|
||||
has 'x' => (
|
||||
is => 'ro',
|
||||
#isa => 'Slic3r::Point::Coordinate',
|
||||
required => 1,
|
||||
coerce => sub { sprintf '%.0f', $_[0] },
|
||||
);
|
||||
|
||||
has 'y' => (
|
||||
is => 'ro',
|
||||
#isa => 'Slic3r::Point::Coordinate',
|
||||
required => 1,
|
||||
coerce => sub { sprintf '%.0f', $_[0] },
|
||||
);
|
||||
|
||||
# this array contains weak references, so it can contain undef's as well
|
||||
has 'lines' => (
|
||||
is => 'rw',
|
||||
#isa => 'ArrayRef[Slic3r::Line]',
|
||||
default => sub { [] },
|
||||
);
|
||||
sub cast {
|
||||
my $class = shift;
|
||||
my ($point) = @_;
|
||||
return ref $point eq 'ARRAY'
|
||||
? Slic3r::Point->new(x => $point->[0], y => $point->[1]) # ==
|
||||
: $point;
|
||||
}
|
||||
|
||||
sub id {
|
||||
my $self = shift;
|
||||
|
@ -32,20 +31,21 @@ sub coordinates {
|
|||
return ($self->x, $self->y); #))
|
||||
}
|
||||
|
||||
sub p {
|
||||
my $self = shift;
|
||||
return [ $self->coordinates ];
|
||||
}
|
||||
|
||||
sub coincides_with {
|
||||
my $self = shift;
|
||||
my ($point) = @_;
|
||||
|
||||
$point = Slic3r::Point->new(x => $point->[0], y => $point->[1]) #==
|
||||
if ref $point eq 'ARRAY';
|
||||
return $self->x == $point->x && $self->y == $point->y; #=
|
||||
return Slic3r::Geometry::points_coincide($self->p, $point->p);
|
||||
}
|
||||
|
||||
sub distance_to {
|
||||
my $self = shift;
|
||||
my ($point) = @_;
|
||||
|
||||
return sqrt(($point->x - $self->x)**2 + ($point->y - $self->y)**2); #-
|
||||
return Slic3r::Geometry::distance_between_points($self->p, $point->p);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue