Catch RangeTest exception from clipper. Fixes #1410

This commit is contained in:
Marius Kintel 2015-08-31 16:56:00 -04:00
parent 6441ac4da2
commit b152acb9e4

View file

@ -1,4 +1,5 @@
#include "clipper-utils.h"
#include "printutils.h"
#include <boost/foreach.hpp>
namespace ClipperUtils {
@ -30,7 +31,15 @@ namespace ClipperUtils {
ClipperLib::PolyTree sanitize(const ClipperLib::Paths &paths) {
ClipperLib::PolyTree result;
ClipperLib::Clipper clipper;
clipper.AddPaths(paths, ClipperLib::ptSubject, true);
try {
clipper.AddPaths(paths, ClipperLib::ptSubject, true);
}
catch(...) {
// Most likely caught a RangeTest exception from clipper
// Note that Clipper up to v6.2.1 incorrectly throws
// an exception of type char* rather than a clipperException()
PRINT("WARNING: Range check failed for polygon. skipping");
}
clipper.Execute(ClipperLib::ctUnion, result, ClipperLib::pftEvenOdd);
return result;
}