Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not freak out if an input polygon is empty #465

Merged
merged 2 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CPP/Clipper2Lib/src/clipper.engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ namespace Clipper2Lib {
//for each path create a circular double linked list of vertices
Vertex* v0 = v, * curr_v = v, * prev_v = nullptr;

if (path.empty())
continue;

v->prev = nullptr;
int cnt = 0;
for (const Point64& pt : path)
Expand Down
2 changes: 1 addition & 1 deletion CPP/Tests/TestRandomPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Clipper2Lib::Paths64 GenerateRandomPaths(std::default_random_engine& rng, int mi

for (int path = 0; path < path_count; ++path)
{
const int min_point_count = 3;
const int min_point_count = 0;
const int path_length = GenerateRandomInt(rng, min_point_count, std::max(min_point_count, max_complexity));
auto& result_path = result[path];
result_path.reserve(path_length);
Expand Down