Ported (and used) ExtrusionPath->first_point

This commit is contained in:
Alessandro Ranellucci 2013-08-26 23:42:00 +02:00
parent fe42427a54
commit 9fb14f2119
6 changed files with 16 additions and 9 deletions

View file

@ -65,11 +65,6 @@ sub points {
return $self->polyline; return $self->polyline;
} }
sub first_point {
my $self = shift;
return $self->polyline->[0];
}
sub is_perimeter { sub is_perimeter {
my $self = shift; my $self = shift;
return $self->role == EXTR_ROLE_PERIMETER return $self->role == EXTR_ROLE_PERIMETER

View file

@ -268,7 +268,7 @@ sub extrude_loop {
my $distance = min(scale $extrusion_path->flow_spacing, $first_segment->length); my $distance = min(scale $extrusion_path->flow_spacing, $first_segment->length);
my $point = Slic3r::Geometry::point_along_segment(@$first_segment, $distance); my $point = Slic3r::Geometry::point_along_segment(@$first_segment, $distance);
$point = Slic3r::Point->new(@$point); $point = Slic3r::Point->new(@$point);
$point->rotate($angle, $extrusion_path->polyline->[0]); $point->rotate($angle, $extrusion_path->first_point);
# generate the travel move # generate the travel move
$gcode .= $self->travel_to($point, $loop->role, "move inwards before travel"); $gcode .= $self->travel_to($point, $loop->role, "move inwards before travel");
@ -294,8 +294,9 @@ sub extrude_path {
# go to first point of extrusion path # go to first point of extrusion path
my $gcode = ""; my $gcode = "";
$gcode .= $self->travel_to($path->points->[0], $path->role, "move to first $description point") my $first_point = $path->first_point;
if !defined $self->last_pos || !$self->last_pos->coincides_with($path->points->[0]); $gcode .= $self->travel_to($first_point, $path->role, "move to first $description point")
if !defined $self->last_pos || !$self->last_pos->coincides_with($first_point);
# compensate retraction # compensate retraction
$gcode .= $self->unretract; $gcode .= $self->unretract;

View file

@ -8,6 +8,12 @@ ExtrusionPath::reverse()
this->polyline.reverse(); this->polyline.reverse();
} }
const Point*
ExtrusionPath::first_point() const
{
return &(this->polyline.points.front());
}
ExtrusionPath* ExtrusionPath*
ExtrusionLoop::split_at_index(int index) ExtrusionLoop::split_at_index(int index)
{ {

View file

@ -38,6 +38,7 @@ class ExtrusionPath : public ExtrusionEntity
public: public:
Polyline polyline; Polyline polyline;
void reverse(); void reverse();
const Point* first_point() const;
}; };
class ExtrusionLoop : public ExtrusionEntity class ExtrusionLoop : public ExtrusionEntity

View file

@ -4,7 +4,7 @@ use strict;
use warnings; use warnings;
use Slic3r::XS; use Slic3r::XS;
use Test::More tests => 7; use Test::More tests => 8;
my $points = [ my $points = [
[100, 100], [100, 100],
@ -28,6 +28,8 @@ is scalar(@$path), 4, 'append to path';
$path->pop_back; $path->pop_back;
is scalar(@$path), 3, 'pop_back from path'; is scalar(@$path), 3, 'pop_back from path';
ok $path->first_point->coincides_with($path->polyline->[0]), 'first_point';
$path = $path->clone; $path = $path->clone;
is $path->role, Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, 'role'; is $path->role, Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, 'role';

View file

@ -16,6 +16,8 @@
void reverse(); void reverse();
Lines lines() Lines lines()
%code{% RETVAL = THIS->polyline.lines(); %}; %code{% RETVAL = THIS->polyline.lines(); %};
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*(THIS->first_point())); %};
%{ %{
ExtrusionPath* ExtrusionPath*