Don't return first_point() and last_point() by reference

This commit is contained in:
Alessandro Ranellucci 2013-09-02 22:33:03 +02:00
parent 0ffb0f6a58
commit 275422fac7
12 changed files with 28 additions and 42 deletions

View File

@ -356,7 +356,7 @@ sub extrude_path {
}
}
$gcode .= ";_BRIDGE_FAN_END\n" if $path->is_bridge;
$self->last_pos($path->last_point->clone);
$self->last_pos($path->last_point);
if ($self->config->cooling) {
my $path_time = $path_length / $F * 60;

View File

@ -252,7 +252,7 @@ sub make_perimeters {
# use a nearest neighbor search to order these children
# TODO: supply second argument to chained_path_items() too?
my @nodes = @{Slic3r::Geometry::chained_path_items(
[ map [ ($_->{outer} // $_->{hole})->first_point->clone, $_ ], @$polynodes ],
[ map [ ($_->{outer} // $_->{hole})->first_point, $_ ], @$polynodes ],
)};
my @loops = ();

View File

@ -15,15 +15,15 @@ ExtrusionPath::reverse()
}
Point*
ExtrusionPath::first_point()
ExtrusionPath::first_point() const
{
return &(this->polyline.points.front());
return new Point(this->polyline.points.front());
}
Point*
ExtrusionPath::last_point()
ExtrusionPath::last_point() const
{
return &(this->polyline.points.back());
return new Point(this->polyline.points.back());
}
ExtrusionLoop*
@ -66,15 +66,15 @@ ExtrusionLoop::reverse()
}
Point*
ExtrusionLoop::first_point()
ExtrusionLoop::first_point() const
{
return &(this->polygon.points.front());
return new Point(this->polygon.points.front());
}
Point*
ExtrusionLoop::last_point()
ExtrusionLoop::last_point() const
{
return &(this->polygon.points.front()); // in polygons, first == last
return new Point(this->polygon.points.front()); // in polygons, first == last
}
}

View File

@ -31,8 +31,8 @@ class ExtrusionEntity
double height; // vertical thickness of the extrusion expressed in mm
double flow_spacing;
virtual void reverse() = 0;
virtual Point* first_point() = 0;
virtual Point* last_point() = 0;
virtual Point* first_point() const = 0;
virtual Point* last_point() const = 0;
};
typedef std::vector<ExtrusionEntity*> ExtrusionEntitiesPtr;
@ -43,8 +43,8 @@ class ExtrusionPath : public ExtrusionEntity
ExtrusionPath* clone() const;
Polyline polyline;
void reverse();
Point* first_point();
Point* last_point();
Point* first_point() const;
Point* last_point() const;
};
class ExtrusionLoop : public ExtrusionEntity
@ -56,8 +56,8 @@ class ExtrusionLoop : public ExtrusionEntity
ExtrusionPath* split_at_first_point();
bool make_counter_clockwise();
void reverse();
Point* first_point();
Point* last_point();
Point* first_point() const;
Point* last_point() const;
};
}

View File

@ -22,13 +22,13 @@ ExtrusionEntityCollection::reverse()
}
Point*
ExtrusionEntityCollection::first_point()
ExtrusionEntityCollection::first_point() const
{
return this->entities.front()->first_point();
}
Point*
ExtrusionEntityCollection::last_point()
ExtrusionEntityCollection::last_point() const
{
return this->entities.back()->last_point();
}

View File

@ -16,8 +16,8 @@ class ExtrusionEntityCollection : public ExtrusionEntity
ExtrusionEntityCollection* chained_path(bool no_reverse) const;
ExtrusionEntityCollection* chained_path_from(Point* start_near, bool no_reverse) const;
void reverse();
Point* first_point();
Point* last_point();
Point* first_point() const;
Point* last_point() const;
};
}

View File

@ -33,15 +33,9 @@ MultiPoint::reverse()
}
Point*
MultiPoint::first_point()
{
return &(this->points.front());
}
const Point*
MultiPoint::first_point() const
{
return &(this->points.front());
return new Point(this->points.front());
}
void

View File

@ -19,9 +19,8 @@ class MultiPoint
void translate(double x, double y);
void rotate(double angle, Point* center);
void reverse();
Point* first_point();
const Point* first_point() const;
virtual Point* last_point() = 0;
Point* first_point() const;
virtual Point* last_point() const = 0;
};
}

View File

@ -6,9 +6,9 @@
namespace Slic3r {
Point*
Polygon::last_point()
Polygon::last_point() const
{
return &(this->points.front()); // last point == first point for polygons
return new Point(this->points.front()); // last point == first point for polygons
}
SV*

View File

@ -11,7 +11,7 @@ namespace Slic3r {
class Polygon : public MultiPoint {
public:
Point* last_point();
Point* last_point() const;
SV* to_SV_ref() const;
SV* to_SV_clone_ref() const;
Lines lines();

View File

@ -3,15 +3,9 @@
namespace Slic3r {
Point*
Polyline::last_point()
{
return &(this->points.back());
}
const Point*
Polyline::last_point() const
{
return &(this->points.back());
return new Point(this->points.back());
}
Lines

View File

@ -8,8 +8,7 @@ namespace Slic3r {
class Polyline : public MultiPoint {
public:
Point* last_point();
const Point* last_point() const;
Point* last_point() const;
Lines lines();
SV* to_SV_ref() const;
SV* to_SV_clone_ref() const;