conditionaly compile native clipper lib poly optimizations
This commit is contained in:
parent
f77da29398
commit
deaebbeb4d
2 changed files with 31 additions and 3 deletions
|
@ -690,10 +690,11 @@ TGPolygon tgPolygonDiff( const TGPolygon& subject, const TGPolygon& clip ) {
|
||||||
return polygon_clip( POLY_DIFF, subject, clip );
|
return polygon_clip( POLY_DIFF, subject, clip );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CLIP_NATIVE
|
||||||
TGPolygon tgPolygonDiff( const TGPolygon& subject, const ClipPolyType& clip ) {
|
TGPolygon tgPolygonDiff( const TGPolygon& subject, const ClipPolyType& clip ) {
|
||||||
return polygon_clip( POLY_DIFF, subject, clip );
|
return polygon_clip( POLY_DIFF, subject, clip );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Intersection
|
// Intersection
|
||||||
TGPolygon tgPolygonInt( const TGPolygon& subject, const TGPolygon& clip ) {
|
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 );
|
return polygon_clip( POLY_UNION, subject, clip );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CLIP_NATIVE
|
||||||
ClipPolyType tgPolygonUnion( const TGPolygon& subject, const ClipPolyType& clip ) {
|
ClipPolyType tgPolygonUnion( const TGPolygon& subject, const ClipPolyType& clip ) {
|
||||||
return polygon_clip_keep_native_fmt( POLY_UNION, subject, clip );
|
return polygon_clip_keep_native_fmt( POLY_UNION, subject, clip );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// canonify the polygon winding, outer contour must be anti-clockwise,
|
// canonify the polygon winding, outer contour must be anti-clockwise,
|
||||||
// all inner contours must be clockwise.
|
// all inner contours must be clockwise.
|
||||||
|
|
|
@ -29,25 +29,41 @@
|
||||||
# error This library requires C++
|
# error This library requires C++
|
||||||
#endif
|
#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_GPC
|
||||||
#define CLIP_CLIPPER
|
#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
|
#ifdef CLIP_GPC
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <gpc.h>
|
#include <gpc.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CLIP_NATIVE // optimization apparently causing errors
|
||||||
typedef gpc_polygon ClipPolyType;
|
typedef gpc_polygon ClipPolyType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* CLIP_GPC */
|
||||||
|
|
||||||
#ifdef CLIP_CLIPPER
|
#ifdef CLIP_CLIPPER
|
||||||
#include "clipper.hpp"
|
#include "clipper.hpp"
|
||||||
using namespace ClipperLib;
|
using namespace ClipperLib;
|
||||||
|
|
||||||
|
#if CLIP_NATIVE // optimization apparently causing errors
|
||||||
typedef Polygons ClipPolyType;
|
typedef Polygons ClipPolyType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* CLIP_CLIPPER */
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/math/sg_types.hxx>
|
#include <simgear/math/sg_types.hxx>
|
||||||
#include <Geometry/point3d.hxx>
|
#include <Geometry/point3d.hxx>
|
||||||
|
@ -203,6 +219,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if !CLIP_NATIVE
|
||||||
|
typedef TGPolygon ClipPolyType;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef std::vector < TGPolygon > poly_list;
|
typedef std::vector < TGPolygon > poly_list;
|
||||||
typedef poly_list::iterator poly_list_iterator;
|
typedef poly_list::iterator poly_list_iterator;
|
||||||
typedef poly_list::const_iterator const_poly_list_iterator;
|
typedef poly_list::const_iterator const_poly_list_iterator;
|
||||||
|
@ -237,7 +257,10 @@ TGPolygon tgPolygon2tristrip( const TGPolygon& poly );
|
||||||
|
|
||||||
// Difference
|
// Difference
|
||||||
TGPolygon tgPolygonDiff( const TGPolygon& subject, const TGPolygon& clip );
|
TGPolygon tgPolygonDiff( const TGPolygon& subject, const TGPolygon& clip );
|
||||||
|
|
||||||
|
#if CLIP_NATIVE
|
||||||
TGPolygon tgPolygonDiff( const TGPolygon& subject, const ClipPolyType& clip );
|
TGPolygon tgPolygonDiff( const TGPolygon& subject, const ClipPolyType& clip );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Intersection
|
// Intersection
|
||||||
TGPolygon tgPolygonInt( const TGPolygon& subject, const TGPolygon& clip );
|
TGPolygon tgPolygonInt( const TGPolygon& subject, const TGPolygon& clip );
|
||||||
|
@ -247,7 +270,10 @@ TGPolygon tgPolygonXor( const TGPolygon& subject, const TGPolygon& clip );
|
||||||
|
|
||||||
// Union
|
// Union
|
||||||
TGPolygon tgPolygonUnion( const TGPolygon& subject, const TGPolygon& clip );
|
TGPolygon tgPolygonUnion( const TGPolygon& subject, const TGPolygon& clip );
|
||||||
|
|
||||||
|
#if CLIP_NATIVE
|
||||||
ClipPolyType tgPolygonUnion( const TGPolygon& subject, const ClipPolyType& clip );
|
ClipPolyType tgPolygonUnion( const TGPolygon& subject, const ClipPolyType& clip );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
std::ostream &operator<< (std::ostream &output, const TGPolygon &poly);
|
std::ostream &operator<< (std::ostream &output, const TGPolygon &poly);
|
||||||
|
|
Loading…
Add table
Reference in a new issue