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

Boolean Path/Region Functions #3288

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/clipper-utils.cc
Expand Up @@ -91,6 +91,19 @@ namespace ClipperUtils {
return result;
}

int pointInRegion(const Polygon2d &polygon, double x, double y)
{
ClipperLib::IntPoint pt(x*CLIPPER_SCALE, y*CLIPPER_SCALE);
int result = 0;
for (const auto& oline : polygon.outlines()) {
int res = ClipperLib::PointInPolygon(pt, fromOutline2d(oline,true));
if (res < -1) return -1;
if (res > 0) result = 1 - result;
}
return result;
}


/*!
Apply the clipper operator to the given paths.

Expand Down
1 change: 1 addition & 0 deletions src/clipper-utils.h
Expand Up @@ -18,5 +18,6 @@ namespace ClipperUtils {
Polygon2d *applyMinkowski(const std::vector<const Polygon2d*> &polygons);
Polygon2d *apply(const std::vector<const Polygon2d*> &polygons, ClipperLib::ClipType);
Polygon2d *apply(const std::vector<ClipperLib::Paths> &pathsvector, ClipperLib::ClipType);
int pointInRegion(const Polygon2d &polygon, double x, double y);

};