Skip to content

Commit 97906fe

Browse files
committed
Renamed ClipType.None to ClipType.NoClip (AngusJohnson#885)
Trivial code tidy in TestExportHeaders.cpp
1 parent 5c96b89 commit 97906fe

File tree

10 files changed

+53
-53
lines changed

10 files changed

+53
-53
lines changed

CPP/Clipper2Lib/include/clipper2/clipper.engine.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 5 July 2024 *
3+
* Date : 17 September 2024 *
44
* Website : http://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2024 *
66
* Purpose : This is the main polygon clipping module *
@@ -32,13 +32,13 @@ namespace Clipper2Lib {
3232
struct HorzSegment;
3333

3434
//Note: all clipping operations except for Difference are commutative.
35-
enum class ClipType { None, Intersection, Union, Difference, Xor };
35+
enum class ClipType { NoClip, Intersection, Union, Difference, Xor };
3636

3737
enum class PathType { Subject, Clip };
38-
enum class JoinWith { None, Left, Right };
38+
enum class JoinWith { NoJoin, Left, Right };
3939

4040
enum class VertexFlags : uint32_t {
41-
None = 0, OpenStart = 1, OpenEnd = 2, LocalMax = 4, LocalMin = 8
41+
Empty = 0, OpenStart = 1, OpenEnd = 2, LocalMax = 4, LocalMin = 8
4242
};
4343

4444
constexpr enum VertexFlags operator &(enum VertexFlags a, enum VertexFlags b)
@@ -55,7 +55,7 @@ namespace Clipper2Lib {
5555
Point64 pt;
5656
Vertex* next = nullptr;
5757
Vertex* prev = nullptr;
58-
VertexFlags flags = VertexFlags::None;
58+
VertexFlags flags = VertexFlags::Empty;
5959
};
6060

6161
struct OutPt {
@@ -131,7 +131,7 @@ namespace Clipper2Lib {
131131
Vertex* vertex_top = nullptr;
132132
LocalMinima* local_min = nullptr; // the bottom of an edge 'bound' (also Vatti)
133133
bool is_left_bound = false;
134-
JoinWith join_with = JoinWith::None;
134+
JoinWith join_with = JoinWith::NoJoin;
135135
};
136136

137137
struct LocalMinima {
@@ -197,7 +197,7 @@ namespace Clipper2Lib {
197197

198198
class ClipperBase {
199199
private:
200-
ClipType cliptype_ = ClipType::None;
200+
ClipType cliptype_ = ClipType::NoClip;
201201
FillRule fillrule_ = FillRule::EvenOdd;
202202
FillRule fillpos = FillRule::Positive;
203203
int64_t bot_y_ = 0;
@@ -210,7 +210,7 @@ namespace Clipper2Lib {
210210
std::vector<Vertex*> vertex_lists_;
211211
std::priority_queue<int64_t> scanline_list_;
212212
IntersectNodeList intersect_nodes_;
213-
HorzSegmentList horz_seg_list_;
213+
HorzSegmentList horz_seg_list_;
214214
std::vector<HorzJoin> horz_join_list_;
215215
void Reset();
216216
inline void InsertScanline(int64_t y);

CPP/Clipper2Lib/include/clipper2/clipper.export.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 16 August 2024 *
3+
* Date : 17 September 2024 *
44
* Website : http://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2024 *
66
* Purpose : This module exports the Clipper2 Library (ie DLL/so) *
@@ -10,7 +10,7 @@
1010

1111
/*
1212
Boolean clipping:
13-
cliptype: None=0, Intersection=1, Union=2, Difference=3, Xor=4
13+
cliptype: NoClip=0, Intersection=1, Union=2, Difference=3, Xor=4
1414
fillrule: EvenOdd=0, NonZero=1, Positive=2, Negative=3
1515
1616
Polygon offsetting (inflate/deflate):

CPP/Clipper2Lib/src/clipper.engine.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 27 April 2024 *
3+
* Date : 17 September 2024 *
44
* Website : http://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2024 *
66
* Purpose : This is the main polygon clipping module *
@@ -85,7 +85,7 @@ namespace Clipper2Lib {
8585
inline bool IsOpenEnd(const Vertex& v)
8686
{
8787
return (v.flags & (VertexFlags::OpenStart | VertexFlags::OpenEnd)) !=
88-
VertexFlags::None;
88+
VertexFlags::Empty;
8989
}
9090

9191

@@ -220,7 +220,7 @@ namespace Clipper2Lib {
220220

221221
inline bool IsMaxima(const Vertex& v)
222222
{
223-
return ((v.flags & VertexFlags::LocalMax) != VertexFlags::None);
223+
return ((v.flags & VertexFlags::LocalMax) != VertexFlags::Empty);
224224
}
225225

226226

@@ -235,12 +235,12 @@ namespace Clipper2Lib {
235235
if (e.wind_dx > 0)
236236
while ((result->next->pt.y == result->pt.y) &&
237237
((result->flags & (VertexFlags::OpenEnd |
238-
VertexFlags::LocalMax)) == VertexFlags::None))
238+
VertexFlags::LocalMax)) == VertexFlags::Empty))
239239
result = result->next;
240240
else
241241
while (result->prev->pt.y == result->pt.y &&
242242
((result->flags & (VertexFlags::OpenEnd |
243-
VertexFlags::LocalMax)) == VertexFlags::None))
243+
VertexFlags::LocalMax)) == VertexFlags::Empty))
244244
result = result->prev;
245245
if (!IsMaxima(*result)) result = nullptr; // not a maxima
246246
return result;
@@ -478,7 +478,7 @@ namespace Clipper2Lib {
478478

479479
inline bool IsJoined(const Active& e)
480480
{
481-
return e.join_with != JoinWith::None;
481+
return e.join_with != JoinWith::NoJoin;
482482
}
483483

484484
inline void SetOwner(OutRec* outrec, OutRec* new_owner)
@@ -608,7 +608,7 @@ namespace Clipper2Lib {
608608
Vertex& vert, PathType polytype, bool is_open)
609609
{
610610
//make sure the vertex is added only once ...
611-
if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::None) return;
611+
if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return;
612612

613613
vert.flags = (vert.flags | VertexFlags::LocalMin);
614614
list.push_back(std::make_unique <LocalMinima>(&vert, polytype, is_open));
@@ -643,7 +643,7 @@ namespace Clipper2Lib {
643643
}
644644
curr_v->prev = prev_v;
645645
curr_v->pt = pt;
646-
curr_v->flags = VertexFlags::None;
646+
curr_v->flags = VertexFlags::Empty;
647647
prev_v = curr_v++;
648648
cnt++;
649649
}
@@ -725,7 +725,7 @@ namespace Clipper2Lib {
725725
void ReuseableDataContainer64::AddLocMin(Vertex& vert, PathType polytype, bool is_open)
726726
{
727727
//make sure the vertex is added only once ...
728-
if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::None) return;
728+
if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return;
729729

730730
vert.flags = (vert.flags | VertexFlags::LocalMin);
731731
minima_list_.push_back(std::make_unique <LocalMinima>(&vert, polytype, is_open));
@@ -907,7 +907,7 @@ namespace Clipper2Lib {
907907
void ClipperBase::AddLocMin(Vertex& vert, PathType polytype, bool is_open)
908908
{
909909
//make sure the vertex is added only once ...
910-
if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::None) return;
910+
if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return;
911911

912912
vert.flags = (vert.flags | VertexFlags::LocalMin);
913913
minima_list_.push_back(std::make_unique <LocalMinima>(&vert, polytype, is_open));
@@ -932,7 +932,7 @@ namespace Clipper2Lib {
932932

933933
switch (cliptype_)
934934
{
935-
case ClipType::None:
935+
case ClipType::NoClip:
936936
return false;
937937
case ClipType::Intersection:
938938
switch (fillrule_)
@@ -1208,7 +1208,7 @@ namespace Clipper2Lib {
12081208

12091209
while (PopLocalMinima(bot_y, local_minima))
12101210
{
1211-
if ((local_minima->vertex->flags & VertexFlags::OpenStart) != VertexFlags::None)
1211+
if ((local_minima->vertex->flags & VertexFlags::OpenStart) != VertexFlags::Empty)
12121212
{
12131213
left_bound = nullptr;
12141214
}
@@ -1224,7 +1224,7 @@ namespace Clipper2Lib {
12241224
SetDx(*left_bound);
12251225
}
12261226

1227-
if ((local_minima->vertex->flags & VertexFlags::OpenEnd) != VertexFlags::None)
1227+
if ((local_minima->vertex->flags & VertexFlags::OpenEnd) != VertexFlags::Empty)
12281228
{
12291229
right_bound = nullptr;
12301230
}
@@ -2125,7 +2125,7 @@ namespace Clipper2Lib {
21252125
using_polytree_ = use_polytrees;
21262126
Reset();
21272127
int64_t y;
2128-
if (ct == ClipType::None || !PopScanline(y)) return true;
2128+
if (ct == ClipType::NoClip || !PopScanline(y)) return true;
21292129

21302130
while (succeeded_)
21312131
{
@@ -2789,14 +2789,14 @@ namespace Clipper2Lib {
27892789
{
27902790
if (e.join_with == JoinWith::Right)
27912791
{
2792-
e.join_with = JoinWith::None;
2793-
e.next_in_ael->join_with = JoinWith::None;
2792+
e.join_with = JoinWith::NoJoin;
2793+
e.next_in_ael->join_with = JoinWith::NoJoin;
27942794
AddLocalMinPoly(e, *e.next_in_ael, pt, true);
27952795
}
27962796
else
27972797
{
2798-
e.join_with = JoinWith::None;
2799-
e.prev_in_ael->join_with = JoinWith::None;
2798+
e.join_with = JoinWith::NoJoin;
2799+
e.prev_in_ael->join_with = JoinWith::NoJoin;
28002800
AddLocalMinPoly(*e.prev_in_ael, e, pt, true);
28012801
}
28022802
}

CPP/Tests/TestExportHeaders.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static bool CreatePolyPath64FromCPolyPath(CPolyPath64& v, PolyPath64& owner)
1515
{
1616
int64_t x = *v++, y = *v++;
1717
#ifdef USINGZ
18-
auto z = Reinterpret<z_type, int64_t>(*v++);
18+
z_type z = Reinterpret<z_type>(*v++);
1919
path.push_back(Point64(x, y, z));
2020
#else
2121
path.push_back(Point64(x, y));
@@ -48,7 +48,7 @@ static bool CreatePolyPathDFromCPolyPath(CPolyPathD& v, PolyPathD& owner)
4848
{
4949
double x = *v++, y = *v++;
5050
#ifdef USINGZ
51-
auto z = Reinterpret<z_type, double>(*v++);
51+
z_type z = Reinterpret<z_type>(*v++);
5252
path.push_back(PointD(x, y, z));
5353
#else
5454
path.push_back(PointD(x, y));

CPP/Tests/TestOffsets.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TEST(Clipper2Tests, TestOffsets) {
1212
ClipperOffset co;
1313
Paths64 subject, subject_open, clip;
1414
Paths64 solution, solution_open;
15-
ClipType ct = ClipType::None;
15+
ClipType ct = ClipType::NoClip;
1616
FillRule fr = FillRule::NonZero;
1717
int64_t stored_area = 0, stored_count = 0;
1818
ASSERT_TRUE(LoadTestNum(ifs, test_number, subject, subject_open, clip, stored_area, stored_count, ct, fr));

CPP/Tests/TestPolytreeHoles.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TEST(Clipper2Tests, TestPolytreeHoles1)
99
Paths64 subject, subject_open, clip;
1010
PolyTree64 solution;
1111
Paths64 solution_open;
12-
ClipType ct = ClipType::None;
12+
ClipType ct = ClipType::NoClip;
1313
FillRule fr = FillRule::EvenOdd;
1414
int64_t area = 0, count = 0;
1515
bool success = false;
@@ -61,7 +61,7 @@ TEST(Clipper2Tests, TestPolytreeHoles2)
6161
ASSERT_TRUE(ifs);
6262
ASSERT_TRUE(ifs.good());
6363
Paths64 subject, subject_open, clip;
64-
ClipType ct = ClipType::None;
64+
ClipType ct = ClipType::NoClip;
6565
FillRule fr = FillRule::EvenOdd;
6666
int64_t area = 0, count = 0;
6767
ASSERT_TRUE(LoadTestNum(ifs, 1, subject, subject_open, clip, area, count, ct, fr));

CPP/Utils/ClipFileSave.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Clipper2Lib {
1414
// Boyer Moore Horspool Search
1515
//------------------------------------------------------------------------------
1616

17-
class BMH_Search
17+
class BMH_Search
1818
{
1919
private:
2020
uint8_t case_table[256];
@@ -51,7 +51,7 @@ class BMH_Search
5151
}
5252

5353
void Init()
54-
{
54+
{
5555
case_sensitive_ = false;
5656
current = nullptr; end = nullptr; last_found = nullptr;
5757
}
@@ -85,7 +85,7 @@ class BMH_Search
8585
while (current < end)
8686
{
8787
uint8_t i = shift[case_table[static_cast<unsigned>(*current)]];
88-
if (!i)
88+
if (!i)
8989
{
9090
char* j = current - needle_len_less1;
9191
while (i < needle_len_less1 &&
@@ -107,7 +107,7 @@ class BMH_Search
107107

108108
public:
109109

110-
explicit BMH_Search(std::ifstream& stream,
110+
explicit BMH_Search(std::ifstream& stream,
111111
const std::string& needle = "")
112112
{
113113
//case blind table
@@ -121,7 +121,7 @@ class BMH_Search
121121
if (needle.size() > 0) SetNeedle(needle);
122122
}
123123

124-
BMH_Search(const char* haystack, size_t length,
124+
BMH_Search(const char* haystack, size_t length,
125125
const std::string& needle = "")
126126
{
127127
Init();
@@ -137,7 +137,7 @@ class BMH_Search
137137

138138
void Reset()
139139
{
140-
current = haystack_;
140+
current = haystack_;
141141
last_found = nullptr;
142142
}
143143

@@ -152,7 +152,7 @@ class BMH_Search
152152
needle_.clear();
153153
needle_.reserve(needle_len_);
154154
for (const char& c : needle) needle_.push_back(static_cast<uint8_t>(c));
155-
155+
156156
//case insensitive needle
157157
needle_ic_ = needle_;
158158
for (std::vector< uint8_t>::iterator ui = needle_ic_.begin(); ui != needle_ic_.end(); ++ui)
@@ -199,10 +199,10 @@ class BMH_Search
199199
inline size_t LastFoundOffset() { return last_found - haystack_; }
200200

201201
inline char* FindNextEndLine()
202-
{
202+
{
203203
current = last_found + needle_len_;
204-
while (current < end &&
205-
*current != char(13) && *current != char(10))
204+
while (current < end &&
205+
*current != char(13) && *current != char(10))
206206
++current;
207207
return current;
208208
}
@@ -212,7 +212,7 @@ class BMH_Search
212212

213213
void PathsToStream(const Paths64& paths, std::ostream& stream)
214214
{
215-
for (Paths64::const_iterator paths_it = paths.cbegin();
215+
for (Paths64::const_iterator paths_it = paths.cbegin();
216216
paths_it != paths.cend(); ++paths_it)
217217
{
218218
//watch out for empty paths
@@ -247,7 +247,7 @@ static bool GetInt(string::const_iterator& s_it,
247247
}
248248

249249
bool SaveTest(const std::string& filename, bool append,
250-
const Paths64* subj, const Paths64* subj_open, const Paths64* clip,
250+
const Paths64* subj, const Paths64* subj_open, const Paths64* clip,
251251
int64_t area, int64_t count, ClipType ct, FillRule fr)
252252
{
253253
string line;
@@ -267,8 +267,8 @@ bool SaveTest(const std::string& filename, bool append,
267267
string::const_iterator s_it = line.cbegin(), s_end = line.cend();
268268
GetInt(s_it, s_end, last_test_no);
269269
}
270-
}
271-
else if (FileExists(filename))
270+
}
271+
else if (FileExists(filename))
272272
remove(filename.c_str());
273273

274274
++last_test_no;
@@ -282,7 +282,7 @@ bool SaveTest(const std::string& filename, bool append,
282282
string cliptype_string;
283283
switch (ct)
284284
{
285-
case ClipType::None: cliptype_string = "NONE"; break;
285+
case ClipType::NoClip: cliptype_string = "NOCLIP"; break;
286286
case ClipType::Intersection: cliptype_string = "INTERSECTION"; break;
287287
case ClipType::Union: cliptype_string = "UNION"; break;
288288
case ClipType::Difference: cliptype_string = "DIFFERENCE"; break;

CSharp/Clipper2Lib/Clipper.Core.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 13 May 2024 *
3+
* Date : 17 September 2024 *
44
* Website : http://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2024 *
66
* Purpose : Core structures and functions for the Clipper Library *
@@ -532,7 +532,7 @@ public string ToString(int precision = 2)
532532
// Note: all clipping operations except for Difference are commutative.
533533
public enum ClipType
534534
{
535-
None,
535+
NoClip,
536536
Intersection,
537537
Union,
538538
Difference,

0 commit comments

Comments
 (0)