mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-16 00:45:55 +08:00
Some cleanup and further optimization to 5f521b24c42ed657967b919871900fa6a65ba790. #3293
This commit is contained in:
parent
3daf64ae56
commit
6f1d1f6af7
@ -490,21 +490,18 @@ sub process_layer {
|
||||
|
||||
# group extrusions by extruder and then by island
|
||||
my %by_extruder = (); # extruder_id => [ { perimeters => \@perimeters, infill => \@infill } ]
|
||||
|
||||
my $n_slices = $#{$layer->slices};
|
||||
my @layer_surface_bboxes = ();
|
||||
for my $i (0 .. $n_slices) {
|
||||
push @layer_surface_bboxes, $layer->slices->[$i]->contour->bounding_box;
|
||||
}
|
||||
|
||||
# cache bounding boxes of layer slices
|
||||
my @layer_slices_bb = map $_->contour->bounding_box, @{$layer->slices};
|
||||
my $point_inside_surface = sub {
|
||||
my ($i, $point) = @_;
|
||||
my $bbox = $layer_surface_bboxes[$i];
|
||||
return
|
||||
$point->x >= $bbox->x_min && $point->x < $bbox->x_max &&
|
||||
$point->y >= $bbox->y_min && $point->y < $bbox->y_max &&
|
||||
$layer->slices->[$i]->contour->contains_point($point);
|
||||
|
||||
my $bbox = $layer_slices_bb[$i];
|
||||
return $layer_slices_bb[$i]->contains_point($point)
|
||||
&& $layer->slices->[$i]->contour->contains_point($point);
|
||||
};
|
||||
|
||||
|
||||
my $n_slices = $layer->slices->count - 1;
|
||||
foreach my $region_id (0..($self->print->region_count-1)) {
|
||||
my $layerm = $layer->regions->[$region_id] or next;
|
||||
my $region = $self->print->get_region($region_id);
|
||||
|
@ -219,4 +219,13 @@ BoundingBox3Base<PointClass>::center() const
|
||||
}
|
||||
template Pointf3 BoundingBox3Base<Pointf3>::center() const;
|
||||
|
||||
template <class PointClass> bool
|
||||
BoundingBoxBase<PointClass>::contains(const PointClass &point) const
|
||||
{
|
||||
return point.x >= this->min.x && point.x <= this->max.x
|
||||
&& point.y >= this->min.y && point.y <= this->max.y;
|
||||
}
|
||||
template bool BoundingBoxBase<Point>::contains(const Point &point) const;
|
||||
template bool BoundingBoxBase<Pointf>::contains(const Pointf &point) const;
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ class BoundingBoxBase
|
||||
void translate(coordf_t x, coordf_t y);
|
||||
void offset(coordf_t delta);
|
||||
PointClass center() const;
|
||||
bool contains(const PointClass &point) const;
|
||||
};
|
||||
|
||||
template <class PointClass>
|
||||
|
@ -16,6 +16,7 @@
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void offset(double delta);
|
||||
bool contains_point(Point* point) %code{% RETVAL = THIS->contains(*point); %};
|
||||
Clone<Polygon> polygon();
|
||||
Clone<Point> size();
|
||||
Clone<Point> center();
|
||||
@ -49,6 +50,7 @@ new_from_points(CLASS, points)
|
||||
void merge_point(Pointf* point) %code{% THIS->merge(*point); %};
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
bool contains_point(Pointf* point) %code{% RETVAL = THIS->contains(*point); %};
|
||||
Clone<Pointf> size();
|
||||
Clone<Pointf> center();
|
||||
Clone<Pointf> min_point() %code{% RETVAL = THIS->min; %};
|
||||
|
Loading…
x
Reference in New Issue
Block a user