Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipper2 ver. 1.5.0 #2350

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 3rdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

## Clipper2
- [![Upstream](https://img.shields.io/github/v/tag/AngusJohnson/Clipper2?label=Upstream)](https://github.com/AngusJohnson/Clipper2)
- Version: 1.4.0
- Version: 1.5.0
- License: BSL-1.0

## ConcurrentQueue
Expand Down Expand Up @@ -157,7 +157,7 @@
- Version: 1.0.1
- License: Apache-2.0

## oboe (Adnroid only)
## oboe (Android only)
- [![Upstream](https://img.shields.io/github/v/tag/google/oboe?label=Upstream)](https://github.com/google/oboe)
- Version: 1.9.3
- License: Apache-2.0
Expand Down
35 changes: 29 additions & 6 deletions 3rdparty/clipper2/include/clipper2/clipper.core.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Clipper2Lib
public:
explicit Clipper2Exception(const char* description) :
m_descr(description) {}
virtual const char* what() const throw() override { return m_descr.c_str(); }
virtual const char* what() const noexcept override { return m_descr.c_str(); }
private:
std::string m_descr;
};
Expand Down Expand Up @@ -88,6 +88,9 @@ namespace Clipper2Lib
throw Clipper2Exception(undefined_error);
case range_error_i:
throw Clipper2Exception(range_error);
// Should never happen, but adding this to stop a compiler warning
default:
throw Clipper2Exception("Unknown error");
}
#else
++error_code; // only to stop compiler warning
Expand All @@ -107,17 +110,21 @@ namespace Clipper2Lib
//https://en.wikipedia.org/wiki/Nonzero-rule
enum class FillRule { EvenOdd, NonZero, Positive, Negative };

#ifdef USINGZ
using z_type = int64_t;
#endif

// Point ------------------------------------------------------------------------

template <typename T>
struct Point {
T x;
T y;
#ifdef USINGZ
int64_t z;
z_type z;

template <typename T2>
inline void Init(const T2 x_ = 0, const T2 y_ = 0, const int64_t z_ = 0)
inline void Init(const T2 x_ = 0, const T2 y_ = 0, const z_type z_ = 0)
{
if constexpr (std::is_integral_v<T> &&
is_round_invocable<T2>::value && !std::is_integral_v<T2>)
Expand All @@ -137,7 +144,7 @@ namespace Clipper2Lib
explicit Point() : x(0), y(0), z(0) {};

template <typename T2>
Point(const T2 x_, const T2 y_, const int64_t z_ = 0)
Point(const T2 x_, const T2 y_, const z_type z_ = 0)
{
Init(x_, y_);
z = z_;
Expand All @@ -150,7 +157,7 @@ namespace Clipper2Lib
}

template <typename T2>
explicit Point(const Point<T2>& p, int64_t z_)
explicit Point(const Point<T2>& p, z_type z_)
{
Init(p.x, p.y, z_);
}
Expand All @@ -160,7 +167,7 @@ namespace Clipper2Lib
return Point(x * scale, y * scale, z);
}

void SetZ(const int64_t z_value) { z = z_value; }
void SetZ(const z_type z_value) { z = z_value; }

friend std::ostream& operator<<(std::ostream& os, const Point& point)
{
Expand Down Expand Up @@ -362,6 +369,22 @@ namespace Clipper2Lib
top == other.top && bottom == other.bottom;
}

Rect<T>& operator+=(const Rect<T>& other)
{
left = (std::min)(left, other.left);
top = (std::min)(top, other.top);
right = (std::max)(right, other.right);
bottom = (std::max)(bottom, other.bottom);
return *this;
}

Rect<T> operator+(const Rect<T>& other) const
{
Rect<T> result = *this;
result += other;
return result;
}

friend std::ostream& operator<<(std::ostream& os, const Rect<T>& rect) {
os << "(" << rect.left << "," << rect.top << "," << rect.right << "," << rect.bottom << ") ";
return os;
Expand Down
18 changes: 9 additions & 9 deletions 3rdparty/clipper2/include/clipper2/clipper.engine.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 5 July 2024 *
* Date : 17 September 2024 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : This is the main polygon clipping module *
Expand Down Expand Up @@ -32,13 +32,13 @@ namespace Clipper2Lib {
struct HorzSegment;

//Note: all clipping operations except for Difference are commutative.
enum class ClipType { None, Intersection, Union, Difference, Xor };
enum class ClipType { NoClip, Intersection, Union, Difference, Xor };

enum class PathType { Subject, Clip };
enum class JoinWith { None, Left, Right };
enum class JoinWith { NoJoin, Left, Right };

enum class VertexFlags : uint32_t {
None = 0, OpenStart = 1, OpenEnd = 2, LocalMax = 4, LocalMin = 8
Empty = 0, OpenStart = 1, OpenEnd = 2, LocalMax = 4, LocalMin = 8
};

constexpr enum VertexFlags operator &(enum VertexFlags a, enum VertexFlags b)
Expand All @@ -55,7 +55,7 @@ namespace Clipper2Lib {
Point64 pt;
Vertex* next = nullptr;
Vertex* prev = nullptr;
VertexFlags flags = VertexFlags::None;
VertexFlags flags = VertexFlags::Empty;
};

struct OutPt {
Expand Down Expand Up @@ -131,7 +131,7 @@ namespace Clipper2Lib {
Vertex* vertex_top = nullptr;
LocalMinima* local_min = nullptr; // the bottom of an edge 'bound' (also Vatti)
bool is_left_bound = false;
JoinWith join_with = JoinWith::None;
JoinWith join_with = JoinWith::NoJoin;
};

struct LocalMinima {
Expand Down Expand Up @@ -167,7 +167,7 @@ namespace Clipper2Lib {
};

#ifdef USINGZ
typedef std::function<void(const Point64& e1bot, const Point64& e1top,
typedef std::function<void(const Point64& e1bot, const Point64& e1top,
const Point64& e2bot, const Point64& e2top, Point64& pt)> ZCallback64;

typedef std::function<void(const PointD& e1bot, const PointD& e1top,
Expand Down Expand Up @@ -197,7 +197,7 @@ namespace Clipper2Lib {

class ClipperBase {
private:
ClipType cliptype_ = ClipType::None;
ClipType cliptype_ = ClipType::NoClip;
FillRule fillrule_ = FillRule::EvenOdd;
FillRule fillpos = FillRule::Positive;
int64_t bot_y_ = 0;
Expand All @@ -210,7 +210,7 @@ namespace Clipper2Lib {
std::vector<Vertex*> vertex_lists_;
std::priority_queue<int64_t> scanline_list_;
IntersectNodeList intersect_nodes_;
HorzSegmentList horz_seg_list_;
HorzSegmentList horz_seg_list_;
std::vector<HorzJoin> horz_join_list_;
void Reset();
inline void InsertScanline(int64_t y);
Expand Down
Loading
Loading