From 97906fea2bed3a16bc46ce01ecf1607c366908b2 Mon Sep 17 00:00:00 2001 From: angusj Date: Tue, 17 Sep 2024 08:00:44 +1000 Subject: [PATCH] Renamed ClipType.None to ClipType.NoClip (#885) Trivial code tidy in TestExportHeaders.cpp --- .../include/clipper2/clipper.engine.h | 16 ++++----- .../include/clipper2/clipper.export.h | 4 +-- CPP/Clipper2Lib/src/clipper.engine.cpp | 36 +++++++++---------- CPP/Tests/TestExportHeaders.cpp | 4 +-- CPP/Tests/TestOffsets.cpp | 2 +- CPP/Tests/TestPolytreeHoles.cpp | 4 +-- CPP/Utils/ClipFileSave.cpp | 30 ++++++++-------- CSharp/Clipper2Lib/Clipper.Core.cs | 4 +-- Delphi/Clipper2Lib/Clipper.Core.pas | 4 +-- Delphi/Clipper2Lib/Clipper.pas | 2 +- 10 files changed, 53 insertions(+), 53 deletions(-) diff --git a/CPP/Clipper2Lib/include/clipper2/clipper.engine.h b/CPP/Clipper2Lib/include/clipper2/clipper.engine.h index f6108832..559f2479 100644 --- a/CPP/Clipper2Lib/include/clipper2/clipper.engine.h +++ b/CPP/Clipper2Lib/include/clipper2/clipper.engine.h @@ -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 * @@ -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) @@ -55,7 +55,7 @@ namespace Clipper2Lib { Point64 pt; Vertex* next = nullptr; Vertex* prev = nullptr; - VertexFlags flags = VertexFlags::None; + VertexFlags flags = VertexFlags::Empty; }; struct OutPt { @@ -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 { @@ -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; @@ -210,7 +210,7 @@ namespace Clipper2Lib { std::vector vertex_lists_; std::priority_queue scanline_list_; IntersectNodeList intersect_nodes_; - HorzSegmentList horz_seg_list_; + HorzSegmentList horz_seg_list_; std::vector horz_join_list_; void Reset(); inline void InsertScanline(int64_t y); diff --git a/CPP/Clipper2Lib/include/clipper2/clipper.export.h b/CPP/Clipper2Lib/include/clipper2/clipper.export.h index 3dfd2618..5afbba17 100644 --- a/CPP/Clipper2Lib/include/clipper2/clipper.export.h +++ b/CPP/Clipper2Lib/include/clipper2/clipper.export.h @@ -1,6 +1,6 @@ /******************************************************************************* * Author : Angus Johnson * -* Date : 16 August 2024 * +* Date : 17 September 2024 * * Website : http://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : This module exports the Clipper2 Library (ie DLL/so) * @@ -10,7 +10,7 @@ /* Boolean clipping: - cliptype: None=0, Intersection=1, Union=2, Difference=3, Xor=4 + cliptype: NoClip=0, Intersection=1, Union=2, Difference=3, Xor=4 fillrule: EvenOdd=0, NonZero=1, Positive=2, Negative=3 Polygon offsetting (inflate/deflate): diff --git a/CPP/Clipper2Lib/src/clipper.engine.cpp b/CPP/Clipper2Lib/src/clipper.engine.cpp index 8f120267..d3a146b4 100644 --- a/CPP/Clipper2Lib/src/clipper.engine.cpp +++ b/CPP/Clipper2Lib/src/clipper.engine.cpp @@ -1,6 +1,6 @@ /******************************************************************************* * Author : Angus Johnson * -* Date : 27 April 2024 * +* Date : 17 September 2024 * * Website : http://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : This is the main polygon clipping module * @@ -85,7 +85,7 @@ namespace Clipper2Lib { inline bool IsOpenEnd(const Vertex& v) { return (v.flags & (VertexFlags::OpenStart | VertexFlags::OpenEnd)) != - VertexFlags::None; + VertexFlags::Empty; } @@ -220,7 +220,7 @@ namespace Clipper2Lib { inline bool IsMaxima(const Vertex& v) { - return ((v.flags & VertexFlags::LocalMax) != VertexFlags::None); + return ((v.flags & VertexFlags::LocalMax) != VertexFlags::Empty); } @@ -235,12 +235,12 @@ namespace Clipper2Lib { if (e.wind_dx > 0) while ((result->next->pt.y == result->pt.y) && ((result->flags & (VertexFlags::OpenEnd | - VertexFlags::LocalMax)) == VertexFlags::None)) + VertexFlags::LocalMax)) == VertexFlags::Empty)) result = result->next; else while (result->prev->pt.y == result->pt.y && ((result->flags & (VertexFlags::OpenEnd | - VertexFlags::LocalMax)) == VertexFlags::None)) + VertexFlags::LocalMax)) == VertexFlags::Empty)) result = result->prev; if (!IsMaxima(*result)) result = nullptr; // not a maxima return result; @@ -478,7 +478,7 @@ namespace Clipper2Lib { inline bool IsJoined(const Active& e) { - return e.join_with != JoinWith::None; + return e.join_with != JoinWith::NoJoin; } inline void SetOwner(OutRec* outrec, OutRec* new_owner) @@ -608,7 +608,7 @@ namespace Clipper2Lib { Vertex& vert, PathType polytype, bool is_open) { //make sure the vertex is added only once ... - if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::None) return; + if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return; vert.flags = (vert.flags | VertexFlags::LocalMin); list.push_back(std::make_unique (&vert, polytype, is_open)); @@ -643,7 +643,7 @@ namespace Clipper2Lib { } curr_v->prev = prev_v; curr_v->pt = pt; - curr_v->flags = VertexFlags::None; + curr_v->flags = VertexFlags::Empty; prev_v = curr_v++; cnt++; } @@ -725,7 +725,7 @@ namespace Clipper2Lib { void ReuseableDataContainer64::AddLocMin(Vertex& vert, PathType polytype, bool is_open) { //make sure the vertex is added only once ... - if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::None) return; + if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return; vert.flags = (vert.flags | VertexFlags::LocalMin); minima_list_.push_back(std::make_unique (&vert, polytype, is_open)); @@ -907,7 +907,7 @@ namespace Clipper2Lib { void ClipperBase::AddLocMin(Vertex& vert, PathType polytype, bool is_open) { //make sure the vertex is added only once ... - if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::None) return; + if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return; vert.flags = (vert.flags | VertexFlags::LocalMin); minima_list_.push_back(std::make_unique (&vert, polytype, is_open)); @@ -932,7 +932,7 @@ namespace Clipper2Lib { switch (cliptype_) { - case ClipType::None: + case ClipType::NoClip: return false; case ClipType::Intersection: switch (fillrule_) @@ -1208,7 +1208,7 @@ namespace Clipper2Lib { while (PopLocalMinima(bot_y, local_minima)) { - if ((local_minima->vertex->flags & VertexFlags::OpenStart) != VertexFlags::None) + if ((local_minima->vertex->flags & VertexFlags::OpenStart) != VertexFlags::Empty) { left_bound = nullptr; } @@ -1224,7 +1224,7 @@ namespace Clipper2Lib { SetDx(*left_bound); } - if ((local_minima->vertex->flags & VertexFlags::OpenEnd) != VertexFlags::None) + if ((local_minima->vertex->flags & VertexFlags::OpenEnd) != VertexFlags::Empty) { right_bound = nullptr; } @@ -2125,7 +2125,7 @@ namespace Clipper2Lib { using_polytree_ = use_polytrees; Reset(); int64_t y; - if (ct == ClipType::None || !PopScanline(y)) return true; + if (ct == ClipType::NoClip || !PopScanline(y)) return true; while (succeeded_) { @@ -2789,14 +2789,14 @@ namespace Clipper2Lib { { if (e.join_with == JoinWith::Right) { - e.join_with = JoinWith::None; - e.next_in_ael->join_with = JoinWith::None; + e.join_with = JoinWith::NoJoin; + e.next_in_ael->join_with = JoinWith::NoJoin; AddLocalMinPoly(e, *e.next_in_ael, pt, true); } else { - e.join_with = JoinWith::None; - e.prev_in_ael->join_with = JoinWith::None; + e.join_with = JoinWith::NoJoin; + e.prev_in_ael->join_with = JoinWith::NoJoin; AddLocalMinPoly(*e.prev_in_ael, e, pt, true); } } diff --git a/CPP/Tests/TestExportHeaders.cpp b/CPP/Tests/TestExportHeaders.cpp index 423d46ee..037ff64f 100644 --- a/CPP/Tests/TestExportHeaders.cpp +++ b/CPP/Tests/TestExportHeaders.cpp @@ -15,7 +15,7 @@ static bool CreatePolyPath64FromCPolyPath(CPolyPath64& v, PolyPath64& owner) { int64_t x = *v++, y = *v++; #ifdef USINGZ - auto z = Reinterpret(*v++); + z_type z = Reinterpret(*v++); path.push_back(Point64(x, y, z)); #else path.push_back(Point64(x, y)); @@ -48,7 +48,7 @@ static bool CreatePolyPathDFromCPolyPath(CPolyPathD& v, PolyPathD& owner) { double x = *v++, y = *v++; #ifdef USINGZ - auto z = Reinterpret(*v++); + z_type z = Reinterpret(*v++); path.push_back(PointD(x, y, z)); #else path.push_back(PointD(x, y)); diff --git a/CPP/Tests/TestOffsets.cpp b/CPP/Tests/TestOffsets.cpp index 006e4b6a..d1af4e74 100644 --- a/CPP/Tests/TestOffsets.cpp +++ b/CPP/Tests/TestOffsets.cpp @@ -12,7 +12,7 @@ TEST(Clipper2Tests, TestOffsets) { ClipperOffset co; Paths64 subject, subject_open, clip; Paths64 solution, solution_open; - ClipType ct = ClipType::None; + ClipType ct = ClipType::NoClip; FillRule fr = FillRule::NonZero; int64_t stored_area = 0, stored_count = 0; ASSERT_TRUE(LoadTestNum(ifs, test_number, subject, subject_open, clip, stored_area, stored_count, ct, fr)); diff --git a/CPP/Tests/TestPolytreeHoles.cpp b/CPP/Tests/TestPolytreeHoles.cpp index 891094ba..901521a0 100644 --- a/CPP/Tests/TestPolytreeHoles.cpp +++ b/CPP/Tests/TestPolytreeHoles.cpp @@ -9,7 +9,7 @@ TEST(Clipper2Tests, TestPolytreeHoles1) Paths64 subject, subject_open, clip; PolyTree64 solution; Paths64 solution_open; - ClipType ct = ClipType::None; + ClipType ct = ClipType::NoClip; FillRule fr = FillRule::EvenOdd; int64_t area = 0, count = 0; bool success = false; @@ -61,7 +61,7 @@ TEST(Clipper2Tests, TestPolytreeHoles2) ASSERT_TRUE(ifs); ASSERT_TRUE(ifs.good()); Paths64 subject, subject_open, clip; - ClipType ct = ClipType::None; + ClipType ct = ClipType::NoClip; FillRule fr = FillRule::EvenOdd; int64_t area = 0, count = 0; ASSERT_TRUE(LoadTestNum(ifs, 1, subject, subject_open, clip, area, count, ct, fr)); diff --git a/CPP/Utils/ClipFileSave.cpp b/CPP/Utils/ClipFileSave.cpp index 305484c6..139e03a7 100644 --- a/CPP/Utils/ClipFileSave.cpp +++ b/CPP/Utils/ClipFileSave.cpp @@ -14,7 +14,7 @@ namespace Clipper2Lib { // Boyer Moore Horspool Search //------------------------------------------------------------------------------ -class BMH_Search +class BMH_Search { private: uint8_t case_table[256]; @@ -51,7 +51,7 @@ class BMH_Search } void Init() - { + { case_sensitive_ = false; current = nullptr; end = nullptr; last_found = nullptr; } @@ -85,7 +85,7 @@ class BMH_Search while (current < end) { uint8_t i = shift[case_table[static_cast(*current)]]; - if (!i) + if (!i) { char* j = current - needle_len_less1; while (i < needle_len_less1 && @@ -107,7 +107,7 @@ class BMH_Search public: - explicit BMH_Search(std::ifstream& stream, + explicit BMH_Search(std::ifstream& stream, const std::string& needle = "") { //case blind table @@ -121,7 +121,7 @@ class BMH_Search if (needle.size() > 0) SetNeedle(needle); } - BMH_Search(const char* haystack, size_t length, + BMH_Search(const char* haystack, size_t length, const std::string& needle = "") { Init(); @@ -137,7 +137,7 @@ class BMH_Search void Reset() { - current = haystack_; + current = haystack_; last_found = nullptr; } @@ -152,7 +152,7 @@ class BMH_Search needle_.clear(); needle_.reserve(needle_len_); for (const char& c : needle) needle_.push_back(static_cast(c)); - + //case insensitive needle needle_ic_ = needle_; for (std::vector< uint8_t>::iterator ui = needle_ic_.begin(); ui != needle_ic_.end(); ++ui) @@ -199,10 +199,10 @@ class BMH_Search inline size_t LastFoundOffset() { return last_found - haystack_; } inline char* FindNextEndLine() - { + { current = last_found + needle_len_; - while (current < end && - *current != char(13) && *current != char(10)) + while (current < end && + *current != char(13) && *current != char(10)) ++current; return current; } @@ -212,7 +212,7 @@ class BMH_Search void PathsToStream(const Paths64& paths, std::ostream& stream) { - for (Paths64::const_iterator paths_it = paths.cbegin(); + for (Paths64::const_iterator paths_it = paths.cbegin(); paths_it != paths.cend(); ++paths_it) { //watch out for empty paths @@ -247,7 +247,7 @@ static bool GetInt(string::const_iterator& s_it, } bool SaveTest(const std::string& filename, bool append, - const Paths64* subj, const Paths64* subj_open, const Paths64* clip, + const Paths64* subj, const Paths64* subj_open, const Paths64* clip, int64_t area, int64_t count, ClipType ct, FillRule fr) { string line; @@ -267,8 +267,8 @@ bool SaveTest(const std::string& filename, bool append, string::const_iterator s_it = line.cbegin(), s_end = line.cend(); GetInt(s_it, s_end, last_test_no); } - } - else if (FileExists(filename)) + } + else if (FileExists(filename)) remove(filename.c_str()); ++last_test_no; @@ -282,7 +282,7 @@ bool SaveTest(const std::string& filename, bool append, string cliptype_string; switch (ct) { - case ClipType::None: cliptype_string = "NONE"; break; + case ClipType::NoClip: cliptype_string = "NOCLIP"; break; case ClipType::Intersection: cliptype_string = "INTERSECTION"; break; case ClipType::Union: cliptype_string = "UNION"; break; case ClipType::Difference: cliptype_string = "DIFFERENCE"; break; diff --git a/CSharp/Clipper2Lib/Clipper.Core.cs b/CSharp/Clipper2Lib/Clipper.Core.cs index 6358aef8..dc2ee7bd 100644 --- a/CSharp/Clipper2Lib/Clipper.Core.cs +++ b/CSharp/Clipper2Lib/Clipper.Core.cs @@ -1,6 +1,6 @@ /******************************************************************************* * Author : Angus Johnson * -* Date : 13 May 2024 * +* Date : 17 September 2024 * * Website : http://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : Core structures and functions for the Clipper Library * @@ -532,7 +532,7 @@ public string ToString(int precision = 2) // Note: all clipping operations except for Difference are commutative. public enum ClipType { - None, + NoClip, Intersection, Union, Difference, diff --git a/Delphi/Clipper2Lib/Clipper.Core.pas b/Delphi/Clipper2Lib/Clipper.Core.pas index a6ee145c..d265e05d 100644 --- a/Delphi/Clipper2Lib/Clipper.Core.pas +++ b/Delphi/Clipper2Lib/Clipper.Core.pas @@ -2,7 +2,7 @@ (******************************************************************************* * Author : Angus Johnson * -* Date : 13 May 2024 * +* Date : 17 September 2024 * * Website : http://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : Core Clipper Library module * @@ -137,7 +137,7 @@ TListEx = class property Item[idx: integer]: Pointer read UnsafeGet; default; end; - TClipType = (ctNone, ctIntersection, ctUnion, ctDifference, ctXor); + TClipType = (ctNoClip, ctIntersection, ctUnion, ctDifference, ctXor); TPointInPolygonResult = (pipOn, pipInside, pipOutside); diff --git a/Delphi/Clipper2Lib/Clipper.pas b/Delphi/Clipper2Lib/Clipper.pas index 0c2fe87e..1520c671 100644 --- a/Delphi/Clipper2Lib/Clipper.pas +++ b/Delphi/Clipper2Lib/Clipper.pas @@ -52,7 +52,7 @@ interface etSquare = Clipper.Offset.etSquare; etRound = Clipper.Offset.etRound; - ctNone = Clipper.Core.ctNone; + ctNone = Clipper.Core.ctNoClip; ctIntersection = Clipper.Core.ctIntersection; ctUnion = Clipper.Core.ctUnion; ctDifference = Clipper.Core.ctDifference;