Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
623f0a2
Compile warnings cleanup, fixes for sign-conversion issues (#858)
masbug Jun 23, 2024
4240912
Fixed a minor bug in Clipper.RectClip (#864)
AngusJohnson Jul 5, 2024
68b3a2c
Fixed an integer overflow error in ClipperOffset (#867)
AngusJohnson Jul 13, 2024
736ddb0
Release version to 1.4.0
AngusJohnson Jul 13, 2024
7f41c18
throw() -> noexcept (#869)
r-barnes Jul 16, 2024
6a346b4
Add operator+ and operator+= to Rect<T> (#875)
LarsSkiba Jul 22, 2024
2a99f83
Clipper.Offset - fixed a bug occasionally encountered when over shrin…
AngusJohnson Jul 24, 2024
c19da72
Fixed compile bugs in previous commit.
AngusJohnson Jul 24, 2024
5c96b89
Preparing to merge export_usingz branch (#878)
AngusJohnson Aug 16, 2024
97906fe
Renamed ClipType.None to ClipType.NoClip (#885)
AngusJohnson Sep 16, 2024
20bd694
Missed uploading clipper.engine.cs during the previous revision
AngusJohnson Sep 16, 2024
80ef1fd
Proposed clean-ups (#894)
philstopford Sep 30, 2024
304235b
Fix warnings (#896)
anchpop Sep 30, 2024
907d1fd
And linq (#895)
philstopford Sep 30, 2024
2b665ac
Reversed LINQ dependency in C# code
AngusJohnson Oct 9, 2024
ed98928
fix after type renaming (#901)
zedxxx Oct 14, 2024
fe5f6b7
Clipper.Offset: fixed a bug seen with excessive deflation (#916)
AngusJohnson Nov 22, 2024
a8269ca
Merge branch 'main' of https://ghp_k8EUbvrIwCiGEtc8baedaTNGLEY12m09TL…
AngusJohnson Nov 22, 2024
c1b13f6
CI update - Ubuntu non-default clang changed to 17 (was 13).
AngusJohnson Dec 21, 2024
7598be9
Clipper.Core.cs: make USINGZ as local as possible (minor refactoring)…
firegurafiku Dec 21, 2024
4ab4da0
Clipper.Offset - changed arc_tolerance default
AngusJohnson Jan 21, 2025
d10ad59
InflatePaths function (C# only) - added missing arcTolerance parameter.
AngusJohnson Jan 23, 2025
ef6dbfd
Clipper2 ver 1.5.0
AngusJohnson Jan 24, 2025
59c2fc2
Fix typos (#935)
deining Jan 26, 2025
41b5f01
Fix broken links, convert links from http to https protocol (#936)
deining Jan 26, 2025
51bb284
Installed Clipper2.pc:: Use canonical way to refer to inc and libdir …
hzeller Jan 26, 2025
baa7014
std::vector: Using emplace_back to replace push_back to improve perfo…
nonwill Jan 26, 2025
e39a44f
Version 1.5.1
AngusJohnson Jan 27, 2025
d6baa52
Fix header including to avoid confusion: header only included where …
nonwill Jan 27, 2025
6901921
Version 1.5.2
AngusJohnson Jan 27, 2025
4f48fe8
Merge upstream
Egliss Jan 29, 2025
97533dd
Rename namespace
Egliss Jan 29, 2025
c2905b3
Update action
Egliss Jan 29, 2025
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
36 changes: 18 additions & 18 deletions .github/workflows/actions_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,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 @@ -26,8 +26,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 @@ -43,8 +43,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 @@ -65,8 +65,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 @@ -81,22 +81,22 @@ jobs:
run: |
cd CPP/build
env CTEST_OUTPUT_ON_FAILURE=1 make test
ubuntu-latest-clang-13:
ubuntu-latest-clang-17:
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
- name: Install clang 17
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 13
sudo ./llvm.sh 17
- name: Build
run: |
export CC=/usr/bin/clang-13
export CXX=/usr/bin/clang++-13
export CC=/usr/bin/clang-17
export CXX=/usr/bin/clang++-17
mkdir CPP/build
cd CPP/build
cmake .. -DCLIPPER2_TESTS=ON
Expand All @@ -108,8 +108,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
6 changes: 3 additions & 3 deletions .github/workflows/actions_csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
run:
working-directory: ./CSharp
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Copy Clipper2Lib to USINGZ directory
run: cp Clipper2Lib/*.cs USINGZ/
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion CPP/BenchMark/GetIntersectPtBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct SetConsoleTextColor
public:
SetConsoleTextColor(TextColor color) : _color(color) {};

static friend std::ostream& operator<< (std::ostream& out, SetConsoleTextColor const& scc)
friend std::ostream& operator<< (std::ostream& out, SetConsoleTextColor const& scc)
{
return out << "\x1B[" << scc._color << "m";
}
Expand Down
4 changes: 2 additions & 2 deletions CPP/BenchMark/PointInPolygonBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct SetConsoleTextColor
public:
SetConsoleTextColor(ConsoleTextColor color) : _color(color) {};

static friend std::ostream& operator<< (std::ostream& out, SetConsoleTextColor const& scc)
friend std::ostream& operator<< (std::ostream& out, SetConsoleTextColor const& scc)
{
return out << "\x1B[" << scc._color << "m";
}
Expand Down Expand Up @@ -195,7 +195,7 @@ inline PointInPolygonResult PIP2(const Point64& pt, const Path64& polygon)
}

/////////////////////////////////////////////////////////
// PIP3: An entirely different algorithm for comparision.
// PIP3: An entirely different algorithm for comparison.
// "Optimal Reliable Point-in-Polygon Test and
// Differential Coding Boolean Operations on Polygons"
// by Jianqiang Hao et al.
Expand Down
4 changes: 2 additions & 2 deletions CPP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.15)
project(Clipper2 VERSION 1.3.0 LANGUAGES C CXX)
project(Clipper2 VERSION 1.5.2 LANGUAGES C CXX)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17)
Expand Down Expand Up @@ -98,7 +98,7 @@ if (NOT (CLIPPER2_USINGZ STREQUAL "OFF"))
if (MSVC)
target_compile_options(Clipper2Z PRIVATE /W4 /WX)
else()
target_compile_options(Clipper2Z PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c++20-compat)
target_compile_options(Clipper2Z PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c++20-compat -Wsign-conversion)
target_link_libraries(Clipper2Z PUBLIC -lm)
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions CPP/Clipper2.pc.cmakein
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

Name: Clipper2@PCFILE_LIB_SUFFIX@
Description: A Polygon Clipping and Offsetting library in C++
Expand Down
61 changes: 41 additions & 20 deletions CPP/Clipper2Lib/include/clipper2/clipper.core.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 12 May 2024 *
* Website : http://www.angusj.com *
* Website : https://www.angusj.com *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : Core Clipper Library structures and functions *
* License : http://www.boost.org/LICENSE_1_0.txt *
* License : https://www.boost.org/LICENSE_1_0.txt *
*******************************************************************************/

#ifndef CLIPPER_CORE_H
#define CLIPPER_CORE_H

#include "clipper2/clipper.version.h"
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include "clipper2/clipper.version.h"
#include <cmath>

namespace Clipper2Lib
{
Expand All @@ -30,7 +28,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 @@ -87,6 +85,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 @@ -106,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 @@ -136,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 @@ -149,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 @@ -159,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 Expand Up @@ -323,10 +328,10 @@ namespace Clipper2Lib
{
Path<T> result;
result.reserve(4);
result.push_back(Point<T>(left, top));
result.push_back(Point<T>(right, top));
result.push_back(Point<T>(right, bottom));
result.push_back(Point<T>(left, bottom));
result.emplace_back(left, top);
result.emplace_back(right, top);
result.emplace_back(right, bottom);
result.emplace_back(left, bottom);
return result;
}

Expand Down Expand Up @@ -361,6 +366,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 Expand Up @@ -594,13 +615,13 @@ namespace Clipper2Lib
result.reserve(path.size());
typename Path<T>::const_iterator path_iter = path.cbegin();
Point<T> first_pt = *path_iter++, last_pt = first_pt;
result.push_back(first_pt);
result.emplace_back(first_pt);
for (; path_iter != path.cend(); ++path_iter)
{
if (!NearEqual(*path_iter, last_pt, max_dist_sqrd))
{
last_pt = *path_iter;
result.push_back(last_pt);
result.emplace_back(last_pt);
}
}
if (!is_closed_path) return result;
Expand All @@ -618,7 +639,7 @@ namespace Clipper2Lib
for (typename Paths<T>::const_iterator paths_citer = paths.cbegin();
paths_citer != paths.cend(); ++paths_citer)
{
result.push_back(StripNearEqual(*paths_citer, max_dist_sqrd, is_closed_path));
result.emplace_back(std::move(StripNearEqual(*paths_citer, max_dist_sqrd, is_closed_path)));
}
return result;
}
Expand Down Expand Up @@ -763,7 +784,7 @@ namespace Clipper2Lib
const Point<T>& line1, const Point<T>& line2)
{
//perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²)
//see http://en.wikipedia.org/wiki/Perpendicular_distance
//see https://en.wikipedia.org/wiki/Perpendicular_distance
double a = static_cast<double>(pt.x - line1.x);
double b = static_cast<double>(pt.y - line1.y);
double c = static_cast<double>(line2.x - line1.x);
Expand Down
Loading