mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-02 12:41:18 -07:00
Ported LayerRegion::make_slices() to XS
This commit is contained in:
parent
948793e570
commit
b69caff93c
11 changed files with 78 additions and 77 deletions
|
|
@ -178,6 +178,14 @@ use overload
|
|||
'@{}' => sub { $_[0]->arrayref },
|
||||
'fallback' => 1;
|
||||
|
||||
sub new {
|
||||
my ($class, @surfaces) = @_;
|
||||
|
||||
my $self = $class->_new;
|
||||
$self->append($_) for @surfaces;
|
||||
return $self;
|
||||
}
|
||||
|
||||
package main;
|
||||
for my $class (qw(
|
||||
Slic3r::Config
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class LayerRegion
|
|||
ExtrusionEntityCollection fills;
|
||||
|
||||
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
|
||||
void merge_slices();
|
||||
|
||||
private:
|
||||
Layer *_layer;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "Layer.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "Surface.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
|
@ -38,6 +40,18 @@ LayerRegion::flow(FlowRole role, bool bridge, double width) const
|
|||
);
|
||||
}
|
||||
|
||||
void
|
||||
LayerRegion::merge_slices()
|
||||
{
|
||||
ExPolygons expp;
|
||||
union_(this->slices, expp);
|
||||
this->slices.surfaces.clear();
|
||||
this->slices.surfaces.reserve(expp.size());
|
||||
|
||||
for (ExPolygons::const_iterator expoly = expp.begin(); expoly != expp.end(); ++expoly)
|
||||
this->slices.surfaces.push_back(Surface(stInternal, *expoly));
|
||||
}
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
REGISTER_CLASS(LayerRegion, "Layer::Region");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,12 +10,17 @@ enum SurfaceType { stTop, stBottom, stBottomBridge, stInternal, stInternalSolid,
|
|||
class Surface
|
||||
{
|
||||
public:
|
||||
ExPolygon expolygon;
|
||||
SurfaceType surface_type;
|
||||
ExPolygon expolygon;
|
||||
double thickness; // in mm
|
||||
unsigned short thickness_layers; // in layers
|
||||
double bridge_angle; // in radians, ccw, 0 = East, only 0+ (negative means undefined)
|
||||
unsigned short extra_perimeters;
|
||||
|
||||
Surface(SurfaceType _surface_type, const ExPolygon &_expolygon)
|
||||
: surface_type(_surface_type), expolygon(_expolygon),
|
||||
thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0)
|
||||
{};
|
||||
double area() const;
|
||||
bool is_solid() const;
|
||||
bool is_external() const;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ is $surface->extra_perimeters, 2, 'extra_perimeters';
|
|||
}
|
||||
|
||||
{
|
||||
my $collection = Slic3r::Surface::Collection->new($surface, $surface->clone);
|
||||
my $collection = Slic3r::Surface::Collection->new;
|
||||
$collection->append($_) for $surface, $surface->clone;
|
||||
is scalar(@$collection), 2, 'collection has the right number of items';
|
||||
is_deeply $collection->[0]->expolygon->pp, [$square, $hole_in_square],
|
||||
'collection returns a correct surface expolygon';
|
||||
|
|
@ -64,12 +65,11 @@ is $surface->extra_perimeters, 2, 'extra_perimeters';
|
|||
}
|
||||
|
||||
{
|
||||
my @surfaces = (
|
||||
my $collection = Slic3r::Surface::Collection->new;
|
||||
$collection->append($_) for
|
||||
Slic3r::Surface->new(expolygon => $expolygon, surface_type => Slic3r::Surface::S_TYPE_BOTTOM),
|
||||
Slic3r::Surface->new(expolygon => $expolygon, surface_type => Slic3r::Surface::S_TYPE_BOTTOM),
|
||||
Slic3r::Surface->new(expolygon => $expolygon, surface_type => Slic3r::Surface::S_TYPE_TOP),
|
||||
);
|
||||
my $collection = Slic3r::Surface::Collection->new(@surfaces);
|
||||
Slic3r::Surface->new(expolygon => $expolygon, surface_type => Slic3r::Surface::S_TYPE_TOP);
|
||||
is scalar(@{$collection->group}), 2, 'group() returns correct number of groups';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
Flow* flow(FlowRole role, bool bridge = false, double width = -1)
|
||||
%code%{ RETVAL = new Flow(THIS->flow(role, bridge, width)); %};
|
||||
void merge_slices();
|
||||
};
|
||||
|
||||
%name{Slic3r::Layer} class Layer {
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ _new(CLASS, expolygon, surface_type, thickness, thickness_layers, bridge_angle,
|
|||
double bridge_angle;
|
||||
unsigned short extra_perimeters;
|
||||
CODE:
|
||||
RETVAL = new Surface ();
|
||||
RETVAL->expolygon = *expolygon;
|
||||
RETVAL->surface_type = surface_type;
|
||||
RETVAL = new Surface (surface_type, *expolygon);
|
||||
RETVAL->thickness = thickness;
|
||||
RETVAL->thickness_layers = thickness_layers;
|
||||
RETVAL->bridge_angle = bridge_angle;
|
||||
|
|
|
|||
|
|
@ -6,27 +6,17 @@
|
|||
%}
|
||||
|
||||
%name{Slic3r::Surface::Collection} class SurfaceCollection {
|
||||
%name{_new} SurfaceCollection();
|
||||
~SurfaceCollection();
|
||||
void clear()
|
||||
%code{% THIS->surfaces.clear(); %};
|
||||
void append(Surface* surface)
|
||||
%code{% THIS->surfaces.push_back(*surface); %};
|
||||
int count()
|
||||
%code{% RETVAL = THIS->surfaces.size(); %};
|
||||
void simplify(double tolerance);
|
||||
%{
|
||||
|
||||
SurfaceCollection*
|
||||
SurfaceCollection::new(...)
|
||||
CODE:
|
||||
RETVAL = new SurfaceCollection;
|
||||
// ST(0) is class name, others are surfaces
|
||||
RETVAL->surfaces.resize(items-1);
|
||||
for (unsigned int i = 1; i < items; i++) {
|
||||
// Note: a COPY of the input is stored
|
||||
RETVAL->surfaces[i-1].from_SV_check(ST(i));
|
||||
}
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
SV*
|
||||
SurfaceCollection::arrayref()
|
||||
CODE:
|
||||
|
|
@ -52,15 +42,6 @@ SurfaceCollection::filter_by_type(surface_type)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
SurfaceCollection::append(...)
|
||||
CODE:
|
||||
for (unsigned int i = 1; i < items; i++) {
|
||||
Surface surface;
|
||||
surface.from_SV_check( ST(i) );
|
||||
THIS->surfaces.push_back(surface);
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceCollection::replace(index, surface)
|
||||
int index
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@
|
|||
%typemap{Ref<MotionPlanner>}{simple};
|
||||
%typemap{Clone<MotionPlanner>}{simple};
|
||||
|
||||
%typemap{Surface*};
|
||||
%typemap{Ref<Surface>}{simple};
|
||||
%typemap{Clone<Surface>}{simple};
|
||||
|
||||
%typemap{PrintState*};
|
||||
%typemap{Ref<PrintState>}{simple};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue