// Create segments from the cut-outs convex points.
// A segment is only valid if its ray doesn't intersect with segment
// from the point before to the point after. (it's not pointing outside!)
populateNonConvexPoints(cutOut, false);
for(Vector2f point: nonConvexPoints) {
Line outside = nonConvexPointOutsideSegment.get(point);
for(Vector2f point2: cutOut) {
if( point2 != point &&
point2 != outside.getPoint(0) &&
point2 != outside.getPoint(1)) {
if(Geometry.raySegmentIntersect(point, point2, outside.getPoint(0), outside.getPoint(1)) == Intersection.FALSE) {
addSegment(point, point2);
}
}
}
}
// testing: draw concave and parallel cut-out points
// for(Vector2f point: nonConvexPoints) {
// renderer.drawPoint(point.x, point.y, 6f, new Color4f(1,0,0,1));
// }
// for(Vector2f point: nonConvexPointsParallel) {
// renderer.drawPoint(point.x, point.y, 6f, new Color4f(0,1,0,1));
// }
}
// Create segments from outline points making the TShape non-convex.
// A segment is only valid if its ray doesn't intersect with segment
// from the point before to the point after. (it's not pointing outside!)
populateNonConvexPoints(shape.getOutline(), true);
for(Vector2f point: nonConvexPoints) {
Line outside = nonConvexPointOutsideSegment.get(point);
for(Vector2f point2: shape.getOutline()) {
if( point2 != point &&
point2 != outside.getPoint(0) &&
point2 != outside.getPoint(1)) {
if(Geometry.raySegmentIntersect(point, point2, outside.getPoint(0), outside.getPoint(1)) == Intersection.FALSE) {
addSegment(point, point2);
}
}
}
}
// Handle redundant points
if(!removeRedundantPoints) {
// parallel points have not necessary been connected yet
// connect them to all common connected points of their pre- and successor
// if the connection does not already exist!
for(Vector2f vec: nonConvexPointsParallel) {
Line prepost = nonConvexPointOutsideSegment.get(vec);
List<Line> lines1 = segmentMap.get(prepost.getPoint(0));
List<Line> lines2 = segmentMap.get(prepost.getPoint(1));
for(Line line1: lines1) {
Vector2f point1 = line1.getPoint(0);
if(point1 == prepost.getPoint(0)) point1 = line1.getPoint(1);
for(Line line2: lines2) {
Vector2f point2 = line2.getPoint(0);
if(point2 == prepost.getPoint(1)) point2 = line2.getPoint(1);
if(point2 == point1) {
if(getLine(vec, point1) == null) {
addSegment(vec, point1);
}