mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-20 15:21:21 -06:00
Use Clipper for line clipping
This commit is contained in:
parent
1d6a18071a
commit
3025c77675
20 changed files with 202 additions and 211 deletions
|
@ -8,11 +8,11 @@ void AddOuterPolyNodeToExPolygons(ClipperLib::PolyNode& polynode, Slic3r::ExPoly
|
|||
{
|
||||
size_t cnt = expolygons.size();
|
||||
expolygons.resize(cnt + 1);
|
||||
ClipperPolygon_to_Slic3rPolygon(polynode.Contour, expolygons[cnt].contour);
|
||||
ClipperPath_to_Slic3rMultiPoint(polynode.Contour, expolygons[cnt].contour);
|
||||
expolygons[cnt].holes.resize(polynode.ChildCount());
|
||||
for (int i = 0; i < polynode.ChildCount(); ++i)
|
||||
{
|
||||
ClipperPolygon_to_Slic3rPolygon(polynode.Childs[i]->Contour, expolygons[cnt].holes[i]);
|
||||
ClipperPath_to_Slic3rMultiPoint(polynode.Childs[i]->Contour, expolygons[cnt].holes[i]);
|
||||
//Add outer polygons contained by (nested within) holes ...
|
||||
for (int j = 0; j < polynode.Childs[i]->ChildCount(); ++j)
|
||||
AddOuterPolyNodeToExPolygons(*polynode.Childs[i]->Childs[j], expolygons);
|
||||
|
@ -27,8 +27,9 @@ void PolyTreeToExPolygons(ClipperLib::PolyTree& polytree, Slic3r::ExPolygons& ex
|
|||
}
|
||||
//-----------------------------------------------------------
|
||||
|
||||
template <class T>
|
||||
void
|
||||
ClipperPolygon_to_Slic3rPolygon(const ClipperLib::Path &input, Slic3r::Polygon &output)
|
||||
ClipperPath_to_Slic3rMultiPoint(const ClipperLib::Path &input, T &output)
|
||||
{
|
||||
output.points.clear();
|
||||
for (ClipperLib::Path::const_iterator pit = input.begin(); pit != input.end(); ++pit) {
|
||||
|
@ -36,19 +37,20 @@ ClipperPolygon_to_Slic3rPolygon(const ClipperLib::Path &input, Slic3r::Polygon &
|
|||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
ClipperPolygons_to_Slic3rPolygons(const ClipperLib::Paths &input, Slic3r::Polygons &output)
|
||||
ClipperPaths_to_Slic3rMultiPoints(const ClipperLib::Paths &input, T &output)
|
||||
{
|
||||
output.clear();
|
||||
for (ClipperLib::Paths::const_iterator it = input.begin(); it != input.end(); ++it) {
|
||||
Slic3r::Polygon p;
|
||||
ClipperPolygon_to_Slic3rPolygon(*it, p);
|
||||
typename T::value_type p;
|
||||
ClipperPath_to_Slic3rMultiPoint(*it, p);
|
||||
output.push_back(p);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ClipperPolygons_to_Slic3rExPolygons(const ClipperLib::Paths &input, Slic3r::ExPolygons &output)
|
||||
ClipperPaths_to_Slic3rExPolygons(const ClipperLib::Paths &input, Slic3r::ExPolygons &output)
|
||||
{
|
||||
// init Clipper
|
||||
ClipperLib::Clipper clipper;
|
||||
|
@ -67,7 +69,7 @@ ClipperPolygons_to_Slic3rExPolygons(const ClipperLib::Paths &input, Slic3r::ExPo
|
|||
}
|
||||
|
||||
void
|
||||
Slic3rPolygon_to_ClipperPolygon(const Slic3r::MultiPoint &input, ClipperLib::Path &output)
|
||||
Slic3rMultiPoint_to_ClipperPath(const Slic3r::MultiPoint &input, ClipperLib::Path &output)
|
||||
{
|
||||
output.clear();
|
||||
for (Slic3r::Points::const_iterator pit = input.points.begin(); pit != input.points.end(); ++pit) {
|
||||
|
@ -77,12 +79,12 @@ Slic3rPolygon_to_ClipperPolygon(const Slic3r::MultiPoint &input, ClipperLib::Pat
|
|||
|
||||
template <class T>
|
||||
void
|
||||
Slic3rPolygons_to_ClipperPolygons(const T &input, ClipperLib::Paths &output)
|
||||
Slic3rMultiPoints_to_ClipperPaths(const T &input, ClipperLib::Paths &output)
|
||||
{
|
||||
output.clear();
|
||||
for (typename T::const_iterator it = input.begin(); it != input.end(); ++it) {
|
||||
ClipperLib::Path p;
|
||||
Slic3rPolygon_to_ClipperPolygon(*it, p);
|
||||
Slic3rMultiPoint_to_ClipperPath(*it, p);
|
||||
output.push_back(p);
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +106,7 @@ offset(Slic3r::Polygons &polygons, ClipperLib::Paths &retval, const float delta,
|
|||
{
|
||||
// read input
|
||||
ClipperLib::Paths* input = new ClipperLib::Paths();
|
||||
Slic3rPolygons_to_ClipperPolygons(polygons, *input);
|
||||
Slic3rMultiPoints_to_ClipperPaths(polygons, *input);
|
||||
|
||||
// scale input
|
||||
scaleClipperPolygons(*input, scale);
|
||||
|
@ -126,7 +128,7 @@ offset(Slic3r::Polygons &polygons, Slic3r::Polygons &retval, const float delta,
|
|||
offset(polygons, *output, delta, scale, joinType, miterLimit);
|
||||
|
||||
// convert into ExPolygons
|
||||
ClipperPolygons_to_Slic3rPolygons(*output, retval);
|
||||
ClipperPaths_to_Slic3rMultiPoints(*output, retval);
|
||||
delete output;
|
||||
}
|
||||
|
||||
|
@ -136,7 +138,7 @@ offset(Slic3r::Polylines &polylines, ClipperLib::Paths &retval, const float delt
|
|||
{
|
||||
// read input
|
||||
ClipperLib::Paths* input = new ClipperLib::Paths();
|
||||
Slic3rPolygons_to_ClipperPolygons(polylines, *input);
|
||||
Slic3rMultiPoints_to_ClipperPaths(polylines, *input);
|
||||
|
||||
// scale input
|
||||
scaleClipperPolygons(*input, scale);
|
||||
|
@ -158,7 +160,7 @@ offset(Slic3r::Polylines &polylines, Slic3r::Polygons &retval, const float delta
|
|||
offset(polylines, *output, delta, scale, joinType, miterLimit);
|
||||
|
||||
// convert into ExPolygons
|
||||
ClipperPolygons_to_Slic3rPolygons(*output, retval);
|
||||
ClipperPaths_to_Slic3rMultiPoints(*output, retval);
|
||||
delete output;
|
||||
}
|
||||
|
||||
|
@ -171,7 +173,7 @@ offset_ex(Slic3r::Polygons &polygons, Slic3r::ExPolygons &retval, const float de
|
|||
offset(polygons, *output, delta, scale, joinType, miterLimit);
|
||||
|
||||
// convert into ExPolygons
|
||||
ClipperPolygons_to_Slic3rExPolygons(*output, retval);
|
||||
ClipperPaths_to_Slic3rExPolygons(*output, retval);
|
||||
delete output;
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ offset2(Slic3r::Polygons &polygons, ClipperLib::Paths &retval, const float delta
|
|||
{
|
||||
// read input
|
||||
ClipperLib::Paths* input = new ClipperLib::Paths();
|
||||
Slic3rPolygons_to_ClipperPolygons(polygons, *input);
|
||||
Slic3rMultiPoints_to_ClipperPaths(polygons, *input);
|
||||
|
||||
// scale input
|
||||
scaleClipperPolygons(*input, scale);
|
||||
|
@ -208,7 +210,7 @@ offset2(Slic3r::Polygons &polygons, Slic3r::Polygons &retval, const float delta1
|
|||
offset2(polygons, *output, delta1, delta2, scale, joinType, miterLimit);
|
||||
|
||||
// convert into ExPolygons
|
||||
ClipperPolygons_to_Slic3rPolygons(*output, retval);
|
||||
ClipperPaths_to_Slic3rMultiPoints(*output, retval);
|
||||
delete output;
|
||||
}
|
||||
|
||||
|
@ -221,7 +223,7 @@ offset2_ex(Slic3r::Polygons &polygons, Slic3r::ExPolygons &retval, const float d
|
|||
offset2(polygons, *output, delta1, delta2, scale, joinType, miterLimit);
|
||||
|
||||
// convert into ExPolygons
|
||||
ClipperPolygons_to_Slic3rExPolygons(*output, retval);
|
||||
ClipperPaths_to_Slic3rExPolygons(*output, retval);
|
||||
delete output;
|
||||
}
|
||||
|
||||
|
@ -232,8 +234,8 @@ void _clipper_do(const ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
|||
// read input
|
||||
ClipperLib::Paths* input_subject = new ClipperLib::Paths();
|
||||
ClipperLib::Paths* input_clip = new ClipperLib::Paths();
|
||||
Slic3rPolygons_to_ClipperPolygons(subject, *input_subject);
|
||||
Slic3rPolygons_to_ClipperPolygons(clip, *input_clip);
|
||||
Slic3rMultiPoints_to_ClipperPaths(subject, *input_subject);
|
||||
Slic3rMultiPoints_to_ClipperPaths(clip, *input_clip);
|
||||
|
||||
// perform safety offset
|
||||
if (safety_offset_) {
|
||||
|
@ -258,6 +260,29 @@ void _clipper_do(const ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
|||
clipper.Execute(clipType, retval, fillType, fillType);
|
||||
}
|
||||
|
||||
void _clipper_do(const ClipperLib::ClipType clipType, Slic3r::Polylines &subject,
|
||||
Slic3r::Polygons &clip, ClipperLib::PolyTree &retval, const ClipperLib::PolyFillType fillType)
|
||||
{
|
||||
// read input
|
||||
ClipperLib::Paths* input_subject = new ClipperLib::Paths();
|
||||
ClipperLib::Paths* input_clip = new ClipperLib::Paths();
|
||||
Slic3rMultiPoints_to_ClipperPaths(subject, *input_subject);
|
||||
Slic3rMultiPoints_to_ClipperPaths(clip, *input_clip);
|
||||
|
||||
// init Clipper
|
||||
ClipperLib::Clipper clipper;
|
||||
clipper.Clear();
|
||||
|
||||
// add polygons
|
||||
clipper.AddPaths(*input_subject, ClipperLib::ptSubject, false);
|
||||
delete input_subject;
|
||||
clipper.AddPaths(*input_clip, ClipperLib::ptClip, true);
|
||||
delete input_clip;
|
||||
|
||||
// perform operation
|
||||
clipper.Execute(clipType, retval, fillType, fillType);
|
||||
}
|
||||
|
||||
void _clipper(ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
||||
Slic3r::Polygons &clip, Slic3r::Polygons &retval, bool safety_offset_)
|
||||
{
|
||||
|
@ -266,7 +291,7 @@ void _clipper(ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
|||
_clipper_do<ClipperLib::Paths>(clipType, subject, clip, *output, ClipperLib::pftNonZero, safety_offset_);
|
||||
|
||||
// convert into Polygons
|
||||
ClipperPolygons_to_Slic3rPolygons(*output, retval);
|
||||
ClipperPaths_to_Slic3rMultiPoints(*output, retval);
|
||||
delete output;
|
||||
}
|
||||
|
||||
|
@ -282,6 +307,19 @@ void _clipper(ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
|||
delete polytree;
|
||||
}
|
||||
|
||||
void _clipper(ClipperLib::ClipType clipType, Slic3r::Polylines &subject,
|
||||
Slic3r::Polygons &clip, Slic3r::Polylines &retval)
|
||||
{
|
||||
// perform operation
|
||||
ClipperLib::PolyTree polytree;
|
||||
_clipper_do(clipType, subject, clip, polytree, ClipperLib::pftNonZero);
|
||||
|
||||
// convert into Polygons
|
||||
ClipperLib::Paths output;
|
||||
ClipperLib::PolyTreeToPaths(polytree, output);
|
||||
ClipperPaths_to_Slic3rMultiPoints(output, retval);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void diff(Slic3r::Polygons &subject, Slic3r::Polygons &clip, T &retval, bool safety_offset_)
|
||||
{
|
||||
|
@ -290,6 +328,11 @@ void diff(Slic3r::Polygons &subject, Slic3r::Polygons &clip, T &retval, bool saf
|
|||
template void diff<Slic3r::ExPolygons>(Slic3r::Polygons &subject, Slic3r::Polygons &clip, Slic3r::ExPolygons &retval, bool safety_offset_);
|
||||
template void diff<Slic3r::Polygons>(Slic3r::Polygons &subject, Slic3r::Polygons &clip, Slic3r::Polygons &retval, bool safety_offset_);
|
||||
|
||||
void diff(Slic3r::Polylines &subject, Slic3r::Polygons &clip, Slic3r::Polylines &retval)
|
||||
{
|
||||
_clipper(ClipperLib::ctDifference, subject, clip, retval);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void intersection(Slic3r::Polygons &subject, Slic3r::Polygons &clip, T &retval, bool safety_offset_)
|
||||
{
|
||||
|
@ -298,6 +341,11 @@ void intersection(Slic3r::Polygons &subject, Slic3r::Polygons &clip, T &retval,
|
|||
template void intersection<Slic3r::ExPolygons>(Slic3r::Polygons &subject, Slic3r::Polygons &clip, Slic3r::ExPolygons &retval, bool safety_offset_);
|
||||
template void intersection<Slic3r::Polygons>(Slic3r::Polygons &subject, Slic3r::Polygons &clip, Slic3r::Polygons &retval, bool safety_offset_);
|
||||
|
||||
void intersection(Slic3r::Polylines &subject, Slic3r::Polygons &clip, Slic3r::Polylines &retval)
|
||||
{
|
||||
_clipper(ClipperLib::ctIntersection, subject, clip, retval);
|
||||
}
|
||||
|
||||
void xor_ex(Slic3r::Polygons &subject, Slic3r::Polygons &clip, Slic3r::ExPolygons &retval,
|
||||
bool safety_offset_)
|
||||
{
|
||||
|
@ -323,14 +371,14 @@ void simplify_polygons(Slic3r::Polygons &subject, Slic3r::Polygons &retval)
|
|||
{
|
||||
// convert into Clipper polygons
|
||||
ClipperLib::Paths* input_subject = new ClipperLib::Paths();
|
||||
Slic3rPolygons_to_ClipperPolygons(subject, *input_subject);
|
||||
Slic3rMultiPoints_to_ClipperPaths(subject, *input_subject);
|
||||
|
||||
ClipperLib::Paths* output = new ClipperLib::Paths();
|
||||
ClipperLib::SimplifyPolygons(*input_subject, *output, ClipperLib::pftNonZero);
|
||||
delete input_subject;
|
||||
|
||||
// convert into Slic3r polygons
|
||||
ClipperPolygons_to_Slic3rPolygons(*output, retval);
|
||||
ClipperPaths_to_Slic3rMultiPoints(*output, retval);
|
||||
delete output;
|
||||
}
|
||||
|
||||
|
@ -371,7 +419,7 @@ polynode2perl(const ClipperLib::PolyNode& node)
|
|||
{
|
||||
HV* hv = newHV();
|
||||
Slic3r::Polygon p;
|
||||
ClipperPolygon_to_Slic3rPolygon(node.Contour, p);
|
||||
ClipperPath_to_Slic3rMultiPoint(node.Contour, p);
|
||||
if (node.IsHole()) {
|
||||
(void)hv_stores( hv, "hole", p.to_SV_clone_ref() );
|
||||
} else {
|
||||
|
|
|
@ -21,12 +21,14 @@ void AddOuterPolyNodeToExPolygons(ClipperLib::PolyNode& polynode, Slic3r::ExPoly
|
|||
void PolyTreeToExPolygons(ClipperLib::PolyTree& polytree, Slic3r::ExPolygons& expolygons);
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void Slic3rPolygon_to_ClipperPolygon(const Slic3r::MultiPoint &input, ClipperLib::Path &output);
|
||||
void Slic3rMultiPoint_to_ClipperPath(const Slic3r::MultiPoint &input, ClipperLib::Path &output);
|
||||
template <class T>
|
||||
void Slic3rPolygons_to_ClipperPolygons(const T &input, ClipperLib::Paths &output);
|
||||
void ClipperPolygon_to_Slic3rPolygon(const ClipperLib::Path &input, Slic3r::Polygon &output);
|
||||
void ClipperPolygons_to_Slic3rPolygons(const ClipperLib::Paths &input, Slic3r::Polygons &output);
|
||||
void ClipperPolygons_to_Slic3rExPolygons(const ClipperLib::Paths &input, Slic3r::ExPolygons &output);
|
||||
void Slic3rMultiPoints_to_ClipperPaths(const T &input, ClipperLib::Paths &output);
|
||||
template <class T>
|
||||
void ClipperPath_to_Slic3rMultiPoint(const ClipperLib::Path &input, T &output);
|
||||
template <class T>
|
||||
void ClipperPaths_to_Slic3rMultiPoints(const ClipperLib::Paths &input, T &output);
|
||||
void ClipperPaths_to_Slic3rExPolygons(const ClipperLib::Paths &input, Slic3r::ExPolygons &output);
|
||||
|
||||
void scaleClipperPolygons(ClipperLib::Paths &polygons, const double scale);
|
||||
|
||||
|
@ -63,17 +65,25 @@ void offset2_ex(Slic3r::Polygons &polygons, Slic3r::ExPolygons &retval, const fl
|
|||
template <class T>
|
||||
void _clipper_do(ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
||||
Slic3r::Polygons &clip, T &retval, bool safety_offset_);
|
||||
void _clipper_do(ClipperLib::ClipType clipType, Slic3r::Polylines &subject,
|
||||
Slic3r::Polygons &clip, ClipperLib::Paths &retval);
|
||||
void _clipper(ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
||||
Slic3r::Polygons &clip, Slic3r::Polygons &retval, bool safety_offset_);
|
||||
void _clipper(ClipperLib::ClipType clipType, Slic3r::Polygons &subject,
|
||||
Slic3r::Polygons &clip, Slic3r::ExPolygons &retval, bool safety_offset_);
|
||||
void _clipper(ClipperLib::ClipType clipType, Slic3r::Polylines &subject,
|
||||
Slic3r::Polygons &clip, Slic3r::Polylines &retval);
|
||||
|
||||
template <class T>
|
||||
void diff(Slic3r::Polygons &subject, Slic3r::Polygons &clip, T &retval, bool safety_offset_);
|
||||
|
||||
void diff(Slic3r::Polylines &subject, Slic3r::Polygons &clip, Slic3r::Polylines &retval);
|
||||
|
||||
template <class T>
|
||||
void intersection(Slic3r::Polygons &subject, Slic3r::Polygons &clip, T &retval, bool safety_offset_);
|
||||
|
||||
void intersection(Slic3r::Polylines &subject, Slic3r::Polygons &clip, Slic3r::Polylines &retval);
|
||||
|
||||
void xor_ex(Slic3r::Polygons &subject, Slic3r::Polygons &clip, Slic3r::ExPolygons &retval,
|
||||
bool safety_offset_ = false);
|
||||
|
||||
|
|
|
@ -66,18 +66,16 @@ double
|
|||
Polygon::area() const
|
||||
{
|
||||
ClipperLib::Path p;
|
||||
Slic3rPolygon_to_ClipperPolygon(*this, p);
|
||||
Slic3rMultiPoint_to_ClipperPath(*this, p);
|
||||
return ClipperLib::Area(p);
|
||||
}
|
||||
|
||||
bool
|
||||
Polygon::is_counter_clockwise() const
|
||||
{
|
||||
ClipperLib::Path* p = new ClipperLib::Path();
|
||||
Slic3rPolygon_to_ClipperPolygon(*this, *p);
|
||||
bool orientation = ClipperLib::Orientation(*p);
|
||||
delete p;
|
||||
return orientation;
|
||||
ClipperLib::Path p;
|
||||
Slic3rMultiPoint_to_ClipperPath(*this, p);
|
||||
return ClipperLib::Orientation(p);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -41,4 +41,15 @@ PolylineCollection::chained_path_from(const Point* start_near, bool no_reverse)
|
|||
return retval;
|
||||
}
|
||||
|
||||
Point*
|
||||
PolylineCollection::leftmost_point() const
|
||||
{
|
||||
const Point* p = NULL;
|
||||
for (Polylines::const_iterator it = this->polylines.begin(); it != this->polylines.end(); ++it) {
|
||||
if (p == NULL || it->points.front().x < p->x)
|
||||
p = &(it->points.front());
|
||||
}
|
||||
return new Point (*p);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ class PolylineCollection
|
|||
Polylines polylines;
|
||||
PolylineCollection* chained_path(bool no_reverse) const;
|
||||
PolylineCollection* chained_path_from(const Point* start_near, bool no_reverse) const;
|
||||
Point* leftmost_point() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
//#define use_xyz
|
||||
|
||||
//use_lines: Enables line clipping. Adds a very minor cost to performance.
|
||||
//#define use_lines
|
||||
#define use_lines
|
||||
|
||||
//When enabled, code developed with earlier versions of Clipper
|
||||
//(ie prior to ver 6) should compile without changes.
|
||||
|
|
|
@ -4,7 +4,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 11;
|
||||
|
||||
my $square = [ # ccw
|
||||
[200, 100],
|
||||
|
@ -88,4 +88,22 @@ my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square);
|
|||
is $result->[0]->area, $expolygon->area, 'diff_ex';
|
||||
}
|
||||
|
||||
{
|
||||
my $polyline = Slic3r::Polyline->new([50,150], [300,150]);
|
||||
{
|
||||
my $result = Slic3r::Geometry::Clipper::intersection_pl([$polyline], [$square, $hole_in_square]);
|
||||
is scalar(@$result), 2, 'intersection_pl - correct number of result lines';
|
||||
# results are in no particular order
|
||||
is scalar(grep $_->length == 40, @$result), 2, 'intersection_pl - result lines have correct length';
|
||||
}
|
||||
{
|
||||
my $result = Slic3r::Geometry::Clipper::diff_pl([$polyline], [$square, $hole_in_square]);
|
||||
is scalar(@$result), 3, 'diff_pl - correct number of result lines';
|
||||
# results are in no particular order
|
||||
is scalar(grep $_->length == 50, @$result), 1, 'diff_pl - the left result line has correct length';
|
||||
is scalar(grep $_->length == 100, @$result), 1, 'diff_pl - two right result line has correct length';
|
||||
is scalar(grep $_->length == 20, @$result), 1, 'diff_pl - the central result line has correct length';
|
||||
}
|
||||
}
|
||||
|
||||
__END__
|
||||
|
|
|
@ -91,6 +91,15 @@ diff_ex(subject, clip, safety_offset = false)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Polylines
|
||||
diff_pl(subject, clip)
|
||||
Polylines subject
|
||||
Polygons clip
|
||||
CODE:
|
||||
diff(subject, clip, RETVAL);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Polygons
|
||||
intersection(subject, clip, safety_offset = false)
|
||||
Polygons subject
|
||||
|
@ -111,6 +120,15 @@ intersection_ex(subject, clip, safety_offset = false)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Polylines
|
||||
intersection_pl(subject, clip)
|
||||
Polylines subject
|
||||
Polygons clip
|
||||
CODE:
|
||||
intersection(subject, clip, RETVAL);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
ExPolygons
|
||||
xor_ex(subject, clip, safety_offset = false)
|
||||
Polygons subject
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->midpoint(); %};
|
||||
Point* point_at(double distance)
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->point_at(distance); %};
|
||||
Polyline* as_polyline()
|
||||
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(); RETVAL->points.push_back(THIS->a); RETVAL->points.push_back(THIS->b); %};
|
||||
%{
|
||||
|
||||
Line*
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
%code{% const char* CLASS = "Slic3r::Polyline::Collection"; RETVAL = THIS->chained_path_from(start_near, no_reverse); %};
|
||||
int count()
|
||||
%code{% RETVAL = THIS->polylines.size(); %};
|
||||
Point* leftmost_point()
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->leftmost_point(); %};
|
||||
%{
|
||||
|
||||
PolylineCollection*
|
||||
|
|
|
@ -22,6 +22,7 @@ ClipperLib::PolyFillType T_UV
|
|||
Points T_ARRAYREF
|
||||
Lines T_ARRAYREF
|
||||
Polygons T_ARRAYREF
|
||||
Polylines T_ARRAYREF
|
||||
ExPolygons T_ARRAYREF
|
||||
|
||||
# we return these types whenever we want the items to be returned
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
%typemap{Points};
|
||||
%typemap{Lines};
|
||||
%typemap{Polygons};
|
||||
%typemap{Polylines};
|
||||
%typemap{ExPolygons};
|
||||
%typemap{Polygons*};
|
||||
%typemap{TriangleMeshPtrs};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue