diff --git a/src/Lib/Polygon/polygon.cxx b/src/Lib/Polygon/polygon.cxx index 8b97fc2e..bf5c15bb 100644 --- a/src/Lib/Polygon/polygon.cxx +++ b/src/Lib/Polygon/polygon.cxx @@ -690,10 +690,11 @@ TGPolygon tgPolygonDiff( const TGPolygon& subject, const TGPolygon& clip ) { return polygon_clip( POLY_DIFF, subject, clip ); } +#if CLIP_NATIVE TGPolygon tgPolygonDiff( const TGPolygon& subject, const ClipPolyType& clip ) { return polygon_clip( POLY_DIFF, subject, clip ); } - +#endif // Intersection TGPolygon tgPolygonInt( const TGPolygon& subject, const TGPolygon& clip ) { @@ -712,10 +713,11 @@ TGPolygon tgPolygonUnion( const TGPolygon& subject, const TGPolygon& clip ) { return polygon_clip( POLY_UNION, subject, clip ); } +#if CLIP_NATIVE ClipPolyType tgPolygonUnion( const TGPolygon& subject, const ClipPolyType& clip ) { return polygon_clip_keep_native_fmt( POLY_UNION, subject, clip ); } - +#endif // canonify the polygon winding, outer contour must be anti-clockwise, // all inner contours must be clockwise. diff --git a/src/Lib/Polygon/polygon.hxx b/src/Lib/Polygon/polygon.hxx index 6a2fb9bc..26319977 100644 --- a/src/Lib/Polygon/polygon.hxx +++ b/src/Lib/Polygon/polygon.hxx @@ -29,25 +29,41 @@ # error This library requires C++ #endif -// which clipping lib to use? +/* which clipping lib to use? Looks like we should go with clipper + * It appears to be both faster and generates better accuracy + */ + //#define CLIP_GPC #define CLIP_CLIPPER +/* Set to 1 to allow keeping accum poly in native clipping lib format + * Although it seems to work on some airports, EHAM is pretty broken + * when turned on + */ + +#define CLIP_NATIVE 0 + #ifdef CLIP_GPC extern "C" { #include } +#if CLIP_NATIVE // optimization apparently causing errors typedef gpc_polygon ClipPolyType; #endif +#endif /* CLIP_GPC */ + #ifdef CLIP_CLIPPER #include "clipper.hpp" using namespace ClipperLib; +#if CLIP_NATIVE // optimization apparently causing errors typedef Polygons ClipPolyType; #endif +#endif /* CLIP_CLIPPER */ + #include #include #include @@ -203,6 +219,10 @@ public: }; +#if !CLIP_NATIVE +typedef TGPolygon ClipPolyType; +#endif + typedef std::vector < TGPolygon > poly_list; typedef poly_list::iterator poly_list_iterator; typedef poly_list::const_iterator const_poly_list_iterator; @@ -237,7 +257,10 @@ TGPolygon tgPolygon2tristrip( const TGPolygon& poly ); // Difference TGPolygon tgPolygonDiff( const TGPolygon& subject, const TGPolygon& clip ); + +#if CLIP_NATIVE TGPolygon tgPolygonDiff( const TGPolygon& subject, const ClipPolyType& clip ); +#endif // Intersection TGPolygon tgPolygonInt( const TGPolygon& subject, const TGPolygon& clip ); @@ -247,7 +270,10 @@ TGPolygon tgPolygonXor( const TGPolygon& subject, const TGPolygon& clip ); // Union TGPolygon tgPolygonUnion( const TGPolygon& subject, const TGPolygon& clip ); + +#if CLIP_NATIVE ClipPolyType tgPolygonUnion( const TGPolygon& subject, const ClipPolyType& clip ); +#endif // Output std::ostream &operator<< (std::ostream &output, const TGPolygon &poly);