Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ec7b67

Browse files
committed
Add "filled" kwarg to path_intersects_path
svn path=/trunk/matplotlib/; revision=6078
1 parent 926f623 commit 2ec7b67

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
2008-09-10 Add "filled" kwarg to Path.intersects_path and
2+
Path.intersects_bbox. - MGD
3+
14
2008-09-07 Changed full arrows slightly to avoid an xpdf rendering
25
problem reported by Friedrich Hagedorn. - JKS
36

4-
2008-09-07 Fix conversion of quadratic to cubic Bezier curves in PDF
7+
2008-09-07 Fix conversion of quadratic to cubic Bezier curves in PDF
58
and PS backends. Patch by Jae-Joon Lee. - JKS
69

710
2008-09-06 Added 5-point star marker to plot command - EF

lib/matplotlib/path.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,29 @@ def get_extents(self, transform=None):
242242
transform = transform.frozen()
243243
return Bbox(get_path_extents(self, transform))
244244

245-
def intersects_path(self, other):
245+
def intersects_path(self, other, filled=True):
246246
"""
247247
Returns *True* if this path intersects another given path.
248+
249+
*filled*, when True, treats the paths as if they were filled.
250+
That is, if one path completely encloses the other,
251+
:meth:`intersects_path` will return True.
248252
"""
249-
return path_intersects_path(self, other)
253+
return path_intersects_path(self, other, filled)
250254

251-
def intersects_bbox(self, bbox):
255+
def intersects_bbox(self, bbox, filled=True):
252256
"""
253257
Returns *True* if this path intersects a given
254258
:class:`~matplotlib.transforms.Bbox`.
259+
260+
*filled*, when True, treats the path as if it was filled.
261+
That is, if one path completely encloses the other,
262+
:meth:`intersects_path` will return True.
255263
"""
256264
from transforms import BboxTransformTo
257265
rectangle = self.unit_rectangle().transformed(
258266
BboxTransformTo(bbox))
259-
result = self.intersects_path(rectangle)
267+
result = self.intersects_path(rectangle, filled)
260268
return result
261269

262270
def interpolated(self, steps):

src/_path.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,14 +1081,22 @@ bool path_intersects_path(PathIterator& p1, PathIterator& p2)
10811081

10821082
Py::Object _path_module::path_intersects_path(const Py::Tuple& args)
10831083
{
1084-
args.verify_length(2);
1084+
args.verify_length(2, 3);
10851085

10861086
PathIterator p1(args[0]);
10871087
PathIterator p2(args[1]);
1088+
bool filled = false;
1089+
if (args.size() == 3) {
1090+
filled = args[2].isTrue();
1091+
}
10881092

1089-
return Py::Int(::path_intersects_path(p1, p2)
1090-
|| ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine())
1091-
|| ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine()));
1093+
if (!filled) {
1094+
return Py::Int(::path_intersects_path(p1, p2));
1095+
} else {
1096+
return Py::Int(::path_intersects_path(p1, p2)
1097+
|| ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine())
1098+
|| ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine()));
1099+
}
10921100
}
10931101

10941102
void _add_polygon(Py::List& polygons, const std::vector<double>& polygon) {

0 commit comments

Comments
 (0)