Ported Surface->offset() to XS
This commit is contained in:
parent
a331f4d27a
commit
46e3b3180e
6 changed files with 35 additions and 5 deletions
|
@ -7,11 +7,6 @@ our @ISA = qw(Exporter);
|
|||
our @EXPORT_OK = qw(S_TYPE_TOP S_TYPE_BOTTOM S_TYPE_INTERNAL S_TYPE_INTERNALSOLID S_TYPE_INTERNALBRIDGE S_TYPE_INTERNALVOID);
|
||||
our %EXPORT_TAGS = (types => \@EXPORT_OK);
|
||||
|
||||
sub offset {
|
||||
my $self = shift;
|
||||
return [ map $self->clone(expolygon => $_), @{$self->expolygon->offset_ex(@_)} ];
|
||||
}
|
||||
|
||||
sub p {
|
||||
my $self = shift;
|
||||
return @{$self->polygons};
|
||||
|
|
|
@ -164,6 +164,24 @@ offset(const Slic3r::Polylines &polylines, Slic3r::Polygons &retval, const float
|
|||
delete output;
|
||||
}
|
||||
|
||||
void
|
||||
offset(const Slic3r::Surface &surface, Slic3r::Surfaces &retval, const float delta,
|
||||
double scale, ClipperLib::JoinType joinType, double miterLimit)
|
||||
{
|
||||
// perform offset
|
||||
Slic3r::ExPolygons expp;
|
||||
offset_ex(surface.expolygon, expp, delta, scale, joinType, miterLimit);
|
||||
|
||||
// clone the input surface for each expolygon we got
|
||||
retval.clear();
|
||||
retval.reserve(expp.size());
|
||||
for (ExPolygons::iterator it = expp.begin(); it != expp.end(); ++it) {
|
||||
Surface s = surface; // clone
|
||||
s.expolygon = *it;
|
||||
retval.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
offset_ex(const Slic3r::Polygons &polygons, Slic3r::ExPolygons &retval, const float delta,
|
||||
double scale, ClipperLib::JoinType joinType, double miterLimit)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "clipper.hpp"
|
||||
#include "ExPolygon.hpp"
|
||||
#include "Polygon.hpp"
|
||||
#include "Surface.hpp"
|
||||
|
||||
// import these wherever we're included
|
||||
using ClipperLib::jtMiter;
|
||||
|
@ -47,6 +48,9 @@ void offset(const Slic3r::Polylines &polylines, ClipperLib::Paths &retval, const
|
|||
void offset(const Slic3r::Polylines &polylines, Slic3r::Polygons &retval, const float delta,
|
||||
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtSquare,
|
||||
double miterLimit = 3);
|
||||
void offset(const Slic3r::Surface &surface, Slic3r::Surfaces &retval, const float delta,
|
||||
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtSquare,
|
||||
double miterLimit = 3);
|
||||
|
||||
void offset_ex(const Slic3r::Polygons &polygons, Slic3r::ExPolygons &retval, const float delta,
|
||||
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
|
||||
|
|
|
@ -80,6 +80,17 @@ Surface::polygons()
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Surfaces
|
||||
Surface::offset(delta, scale = CLIPPER_OFFSET_SCALE, joinType = ClipperLib::jtMiter, miterLimit = 3)
|
||||
const float delta
|
||||
double scale
|
||||
ClipperLib::JoinType joinType
|
||||
double miterLimit
|
||||
CODE:
|
||||
offset(*THIS, RETVAL, delta, scale, joinType, miterLimit);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
%}
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ Lines T_ARRAYREF
|
|||
Polygons T_ARRAYREF
|
||||
Polylines T_ARRAYREF
|
||||
ExPolygons T_ARRAYREF
|
||||
Surfaces T_ARRAYREF
|
||||
|
||||
# we return these types whenever we want the items to be returned
|
||||
# by reference and marked ::Ref because they're contained in another
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
%typemap{Polygons};
|
||||
%typemap{Polylines};
|
||||
%typemap{ExPolygons};
|
||||
%typemap{Surfaces};
|
||||
%typemap{Polygons*};
|
||||
%typemap{TriangleMeshPtrs};
|
||||
|
||||
|
|
Loading…
Reference in a new issue