Skip to content

Commit

Permalink
Branch from main - to test USINGZ in clipper.export.h
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusJohnson committed Aug 14, 2024
1 parent c19da72 commit b060424
Show file tree
Hide file tree
Showing 32 changed files with 4,173 additions and 1,588 deletions.
14 changes: 9 additions & 5 deletions CPP/Clipper2Lib/include/clipper2/clipper.core.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,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 +141,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 +154,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 +164,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
Loading

0 comments on commit b060424

Please sign in to comment.