Skip to content

Commit cffc9bd

Browse files
committed
improve getPolyPoints
- sample points based off length
1 parent e56db1a commit cffc9bd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

PyRxCore/PyDbEnts.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,18 +2430,21 @@ static auto getPolyPoints(const AcGeCompositeCurve3d& cc) -> AcGePoint3dArray
24302430
cc.getCurveList(curveList);
24312431
for (const auto* pvoid : curveList)
24322432
{
2433+
if (pvoid == nullptr)
2434+
return polypoints;
24332435
AcGeEntity3d* pItem = (AcGeEntity3d*)pvoid;
24342436
if (pItem->type() == AcGe::kLineSeg3d)
24352437
{
2436-
auto tmp = static_cast<AcGeLineSeg3d*>(pItem);
2438+
const auto tmp = static_cast<AcGeLineSeg3d*>(pItem);
24372439
polypoints.append(tmp->startPoint());
24382440
polypoints.append(tmp->endPoint());
24392441
}
24402442
else if (pItem->type() == AcGe::kCircArc3d)
24412443
{
2442-
auto tmp = static_cast<AcGeCircArc3d*>(pItem);
2444+
const auto tmp = static_cast<AcGeCircArc3d*>(pItem);
24432445
AcGePoint3dArray samplePnts;
2444-
tmp->getSamplePoints(100, samplePnts);
2446+
const auto len = size_t(tmp->length(0, 1)) +1;
2447+
tmp->getSamplePoints(len * 20, samplePnts);
24452448
for (const auto& pnt : samplePnts)
24462449
polypoints.append(pnt);
24472450
}
@@ -2950,8 +2953,12 @@ boost::python::list PyDbPolyline::toList() const
29502953
bool PyDbPolyline::isPointInside(const AcGePoint3d& pnt) const
29512954
{
29522955
auto plineClone = shallowClone(*impObj());
2956+
if (plineClone == nullptr)
2957+
PyThrowBadEs(eNullPtr);
29532958
plineClone->setClosed(true);
29542959
auto cc = getCompositCurve(*plineClone);
2960+
if (cc == nullptr)
2961+
PyThrowBadEs(eNullPtr);
29552962
return isPointInPolygon(getPolyPoints(*cc), pnt);
29562963
}
29572964

0 commit comments

Comments
 (0)