Skip to content

Commit

Permalink
Renamed ClipType.None to ClipType.NoClip (AngusJohnson#885)
Browse files Browse the repository at this point in the history
Trivial code tidy in TestExportHeaders.cpp
  • Loading branch information
AngusJohnson committed Sep 16, 2024
1 parent 5c96b89 commit 97906fe
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 53 deletions.
16 changes: 8 additions & 8 deletions CPP/Clipper2Lib/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 @@ -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
4 changes: 2 additions & 2 deletions CPP/Clipper2Lib/include/clipper2/clipper.export.h
Original file line number Diff line number Diff line change
@@ -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) *
Expand All @@ -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):
Expand Down
36 changes: 18 additions & 18 deletions CPP/Clipper2Lib/src/clipper.engine.cpp
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down Expand Up @@ -85,7 +85,7 @@ namespace Clipper2Lib {
inline bool IsOpenEnd(const Vertex& v)
{
return (v.flags & (VertexFlags::OpenStart | VertexFlags::OpenEnd)) !=
VertexFlags::None;
VertexFlags::Empty;
}


Expand Down Expand Up @@ -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);
}


Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 <LocalMinima>(&vert, polytype, is_open));
Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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 <LocalMinima>(&vert, polytype, is_open));
Expand Down Expand Up @@ -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 <LocalMinima>(&vert, polytype, is_open));
Expand All @@ -932,7 +932,7 @@ namespace Clipper2Lib {

switch (cliptype_)
{
case ClipType::None:
case ClipType::NoClip:
return false;
case ClipType::Intersection:
switch (fillrule_)
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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_)
{
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions CPP/Tests/TestExportHeaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static bool CreatePolyPath64FromCPolyPath(CPolyPath64& v, PolyPath64& owner)
{
int64_t x = *v++, y = *v++;
#ifdef USINGZ
auto z = Reinterpret<z_type, int64_t>(*v++);
z_type z = Reinterpret<z_type>(*v++);
path.push_back(Point64(x, y, z));
#else
path.push_back(Point64(x, y));
Expand Down Expand Up @@ -48,7 +48,7 @@ static bool CreatePolyPathDFromCPolyPath(CPolyPathD& v, PolyPathD& owner)
{
double x = *v++, y = *v++;
#ifdef USINGZ
auto z = Reinterpret<z_type, double>(*v++);
z_type z = Reinterpret<z_type>(*v++);
path.push_back(PointD(x, y, z));
#else
path.push_back(PointD(x, y));
Expand Down
2 changes: 1 addition & 1 deletion CPP/Tests/TestOffsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions CPP/Tests/TestPolytreeHoles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
30 changes: 15 additions & 15 deletions CPP/Utils/ClipFileSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Clipper2Lib {
// Boyer Moore Horspool Search
//------------------------------------------------------------------------------

class BMH_Search
class BMH_Search
{
private:
uint8_t case_table[256];
Expand Down Expand Up @@ -51,7 +51,7 @@ class BMH_Search
}

void Init()
{
{
case_sensitive_ = false;
current = nullptr; end = nullptr; last_found = nullptr;
}
Expand Down Expand Up @@ -85,7 +85,7 @@ class BMH_Search
while (current < end)
{
uint8_t i = shift[case_table[static_cast<unsigned>(*current)]];
if (!i)
if (!i)
{
char* j = current - needle_len_less1;
while (i < needle_len_less1 &&
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -137,7 +137,7 @@ class BMH_Search

void Reset()
{
current = haystack_;
current = haystack_;
last_found = nullptr;
}

Expand All @@ -152,7 +152,7 @@ class BMH_Search
needle_.clear();
needle_.reserve(needle_len_);
for (const char& c : needle) needle_.push_back(static_cast<uint8_t>(c));

//case insensitive needle
needle_ic_ = needle_;
for (std::vector< uint8_t>::iterator ui = needle_ic_.begin(); ui != needle_ic_.end(); ++ui)
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions CSharp/Clipper2Lib/Clipper.Core.cs
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 97906fe

Please sign in to comment.