Skip to content

Commit 6384d69

Browse files
committed
added Extents2d.contains (point2d)
1 parent 42e5a2a commit 6384d69

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

PyRxCore/PyAcDb.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ static AcGePoint2d AcDbExtents2dMidPoint(const AcDbExtents2d& extents)
122122
return seg.midPoint();
123123
}
124124

125+
static bool AcDbExtents2dContains(const AcDbExtents2d& extents, AcGePoint2d pnt)
126+
{
127+
auto min = extents.minPoint();
128+
auto max = extents.maxPoint();
129+
return min.x <= pnt.x && min.y <= pnt.y && max.x >= pnt.x && max.y >= pnt.y;
130+
}
131+
125132
void makePyDbExtents2dWrapper()
126133
{
127134
constexpr const std::string_view ctords = "Overloads:\n"
@@ -143,6 +150,7 @@ void makePyDbExtents2dWrapper()
143150
.def("transformBy", &AcDbExtents2d::transformBy, DS.ARGS({ "xform: PyGe.Matrix2d" }, 4525))
144151
.def("intersectsWith", &AcDbExtents2dIntersects, DS.ARGS({ "ex: PyDb.Extents2d" }))
145152
.def("coords", &AcDbExtents2dCoords, DS.ARGS())
153+
.def("contains", &AcDbExtents2dContains, DS.ARGS({ "pt: PyGe.Point2d" }))
146154
.def("__str__", &AcDbExtents2dToString, DS.ARGS())
147155
.def("__repr__", &AcDbExtents2dToStringRepr, DS.ARGS())
148156
;

PyRxStubs/PyDb.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9010,6 +9010,9 @@ class Extents2d(object):
90109010
def addPoints (self, pts: list[PyGe.Point2d])-> None :
90119011
'''Updates the extents to include point.'''
90129012
...
9013+
def contains (self, pt: PyGe.Point2d)-> bool :
9014+
''' '''
9015+
...
90139016
def coords (self)-> tuple[float,...] :
90149017
''' '''
90159018
...

0 commit comments

Comments
 (0)