1
0
Fork 0

conditionaly compile native clipper lib poly optimizations

This commit is contained in:
PSadrozinski 2011-10-25 22:52:55 -04:00 committed by Christian Schmitt
parent f77da29398
commit deaebbeb4d
2 changed files with 31 additions and 3 deletions

View file

@ -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.

View file

@ -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 <gpc.h>
}
#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 <simgear/compiler.h>
#include <simgear/math/sg_types.hxx>
#include <Geometry/point3d.hxx>
@ -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);