Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lycantropos committed May 29, 2023
1 parent 84ada2e commit 0786664
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
23 changes: 12 additions & 11 deletions sect/core/delaunay/triangulation.py
Expand Up @@ -289,9 +289,9 @@ def detect_crossings(inner_edges: Iterable[QuadEdge],
if segments_relater(edge, constraint) is Relation.CROSS]


def edge_should_be_swapped(edge: QuadEdge,
point_in_circle_locator: PointInCircleLocator
) -> bool:
def edge_should_be_swapped(
edge: QuadEdge, point_in_circle_locator: PointInCircleLocator
) -> bool:
return (is_convex_quadrilateral_diagonal(edge)
and (point_in_circle_locator(edge.right_from_start.end,
edge.start, edge.end,
Expand Down Expand Up @@ -381,9 +381,9 @@ def to_edges(triangulation: Triangulation) -> Iterable[QuadEdge]:
return edges_with_opposites(to_unique_edges(triangulation))


def to_left_candidate(base_edge: QuadEdge,
point_in_circle_locator: PointInCircleLocator
) -> Optional[QuadEdge]:
def to_left_candidate(
base_edge: QuadEdge, point_in_circle_locator: PointInCircleLocator
) -> Optional[QuadEdge]:
result = base_edge.opposite.left_from_start
if base_edge.orientation_of(result.end) is not Orientation.CLOCKWISE:
return None
Expand All @@ -398,9 +398,9 @@ def to_left_candidate(base_edge: QuadEdge,
return result


def to_right_candidate(base_edge: QuadEdge,
point_in_circle_locator: PointInCircleLocator
) -> Optional[QuadEdge]:
def to_right_candidate(
base_edge: QuadEdge, point_in_circle_locator: PointInCircleLocator
) -> Optional[QuadEdge]:
result = base_edge.right_from_start
if (base_edge.orientation_of(result.end)
is not Orientation.CLOCKWISE):
Expand All @@ -416,8 +416,9 @@ def to_right_candidate(base_edge: QuadEdge,
return result


def to_unique_boundary_edges(triangulation: Triangulation
) -> Iterable[QuadEdge]:
def to_unique_boundary_edges(
triangulation: Triangulation
) -> Iterable[QuadEdge]:
start = triangulation.left_side
edge = start
while True:
Expand Down
48 changes: 26 additions & 22 deletions sect/core/delaunay/utils.py
Expand Up @@ -26,11 +26,12 @@ def ceil_log2(number: int) -> int:
return number.bit_length() - (not (number & (number - 1)))


def complete_vertices(border: Contour,
holes: Sequence[Contour],
candidates: Sequence[Point],
context: Context
) -> Tuple[Contour, Sequence[Contour], Sequence[Point]]:
def complete_vertices(
border: Contour,
holes: Sequence[Contour],
candidates: Sequence[Point],
context: Context
) -> Tuple[Contour, Sequence[Contour], Sequence[Point]]:
candidates = sorted(to_distinct(candidates))
contour_cls, segment_cls, segment_point_relater = (
context.contour_cls, context.segment_cls,
Expand All @@ -50,11 +51,12 @@ def complete_vertices(border: Contour,
return border, completed_holes, candidates


def contour_to_oriented_edges_endpoints(contour: Contour,
*,
clockwise: bool,
orienteer: Orienteer
) -> Iterable[SegmentEndpoints]:
def contour_to_oriented_edges_endpoints(
contour: Contour,
*,
clockwise: bool,
orienteer: Orienteer
) -> Iterable[SegmentEndpoints]:
vertices = contour.vertices
return (((vertices[index - 1], vertices[index])
for index in range(len(vertices)))
Expand All @@ -78,12 +80,13 @@ def normalize_contour_vertices(vertices: Sequence[Point],
to_distinct = dict.fromkeys


def _complete_contour_vertices(contour: Contour,
candidates: Sequence[Point],
contour_cls: Type[Contour],
segment_cls: Type[Segment],
containment_checker: SegmentContainmentChecker
) -> Tuple[Contour, Sequence[Point]]:
def _complete_contour_vertices(
contour: Contour,
candidates: Sequence[Point],
contour_cls: Type[Contour],
segment_cls: Type[Segment],
containment_checker: SegmentContainmentChecker
) -> Tuple[Contour, Sequence[Point]]:
extra_vertices = {}
vertices = contour.vertices
start = vertices[-1]
Expand Down Expand Up @@ -120,12 +123,13 @@ def _complete_contour_vertices(contour: Contour,
return contour, candidates


def _is_inner_segment_point(start: Point,
end: Point,
point: Point,
segment_cls: Type[Segment],
containment_checker: SegmentContainmentChecker
) -> bool:
def _is_inner_segment_point(
start: Point,
end: Point,
point: Point,
segment_cls: Type[Segment],
containment_checker: SegmentContainmentChecker
) -> bool:
return (point != start and point != end
and containment_checker(segment_cls(start, end), point))

Expand Down

0 comments on commit 0786664

Please sign in to comment.