Skip to content

Commit

Permalink
Preparing to merge export_usingz branch (#878)
Browse files Browse the repository at this point in the history
* Branch from main - to test USINGZ in clipper.export.h

* clipper.header.h - Replaced problematic bit_cast function

* clipper.export.h - tweaked new Reinterpret function

* Tweaked a C++ CI test routine

* clipper.export.h - minor tweak to Reinterpret function

* tweaks to CI config.

* another tweak to C++ CI configuration
  • Loading branch information
AngusJohnson authored Aug 16, 2024
1 parent c19da72 commit 5c96b89
Show file tree
Hide file tree
Showing 35 changed files with 4,256 additions and 1,605 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/actions_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
windows-latest:
runs-on: 'windows-latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v2
- name: Build
run: |
mkdir CPP/build
Expand All @@ -25,8 +25,8 @@ jobs:
ubuntu-latest-gcc-default:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- name: Build
Expand All @@ -42,8 +42,8 @@ jobs:
ubuntu-latest-gcc-11:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- name: Install gcc 11
Expand All @@ -64,8 +64,8 @@ jobs:
ubuntu-latest-clang-default:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- name: Build
Expand All @@ -83,8 +83,8 @@ jobs:
ubuntu-latest-clang-13:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- name: Install clang 13
Expand All @@ -107,8 +107,8 @@ jobs:
macos-latest:
runs-on: 'macos-latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/actions_csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
run:
working-directory: ./CSharp
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Copy Clipper2Lib to USINGZ directory
run: cp Clipper2Lib/*.cs USINGZ/
- name: Setup .NET Core
Expand Down
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 5c96b89

Please sign in to comment.