mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-20 15:21:21 -06:00
Include thin walls in general top-level perimeter sorting to get more efficient paths
This commit is contained in:
parent
2a73ab988f
commit
7f5442265e
11 changed files with 130 additions and 94 deletions
|
@ -109,7 +109,7 @@ sub new {
|
|||
sub clone {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
return (ref $self)->_new(
|
||||
return __PACKAGE__->_new(
|
||||
$args{polygon} // $self->polygon,
|
||||
$args{role} // $self->role,
|
||||
$args{mm3_per_mm} // $self->mm3_per_mm,
|
||||
|
@ -139,7 +139,7 @@ sub new {
|
|||
sub clone {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
return (ref $self)->_new(
|
||||
return __PACKAGE__->_new(
|
||||
$args{polyline} // $self->polyline,
|
||||
$args{role} // $self->role,
|
||||
$args{mm3_per_mm} // $self->mm3_per_mm,
|
||||
|
|
|
@ -54,22 +54,22 @@ ExtrusionPath::last_point() const
|
|||
return new Point(this->polyline.points.back());
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection*
|
||||
ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection) const
|
||||
void
|
||||
ExtrusionPath::intersect_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const
|
||||
{
|
||||
// perform clipping
|
||||
Polylines clipped;
|
||||
intersection(this->polyline, *collection, clipped);
|
||||
return this->_inflate_collection(clipped);
|
||||
intersection(this->polyline, collection, clipped);
|
||||
return this->_inflate_collection(clipped, retval);
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection*
|
||||
ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection) const
|
||||
void
|
||||
ExtrusionPath::subtract_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const
|
||||
{
|
||||
// perform clipping
|
||||
Polylines clipped;
|
||||
diff(this->polyline, *collection, clipped);
|
||||
return this->_inflate_collection(clipped);
|
||||
diff(this->polyline, collection, clipped);
|
||||
return this->_inflate_collection(clipped, retval);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -90,16 +90,14 @@ ExtrusionPath::length() const
|
|||
return this->polyline.length();
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection*
|
||||
ExtrusionPath::_inflate_collection(const Polylines &polylines) const
|
||||
void
|
||||
ExtrusionPath::_inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const
|
||||
{
|
||||
ExtrusionEntityCollection* retval = new ExtrusionEntityCollection();
|
||||
for (Polylines::const_iterator it = polylines.begin(); it != polylines.end(); ++it) {
|
||||
ExtrusionPath* path = this->clone();
|
||||
path->polyline = *it;
|
||||
retval->entities.push_back(path);
|
||||
collection->entities.push_back(path);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
ExtrusionLoop*
|
||||
|
|
|
@ -50,13 +50,13 @@ class ExtrusionPath : public ExtrusionEntity
|
|||
void reverse();
|
||||
Point* first_point() const;
|
||||
Point* last_point() const;
|
||||
ExtrusionEntityCollection* intersect_expolygons(ExPolygonCollection* collection) const;
|
||||
ExtrusionEntityCollection* subtract_expolygons(ExPolygonCollection* collection) const;
|
||||
void intersect_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const;
|
||||
void subtract_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const;
|
||||
void clip_end(double distance);
|
||||
void simplify(double tolerance);
|
||||
double length() const;
|
||||
private:
|
||||
ExtrusionEntityCollection* _inflate_collection(const Polylines &polylines) const;
|
||||
void _inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const;
|
||||
};
|
||||
|
||||
class ExtrusionLoop : public ExtrusionEntity
|
||||
|
|
|
@ -47,6 +47,8 @@ ExtrusionEntityCollection::chained_path_from(Point* start_near, bool no_reverse)
|
|||
{
|
||||
if (this->no_sort) return this->clone();
|
||||
ExtrusionEntityCollection* retval = new ExtrusionEntityCollection;
|
||||
retval->entities.reserve(this->entities.size());
|
||||
retval->orig_indices.reserve(this->entities.size());
|
||||
|
||||
ExtrusionEntitiesPtr my_paths;
|
||||
for (ExtrusionEntitiesPtr::const_iterator it = this->entities.begin(); it != this->entities.end(); ++it) {
|
||||
|
@ -71,6 +73,7 @@ ExtrusionEntityCollection::chained_path_from(Point* start_near, bool no_reverse)
|
|||
my_paths.at(path_index)->reverse();
|
||||
}
|
||||
retval->entities.push_back(my_paths.at(path_index));
|
||||
retval->orig_indices.push_back(path_index);
|
||||
my_paths.erase(my_paths.begin() + path_index);
|
||||
endpoints.erase(endpoints.begin() + 2*path_index, endpoints.begin() + 2*path_index + 2);
|
||||
start_near = retval->entities.back()->last_point();
|
||||
|
|
|
@ -11,6 +11,7 @@ class ExtrusionEntityCollection : public ExtrusionEntity
|
|||
public:
|
||||
ExtrusionEntityCollection* clone() const;
|
||||
ExtrusionEntitiesPtr entities;
|
||||
std::vector<int> orig_indices;
|
||||
bool no_sort;
|
||||
ExtrusionEntityCollection(): no_sort(false) {};
|
||||
ExtrusionEntityCollection* chained_path(bool no_reverse) const;
|
||||
|
|
|
@ -104,10 +104,4 @@ is $expolygon->area, 100*100-20*20, 'area';
|
|||
is_deeply $collection->[0]->clone->pp, $collection->[0]->pp, 'clone collection item';
|
||||
}
|
||||
|
||||
{
|
||||
my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square);
|
||||
my $res = $expolygon->medial_axis(10);
|
||||
use XXX; YYY $res;
|
||||
}
|
||||
|
||||
__END__
|
||||
|
|
|
@ -4,7 +4,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 14;
|
||||
use Test::More tests => 16;
|
||||
|
||||
my $points = [
|
||||
[100, 100],
|
||||
|
@ -40,6 +40,8 @@ is scalar(@$collection), 4, 'append ExtrusionLoop';
|
|||
isa_ok $collection->[1], 'Slic3r::ExtrusionPath::Collection::Ref', 'correct object returned for collection';
|
||||
isa_ok $collection->[2], 'Slic3r::ExtrusionPath::Ref', 'correct object returned for path';
|
||||
isa_ok $collection->[3], 'Slic3r::ExtrusionLoop::Ref', 'correct object returned for loop';
|
||||
is ref($collection->[2]->clone), 'Slic3r::ExtrusionPath', 'correct object returned for cloned path';
|
||||
is ref($collection->[3]->clone), 'Slic3r::ExtrusionLoop', 'correct object returned for cloned loop';
|
||||
|
||||
is scalar(@{$collection->[1]}), 1, 'appended collection was duplicated';
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->last_point(); %};
|
||||
int count()
|
||||
%code{% RETVAL = THIS->entities.size(); %};
|
||||
std::vector<int> orig_indices()
|
||||
%code{% RETVAL = THIS->orig_indices; %};
|
||||
%{
|
||||
|
||||
void
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
%{
|
||||
#include <myinit.h>
|
||||
#include "ExtrusionEntity.hpp"
|
||||
#include "ExtrusionEntityCollection.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::ExtrusionPath} class ExtrusionPath {
|
||||
|
@ -20,10 +21,6 @@
|
|||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->first_point(); %};
|
||||
Point* last_point()
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->last_point(); %};
|
||||
ExtrusionEntityCollection* intersect_expolygons(ExPolygonCollection* collection)
|
||||
%code{% const char* CLASS = "Slic3r::ExtrusionPath::Collection"; RETVAL = THIS->intersect_expolygons(collection); %};
|
||||
ExtrusionEntityCollection* subtract_expolygons(ExPolygonCollection* collection)
|
||||
%code{% const char* CLASS = "Slic3r::ExtrusionPath::Collection"; RETVAL = THIS->subtract_expolygons(collection); %};
|
||||
void clip_end(double distance);
|
||||
void simplify(double tolerance);
|
||||
double length();
|
||||
|
@ -87,6 +84,26 @@ ExtrusionPath::append(...)
|
|||
THIS->polyline.points.push_back(p);
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection*
|
||||
ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection)
|
||||
PREINIT:
|
||||
const char* CLASS = "Slic3r::ExtrusionPath::Collection";
|
||||
CODE:
|
||||
RETVAL = new ExtrusionEntityCollection ();
|
||||
THIS->intersect_expolygons(*collection, RETVAL);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
ExtrusionEntityCollection*
|
||||
ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection)
|
||||
PREINIT:
|
||||
const char* CLASS = "Slic3r::ExtrusionPath::Collection";
|
||||
CODE:
|
||||
RETVAL = new ExtrusionEntityCollection ();
|
||||
THIS->subtract_expolygons(*collection, RETVAL);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
%}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
%typemap{bool}{simple};
|
||||
%typemap{std::string};
|
||||
%typemap{t_config_option_key};
|
||||
%typemap{std::vector<int>};
|
||||
%typemap{std::vector<unsigned int>*};
|
||||
%typemap{std::vector<double>};
|
||||
%typemap{std::vector<double>*};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue