Skip to content

Commit

Permalink
rebase and compare with fast-fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Esser50K committed Mar 26, 2023
1 parent 1ee0cc1 commit e4090e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions svgpathtools/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,7 @@ def seg2lines(seg_):
bezier_path_approximation.append(seg)
return area_without_arcs(Path(*bezier_path_approximation))

def intersect(self, other_curve, use_quadtree_lookup=True, justonemode=False, tol=1e-12):
def intersect(self, other_curve, use_quadtree_lookup=False, justonemode=False, tol=1e-12):
"""Finds intersections of `self` with `other_curve`
Args:
Expand Down Expand Up @@ -3488,12 +3488,12 @@ def insert_path(self, path: Path):
def _get_segments_in_area(self, area: Rect, out=None) -> list[PathSegment]:
"""returns a list of PathSegments that are present in the specified area"""
if out is None:
out = list()
out = set()

if not self.boundary.overlaps(area):
return out

out.extend(self._path_segments)
out = set(self._path_segments)
if self._is_split:
out = out.union(self._subtreeNE._get_segments_in_area(area, out))
out = out.union(self._subtreeNW._get_segments_in_area(area, out))
Expand Down
18 changes: 12 additions & 6 deletions test/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ def test_random_intersections(self):
r = Random()
distance = 100
distribution = 10000
count = 500
count = 2000

def random_complex(offset_x=0.0, offset_y=0.0):
return complex(r.random() * distance + offset_x, r.random() * distance + offset_y)
Expand Down Expand Up @@ -1534,11 +1534,17 @@ def random_path():
return path

path1 = random_path()
path2 = random_path()
t = time.time()
intersections = path1.intersect(path2)
print("\nFound {} intersections in {} seconds.\n"
"".format(len(intersections), time.time() - t))
for i in range(10):
path2 = random_path()
t = time.time()
intersections = path1.intersect(path2)
print("\nFound {} intersections in {} seconds.\n"
"".format(len(intersections), time.time() - t))

t = time.time()
intersections = path1.intersect(path2, use_quadtree_lookup=False)
print("\nFound {} intersections in {} seconds without quadtree.\n"
"".format(len(intersections), time.time() - t))

def test_line_line_0(self):
l0 = Line(start=(25.389999999999997+99.989999999999995j),
Expand Down

0 comments on commit e4090e0

Please sign in to comment.