private bool isLinearEdgeEnabled(PlanarGraphEdge edge, OverlayType operation, Polygon polygon, bool inverseArgs) { if (isAreaEdgeEnabled(edge, operation, polygon, inverseArgs)) return false; switch (operation) { case OverlayType.Intersection: return edge.Label.UsedByObject1 && (edge.Label.UsedByObject2 || polygon.ContainsPoint(edge.CenterPoint())); case OverlayType.Union: return edge.Label.UsedByObject1 && !polygon.ContainsPoint(edge.CenterPoint()); case OverlayType.Difference: return inverseArgs ? false : edge.Label.UsedByObject1 && !polygon.ContainsPoint(edge.CenterPoint()) && !edge.Label.UsedByObject2; case OverlayType.SymmetricDifference: return edge.Label.UsedByObject1 && !polygon.ContainsPoint(edge.CenterPoint()) && !edge.Label.UsedByObject2; } return false; }
private bool isAreaEdgeEnabled(PlanarGraphEdge edge, OverlayType operation, Polygon p1, Polygon p2) { bool usebyPolygon1 = edge.Label.UsedByObject1; bool usebyPolygon2 = edge.Label.UsedByObject2; switch (operation) { case OverlayType.Intersection: if (usebyPolygon1 && usebyPolygon2 && edge.OrientationInObject1 == edge.OrientationInObject2) return true; if ((usebyPolygon1 ^ usebyPolygon2)) if (usebyPolygon1) { if (p2.ContainsPoint(edge.CenterPoint())) return true; } else { if (p1.ContainsPoint(edge.CenterPoint())) return true; } break; case OverlayType.Union: if (usebyPolygon1 && usebyPolygon2 && edge.OrientationInObject1 == edge.OrientationInObject2) return true; if ((usebyPolygon1 ^ usebyPolygon2)) if (usebyPolygon1) { if (!p2.ContainsPoint(edge.CenterPoint())) return true; } else { if (!p1.ContainsPoint(edge.CenterPoint())) return true; } break; case OverlayType.Difference: if (usebyPolygon1 && usebyPolygon2 && edge.OrientationInObject1 != edge.OrientationInObject2) return true; if ((usebyPolygon1 ^ usebyPolygon2)) if (usebyPolygon1) { if (!p2.ContainsPoint(edge.CenterPoint())) return true; } else { if (p1.ContainsPoint(edge.CenterPoint())) return true; } break; case OverlayType.SymmetricDifference: if ((usebyPolygon1 ^ usebyPolygon2)) return true; break; } return false; }