Fix for using clipper library
- it doesn't fix my donut problem - still need to fix degenerate nodes.
This commit is contained in:
parent
33d88b8c27
commit
59b534616f
1 changed files with 22 additions and 42 deletions
|
@ -27,8 +27,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// which clipping lib to use?
|
// which clipping lib to use?
|
||||||
#define CLIP_GPC
|
//#define CLIP_GPC
|
||||||
//#define CLIP_CLIPPER
|
#define CLIP_CLIPPER
|
||||||
|
|
||||||
#ifdef CLIP_GPC
|
#ifdef CLIP_GPC
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -499,8 +499,8 @@ TGPolygon polygon_clip( clip_op poly_op, const TGPolygon& subject, const TGPolyg
|
||||||
Polygons clipper_clip;
|
Polygons clipper_clip;
|
||||||
make_clipper_poly( clip, &clipper_clip );
|
make_clipper_poly( clip, &clipper_clip );
|
||||||
|
|
||||||
//ExPolygons clipper_result;
|
ExPolygons clipper_result;
|
||||||
Polygons clipper_result;
|
//Polygons clipper_result;
|
||||||
|
|
||||||
ClipType op;
|
ClipType op;
|
||||||
if ( poly_op == POLY_DIFF ) {
|
if ( poly_op == POLY_DIFF ) {
|
||||||
|
@ -524,16 +524,16 @@ TGPolygon polygon_clip( clip_op poly_op, const TGPolygon& subject, const TGPolyg
|
||||||
int res_contour = 0;
|
int res_contour = 0;
|
||||||
if (c.Execute(op, clipper_result, pftEvenOdd, pftEvenOdd))
|
if (c.Execute(op, clipper_result, pftEvenOdd, pftEvenOdd))
|
||||||
{
|
{
|
||||||
#if 0 // ExPolygons
|
|
||||||
for (int i=0; i<clipper_result.size(); i++)
|
for (int i=0; i<clipper_result.size(); i++)
|
||||||
{
|
{
|
||||||
struct ExPolygon* pg = &clipper_result[i];
|
struct ExPolygon* pg = &clipper_result[i];
|
||||||
|
IntPoint ip;
|
||||||
|
|
||||||
// Get the boundary contour
|
// Get the boundary contour
|
||||||
for (int j = 0; j < pg->outer.size(); j++)
|
for (int j = 0; j < pg->outer.size(); j++)
|
||||||
{
|
{
|
||||||
p = Point3D( pg->outer[j].X, pg->outer[j].Y, -9999.0 );
|
ip = IntPoint( pg->outer[j].X, pg->outer[j].Y );
|
||||||
result.add_node(res_contour, p);
|
result.add_node(res_contour, MakeTGPoint(ip));
|
||||||
}
|
}
|
||||||
result.set_hole_flag(res_contour, 0);
|
result.set_hole_flag(res_contour, 0);
|
||||||
res_contour++;
|
res_contour++;
|
||||||
|
@ -543,33 +543,13 @@ TGPolygon polygon_clip( clip_op poly_op, const TGPolygon& subject, const TGPolyg
|
||||||
{
|
{
|
||||||
for (int k = 0; k < pg->holes[j].size(); k++)
|
for (int k = 0; k < pg->holes[j].size(); k++)
|
||||||
{
|
{
|
||||||
p = Point3D( pg->holes[j].at(k).X, pg->holes[j].at(k).Y, -9999.0 );
|
ip = IntPoint( pg->holes[j].at(k).X, pg->holes[j].at(k).Y );
|
||||||
result.add_node(res_contour, p);
|
result.add_node(res_contour, MakeTGPoint(ip));
|
||||||
}
|
}
|
||||||
result.set_hole_flag(res_contour, 1);
|
result.set_hole_flag(res_contour, 1);
|
||||||
res_contour++;
|
res_contour++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
for (int i=0; i<clipper_result.size(); i++)
|
|
||||||
{
|
|
||||||
Polygon* pg = &clipper_result[i];
|
|
||||||
IntPoint ip;
|
|
||||||
|
|
||||||
for (int j = 0; j < pg->size(); j++)
|
|
||||||
{
|
|
||||||
ip = IntPoint( pg->at(j).X, pg->at(j).Y );
|
|
||||||
result.add_node(i, MakeTGPoint(ip));
|
|
||||||
}
|
|
||||||
if (i==0)
|
|
||||||
{
|
|
||||||
result.set_hole_flag(i, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.set_hole_flag(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue