-
Notifications
You must be signed in to change notification settings - Fork 29
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
Polygons with holes #13
Comments
Looks like you have negative speeds on the hole?
…On Sun, Mar 28, 2021 at 10:44 PM Michael Carleton ***@***.***> wrote:
yes it works with holes, they have to defined as a separate loop in a
backwards direction
I'm following this but I'm unable to get it to behave with holes. I've
tried every combination of exterior & interior coordinates direction.
Examples:
No hole
[image: image]
<https://user-images.githubusercontent.com/9304234/112768914-4cf90300-9016-11eb-8aff-1467786ff710.png>
Exterior loop CCW, interior loop CW
[image: exCCWinCW]
<https://user-images.githubusercontent.com/9304234/112768710-3605e100-9015-11eb-91fa-c9972a1926a5.gif>
Exterior loop CCW, interior loop CCW
[image: exCCWinCCW]
<https://user-images.githubusercontent.com/9304234/112768774-91d06a00-9015-11eb-9ae8-a0ccd8fdd2df.gif>
Exterior loop CW, interior loop CCW
[image: exCWinCCW]
<https://user-images.githubusercontent.com/9304234/112768870-03101d00-9016-11eb-8bf3-13d9ce1cc556.gif>
Exterior loop CW, interior loop CW
[image: exCWinCW]
<https://user-images.githubusercontent.com/9304234/112768900-3783d900-9016-11eb-9d9d-2c2d5251989d.gif>
Code
Polygon polygon;
Skeleton skeleton;
LoopL<org.twak.camp.Edge> loopL = new LoopL<>(); // list of loops
ArrayList<Corner> corners = new ArrayList<>();
Loop<org.twak.camp.Edge> loop = new Loop<>();
LinearRing exterior = polygon.getExteriorRing();
if (!Orientation.isCCW(exterior.getCoordinates())) {
exterior = exterior.reverse(); // exterior should be CCW
}
Coordinate[] coords = exterior.getCoordinates();
for (int j = 0; j < coords.length - 1; j++) {
double a = coords[j].x;
double b = coords[j].y;
corners.add(new Corner(a, b));
}
for (int j = 0; j < corners.size() - 1; j++) {
org.twak.camp.Edge edge = new org.twak.camp.Edge(corners.get(j),
corners.get((j + 1) % (corners.size() - 1)));
edge.machine = speed;
loop.append(edge);
}
loopL.add(loop);
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
corners = new ArrayList<>();
LinearRing hole = polygon.getInteriorRingN(i);
if (Orientation.isCCW(hole.getCoordinates())) {
hole = hole.reverse(); // holes should be clockwise
}
for (int j = 0; j < hole.getNumPoints() - 1; j++) {
corners.add(new Corner(hole.getCoordinates()[j].x, hole.getCoordinates()[j].y));
}
loop = new Loop<>();
for (int j = 0; j < corners.size() - 1; j++) {
org.twak.camp.Edge edge = new org.twak.camp.Edge(corners.get(j),
corners.get((j + 1) % (corners.size() - 1)));
edge.machine = speed;
loop.append(edge);
}
loopL.add(loop);
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#13>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA7DKQFBHCVEI5EQZXQLFLTF6WMBANCNFSM4Z6OPJ2Q>
.
|
Confirmed holes works. Code in WeightedPointEditorWithHoles. Closing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm following this but I'm unable to get it to behave with holes. I've tried every combination of exterior & interior coordinates directions. Examples:
No hole
Exterior loop CCW, interior loop (hole) CW
Exterior loop CCW, interior loop CCW
Exterior loop CW, interior loop CCW
Exterior loop CW, interior loop CW
Code
The text was updated successfully, but these errors were encountered: