2013-08-12 03:50:46 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
c_clipper.cpp
|
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2013-08-12 03:50:46 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __C_CLIPPER_CPP
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
#include "gb.geom.h"
|
|
|
|
#include "c_clipper.h"
|
|
|
|
|
2018-02-22 04:30:25 +01:00
|
|
|
#define SCALE 1048576.0
|
2013-08-12 03:50:46 +02:00
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
static IntPoint to_point_xy(double x, double y)
|
|
|
|
{
|
|
|
|
return IntPoint(x * SCALE + 0.5, y * SCALE + 0.5);
|
|
|
|
}
|
|
|
|
|
2013-08-12 03:50:46 +02:00
|
|
|
static IntPoint to_point(GEOM_POINTF *point)
|
|
|
|
{
|
2013-08-18 02:47:21 +02:00
|
|
|
return to_point_xy(point->x, point->y);
|
2013-08-12 03:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static GEOM_POINTF *from_point(IntPoint p)
|
|
|
|
{
|
|
|
|
return GEOM.CreatePointF((double)p.X / SCALE, (double)p.Y / SCALE);
|
|
|
|
}
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
static bool is_polygon_closed(Path &p)
|
2013-08-18 02:47:21 +02:00
|
|
|
{
|
|
|
|
int n = p.size() - 1;
|
|
|
|
|
|
|
|
if (n <= 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return p[0].X == p[n].X && p[0].Y == p[n].Y;
|
|
|
|
}
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
static void set_polygon_closed(Path &p, bool closed)
|
2013-08-18 02:47:21 +02:00
|
|
|
{
|
|
|
|
if (is_polygon_closed(p) == closed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (closed)
|
|
|
|
p.push_back(p[0]);
|
|
|
|
else
|
|
|
|
p.erase(p.begin() + p.size() - 1);
|
|
|
|
}
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
static bool to_polygons(Paths &polygons, GB_ARRAY array)
|
2013-08-12 03:50:46 +02:00
|
|
|
{
|
|
|
|
int count;
|
2013-08-14 00:28:41 +02:00
|
|
|
CPOLYGON *p;
|
|
|
|
int i;
|
2013-08-12 03:50:46 +02:00
|
|
|
|
|
|
|
if (GB.CheckObject(array))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
count = GB.Array.Count(array);
|
|
|
|
if (count == 0)
|
|
|
|
return false;
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
polygons.clear();
|
2013-08-12 03:50:46 +02:00
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
2013-08-14 00:28:41 +02:00
|
|
|
p = *(CPOLYGON **)GB.Array.Get(array, i);
|
|
|
|
if (!p)
|
2013-08-12 03:50:46 +02:00
|
|
|
continue;
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
polygons.push_back(*(p->poly));
|
2013-08-12 03:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
static GB_ARRAY from_polygons(Paths &polygons, bool closed)
|
2013-08-12 03:50:46 +02:00
|
|
|
{
|
|
|
|
GB_ARRAY a;
|
2013-08-14 00:28:41 +02:00
|
|
|
CPOLYGON *p;
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
GB.Array.New(&a, GB.FindClass("Polygon"), polygons.size());
|
2013-08-12 03:50:46 +02:00
|
|
|
|
|
|
|
for (i = 0; i < polygons.size(); i++)
|
|
|
|
{
|
2013-08-14 00:28:41 +02:00
|
|
|
if (polygons[i].size() == 0)
|
2013-08-13 14:18:32 +02:00
|
|
|
continue;
|
|
|
|
|
2013-08-18 18:17:30 +02:00
|
|
|
set_polygon_closed(polygons[i], closed);
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
p = (CPOLYGON *)GB.New(GB.FindClass("Polygon"), NULL, NULL);
|
|
|
|
*(p->poly) = polygons[i];
|
2013-08-12 03:50:46 +02:00
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
*(GB_ARRAY *)GB.Array.Get(a, i) = p;
|
|
|
|
GB.Ref(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define THIS ((CPOLYGON *)_object)
|
|
|
|
#define POLY THIS->poly
|
|
|
|
|
|
|
|
static bool _convert_polygon(CPOLYGON *_object, GB_TYPE type, GB_VALUE *conv)
|
|
|
|
{
|
|
|
|
if (type != GB.FindClass("PointF[]"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (THIS)
|
|
|
|
{
|
|
|
|
// Polygon --> PointF[]
|
|
|
|
GB_ARRAY a;
|
|
|
|
int i;
|
|
|
|
GEOM_POINTF **data;
|
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
GB.Array.New(&a, GB.FindClass("PointF"), POLY->size()); // + THIS->closed);
|
2013-08-14 00:28:41 +02:00
|
|
|
data = (GEOM_POINTF **)GB.Array.Get(a, 0);
|
|
|
|
for(i = 0; i < (int)POLY->size(); i++)
|
2013-08-12 03:50:46 +02:00
|
|
|
{
|
2013-08-14 00:28:41 +02:00
|
|
|
data[i] = from_point((*POLY)[i]);
|
|
|
|
GB.Ref(data[i]);
|
2013-08-12 03:50:46 +02:00
|
|
|
}
|
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
/*if (closed)
|
|
|
|
{
|
|
|
|
data[i] = from_point((*POLY)[0]);
|
|
|
|
GB.Ref(data[i]);
|
|
|
|
}*/
|
2013-08-12 03:50:46 +02:00
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
conv->_object.value = a;
|
|
|
|
return false;
|
2013-08-12 03:50:46 +02:00
|
|
|
}
|
2013-08-14 00:28:41 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// PointF[] --> Polygon
|
|
|
|
CPOLYGON *p;
|
|
|
|
GB_ARRAY a = (GB_ARRAY)conv->_object.value;
|
|
|
|
int size = GB.Array.Count(a);
|
|
|
|
int i;
|
|
|
|
GEOM_POINTF **points;
|
2013-08-12 03:50:46 +02:00
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
p = (CPOLYGON *)GB.New(GB.FindClass("Polygon"), NULL, NULL);
|
|
|
|
|
|
|
|
points = (GEOM_POINTF **)GB.Array.Get(a, 0);
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
if (!points[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
p->poly->push_back(to_point(points[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
conv->_object.value = p;
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-12 03:50:46 +02:00
|
|
|
}
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
BEGIN_METHOD(Polygon_new, GB_INTEGER size)
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
POLY = new Path;
|
2013-08-14 00:28:41 +02:00
|
|
|
|
|
|
|
if (!MISSING(size))
|
|
|
|
POLY->resize(VARG(size));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD_VOID(Polygon_free)
|
|
|
|
|
|
|
|
delete POLY;
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Polygon_get, GB_INTEGER index)
|
|
|
|
|
|
|
|
int index = VARG(index);
|
|
|
|
|
|
|
|
if (index < 0 || index >= (int)POLY->size())
|
|
|
|
{
|
|
|
|
GB.Error(GB_ERR_BOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GB.ReturnObject(from_point((*POLY)[index]));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Polygon_put, GB_OBJECT point; GB_INTEGER index)
|
|
|
|
|
|
|
|
int index = VARG(index);
|
|
|
|
GEOM_POINTF *point = (GEOM_POINTF *)VARG(point);
|
|
|
|
|
|
|
|
if (GB.CheckObject(point))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (index < 0 || index >= (int)POLY->size())
|
|
|
|
{
|
|
|
|
GB.Error(GB_ERR_BOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*POLY)[index] = to_point(point);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(Polygon_Count)
|
|
|
|
|
|
|
|
GB.ReturnInteger(POLY->size());
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(Polygon_Max)
|
|
|
|
|
|
|
|
GB.ReturnInteger(POLY->size() - 1);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(Polygon_Area)
|
|
|
|
|
|
|
|
GB.ReturnFloat(Area(*POLY) / SCALE / SCALE);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_METHOD_VOID(Polygon_Reverse)
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
ReversePath(*POLY);
|
2013-08-14 00:28:41 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Polygon_Simplify, GB_INTEGER fill)
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
Paths result;
|
2013-08-14 00:28:41 +02:00
|
|
|
|
|
|
|
SimplifyPolygon(*POLY, result, (PolyFillType)VARGOPT(fill, pftNonZero));
|
|
|
|
|
2013-08-18 18:17:30 +02:00
|
|
|
GB.ReturnObject(from_polygons(result, is_polygon_closed(*POLY)));
|
2013-08-14 00:28:41 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Polygon_Clean, GB_FLOAT distance)
|
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
bool closed;
|
2013-08-14 00:28:41 +02:00
|
|
|
CPOLYGON *result = (CPOLYGON *)GB.New(GB.FindClass("Polygon"), NULL, 0);
|
|
|
|
|
|
|
|
result->poly->resize(POLY->size());
|
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
closed = is_polygon_closed(*POLY);
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
CleanPolygon(*POLY, *(result->poly), VARGOPT(distance, 1.415));
|
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
set_polygon_closed(*(result->poly), closed);
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
GB.ReturnObject(result);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
BEGIN_METHOD(Polygon_Add, GB_FLOAT x; GB_FLOAT y)
|
|
|
|
|
|
|
|
POLY->push_back(to_point_xy(VARG(x), VARG(y)));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Polygon_AddPoint, GB_OBJECT point)
|
|
|
|
|
|
|
|
GEOM_POINTF *point = (GEOM_POINTF *)VARG(point);
|
|
|
|
|
|
|
|
if (GB.CheckObject(point))
|
|
|
|
return;
|
|
|
|
|
|
|
|
POLY->push_back(to_point(point));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Polygon_Remove, GB_INTEGER index; GB_INTEGER count)
|
|
|
|
|
|
|
|
int index = VARG(index);
|
|
|
|
int count = VARGOPT(count, 1);
|
|
|
|
int index2;
|
|
|
|
|
|
|
|
if (index < 0 || index >= (int)POLY->size())
|
|
|
|
{
|
|
|
|
GB.Error(GB_ERR_BOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count < 0)
|
|
|
|
count = (int)POLY->size() - index;
|
|
|
|
|
|
|
|
index2 = index + count;
|
|
|
|
|
|
|
|
if (index2 > (int)POLY->size())
|
|
|
|
index2 = POLY->size();
|
|
|
|
|
|
|
|
if (count == 1)
|
|
|
|
POLY->erase(POLY->begin() + index);
|
|
|
|
else
|
|
|
|
POLY->erase(POLY->begin() + index, POLY->begin() + index2);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2013-08-18 18:17:30 +02:00
|
|
|
BEGIN_PROPERTY(Polygon_Orientation)
|
|
|
|
|
|
|
|
GB.ReturnBoolean(Orientation(*POLY));
|
|
|
|
|
|
|
|
END_PROPERTY
|
2013-08-18 02:47:21 +02:00
|
|
|
|
2013-08-13 14:18:32 +02:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BEGIN_METHOD(Clipper_Offset, GB_OBJECT polygons; GB_FLOAT delta; GB_INTEGER join; GB_FLOAT limit; GB_BOOLEAN do_not_fix)
|
2013-08-12 03:50:46 +02:00
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
Paths polygons;
|
|
|
|
Paths result;
|
2013-08-12 03:50:46 +02:00
|
|
|
|
|
|
|
if (to_polygons(polygons, VARG(polygons)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
SimplifyPolygons(polygons, result, pftNonZero);
|
|
|
|
polygons = result;
|
2014-09-04 17:55:50 +02:00
|
|
|
|
|
|
|
ClipperOffset co;
|
|
|
|
co.AddPaths(polygons, (JoinType)VARGOPT(join, jtSquare), etClosedPolygon);
|
|
|
|
co.MiterLimit = VARGOPT(limit, 0.0);
|
|
|
|
co.Execute(result, VARG(delta) * SCALE);
|
|
|
|
|
|
|
|
//OffsetPaths(polygons, result, VARG(delta) * SCALE, (JoinType)VARGOPT(join, jtSquare), VARGOPT(limit, 0.0), !VARGOPT(do_not_fix, false));
|
2013-08-12 03:50:46 +02:00
|
|
|
|
2013-08-18 18:17:30 +02:00
|
|
|
GB.ReturnObject(from_polygons(result, true));
|
2013-08-12 03:50:46 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2013-08-13 14:18:32 +02:00
|
|
|
|
|
|
|
BEGIN_METHOD(Clipper_Simplify, GB_OBJECT polygons; GB_INTEGER fill)
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
Paths polygons;
|
|
|
|
Paths result;
|
2013-08-13 14:18:32 +02:00
|
|
|
|
|
|
|
if (to_polygons(polygons, VARG(polygons)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
SimplifyPolygons(polygons, result, (PolyFillType)VARGOPT(fill, pftNonZero));
|
|
|
|
|
2013-08-18 18:17:30 +02:00
|
|
|
GB.ReturnObject(from_polygons(result, true));
|
2013-08-13 14:18:32 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Clipper_Clean, GB_OBJECT polygons; GB_FLOAT distance)
|
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
Paths polygons;
|
|
|
|
Paths result;
|
2013-08-13 14:18:32 +02:00
|
|
|
|
|
|
|
if (to_polygons(polygons, VARG(polygons)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
result.resize(polygons.size());
|
|
|
|
|
|
|
|
CleanPolygons(polygons, result, VARGOPT(distance, 1.415));
|
|
|
|
|
2013-08-18 18:17:30 +02:00
|
|
|
GB.ReturnObject(from_polygons(result, true));
|
2013-08-14 00:28:41 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2013-08-14 01:41:50 +02:00
|
|
|
static void execute(ClipType action, PolyFillType fill, void *subject, void *clip)
|
|
|
|
{
|
2013-08-14 00:28:41 +02:00
|
|
|
Clipper c;
|
2014-09-04 17:55:50 +02:00
|
|
|
Paths psubject, pclip, result;
|
|
|
|
PolyTree tree;
|
2013-08-14 00:28:41 +02:00
|
|
|
|
2013-08-14 01:41:50 +02:00
|
|
|
if (to_polygons(psubject, subject))
|
2013-08-14 00:28:41 +02:00
|
|
|
return;
|
|
|
|
|
2013-08-14 01:41:50 +02:00
|
|
|
if (clip && to_polygons(pclip, clip))
|
|
|
|
return;
|
2013-08-14 00:28:41 +02:00
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
c.AddPaths(psubject, ptSubject, true);
|
2013-10-19 04:53:17 +02:00
|
|
|
if (clip)
|
2014-09-04 17:55:50 +02:00
|
|
|
c.AddPaths(pclip, ptClip, true);
|
2013-08-14 01:41:50 +02:00
|
|
|
|
2014-09-04 17:55:50 +02:00
|
|
|
c.StrictlySimple(true);
|
|
|
|
c.Execute(action, tree, fill, fill);
|
|
|
|
ClosedPathsFromPolyTree(tree, result);
|
2013-08-14 00:28:41 +02:00
|
|
|
|
2013-08-18 18:17:30 +02:00
|
|
|
GB.ReturnObject(from_polygons(result, true));
|
2013-08-14 01:41:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN_METHOD(Clipper_Union, GB_OBJECT subject; GB_OBJECT clip; GB_INTEGER fill)
|
|
|
|
|
|
|
|
execute(ctUnion, (PolyFillType)VARGOPT(fill, pftNonZero), VARG(subject), VARGOPT(clip, NULL));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Clipper_Intersection, GB_OBJECT subject; GB_OBJECT clip; GB_INTEGER fill)
|
|
|
|
|
|
|
|
execute(ctIntersection, (PolyFillType)VARGOPT(fill, pftNonZero), VARG(subject), VARGOPT(clip, NULL));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Clipper_Difference, GB_OBJECT subject; GB_OBJECT clip; GB_INTEGER fill)
|
|
|
|
|
|
|
|
execute(ctDifference, (PolyFillType)VARGOPT(fill, pftNonZero), VARG(subject), VARGOPT(clip, NULL));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Clipper_ExclusiveOr, GB_OBJECT subject; GB_OBJECT clip; GB_INTEGER fill)
|
|
|
|
|
|
|
|
execute(ctXor, (PolyFillType)VARGOPT(fill, pftNonZero), VARG(subject), VARGOPT(clip, NULL));
|
2013-08-13 14:18:32 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
GB_DESC PolygonDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE("Polygon", sizeof(CPOLYGON)),
|
|
|
|
|
|
|
|
GB_METHOD("_new", NULL, Polygon_new, "[(Size)i]"),
|
|
|
|
GB_METHOD("_free", NULL, Polygon_free, NULL),
|
|
|
|
|
|
|
|
GB_METHOD("_get", "PointF", Polygon_get, "(Index)i"),
|
2015-06-18 11:59:26 +02:00
|
|
|
GB_METHOD("_put", NULL, Polygon_put, "(Point)PointF;(Index)i"),
|
2013-08-14 00:28:41 +02:00
|
|
|
|
|
|
|
GB_PROPERTY_READ("Count", "i", Polygon_Count),
|
|
|
|
GB_PROPERTY_READ("Max", "i", Polygon_Max),
|
|
|
|
GB_PROPERTY_READ("Area", "f", Polygon_Area),
|
2013-08-18 18:17:30 +02:00
|
|
|
GB_PROPERTY_READ("Orientation", "b", Polygon_Orientation),
|
2013-08-14 00:28:41 +02:00
|
|
|
|
|
|
|
GB_METHOD("Reverse", NULL, Polygon_Reverse, NULL),
|
|
|
|
GB_METHOD("Simplify", "Polygon[]", Polygon_Simplify, "[(Fill)i]"),
|
|
|
|
GB_METHOD("Clean", "Polygon", Polygon_Clean, "[(Distance)f]"),
|
|
|
|
|
2013-08-18 02:47:21 +02:00
|
|
|
GB_METHOD("Add", NULL, Polygon_Add, "(X)f(Y)f"),
|
2015-06-19 01:53:23 +02:00
|
|
|
GB_METHOD("AddPoint", NULL, Polygon_AddPoint, "(Point)PointF;"),
|
2013-10-19 04:53:17 +02:00
|
|
|
GB_METHOD("Remove", NULL, Polygon_Remove, "(Index)i[(Count)i]"),
|
2013-08-18 02:47:21 +02:00
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
GB_INTERFACE("_convert", &_convert_polygon),
|
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
2013-08-12 03:50:46 +02:00
|
|
|
GB_DESC ClipperDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE_VIRTUAL("Clipper"),
|
|
|
|
|
|
|
|
GB_CONSTANT("JoinMiter", "i", jtMiter),
|
|
|
|
GB_CONSTANT("JoinSquare", "i", jtSquare),
|
|
|
|
GB_CONSTANT("JoinRound", "i", jtRound),
|
|
|
|
|
2013-08-13 14:18:32 +02:00
|
|
|
GB_CONSTANT("FillEvenOdd", "i", pftEvenOdd),
|
|
|
|
GB_CONSTANT("FillWinding", "i", pftNonZero),
|
|
|
|
GB_CONSTANT("FillNonZero", "i", pftNonZero),
|
|
|
|
GB_CONSTANT("FillPositive", "i", pftPositive),
|
|
|
|
GB_CONSTANT("FillNegative", "i", pftNegative),
|
|
|
|
|
2013-08-14 00:28:41 +02:00
|
|
|
GB_STATIC_METHOD("Offset", "Polygon[]", Clipper_Offset, "(Polygons)Polygon[];(Delta)f[(Join)i(Limit)f(DoNotFix)b]"),
|
|
|
|
GB_STATIC_METHOD("Simplify", "Polygon[]", Clipper_Simplify, "(Polygons)Polygon[];[(Fill)i]"),
|
|
|
|
GB_STATIC_METHOD("Clean", "Polygon[]", Clipper_Clean, "(Polygons)Polygon[];[(Distance)f]"),
|
|
|
|
|
2013-10-19 04:53:17 +02:00
|
|
|
GB_STATIC_METHOD("Union", "Polygon[]", Clipper_Union, "(Polygons)Polygon[];[(Clip)Polygon[];(Fill)i]"),
|
|
|
|
GB_STATIC_METHOD("Intersection", "Polygon[]", Clipper_Intersection, "(Polygons)Polygon[];[(Clip)Polygon[];(Fill)i]"),
|
|
|
|
GB_STATIC_METHOD("Difference", "Polygon[]", Clipper_Difference, "(Polygons)Polygon[];[(Clip)Polygon[];(Fill)i]"),
|
|
|
|
GB_STATIC_METHOD("ExclusiveOr", "Polygon[]", Clipper_ExclusiveOr, "(Polygons)Polygon[];[(Clip)Polygon[];(Fill)i]"),
|
2013-08-12 03:50:46 +02:00
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
|
|
|
|