本文整理汇总了C++中m2::RectD::IsRectInside方法的典型用法代码示例。如果您正苦于以下问题:C++ RectD::IsRectInside方法的具体用法?C++ RectD::IsRectInside怎么用?C++ RectD::IsRectInside使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类m2::RectD
的用法示例。
在下文中一共展示了RectD::IsRectInside方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClipSplineByRect
vector<m2::SharedSpline> ClipSplineByRect(m2::RectD const & rect, m2::SharedSpline const & spline)
{
vector<m2::SharedSpline> result;
vector<m2::PointD> const & path = spline->GetPath();
if (path.size() < 2)
return result;
m2::RectD splineRect;
for (m2::PointD const & p : path)
splineRect.Add(p);
// Check for spline is inside.
if (rect.IsRectInside(splineRect))
{
result.push_back(spline);
return result;
}
// Check for spline is outside.
if (!rect.IsIntersect(splineRect))
return result;
// Divide spline into parts.
result.reserve(2);
m2::PointD p1, p2;
int code1 = 0;
int code2 = 0;
m2::SharedSpline s;
s.Reset(new m2::Spline(path.size()));
for (size_t i = 0; i < path.size() - 1; i++)
{
p1 = path[i];
p2 = path[i + 1];
if (m2::Intersect(rect, p1, p2, code1, code2))
{
if ((p1 - p2).IsAlmostZero())
continue;
if (s.IsNull())
s.Reset(new m2::Spline(path.size() - i));
s->AddPoint(p1);
if (code2 != 0 || i + 2 == path.size())
{
s->AddPoint(p2);
result.push_back(s);
s.Reset(nullptr);
}
}
}
return result;
}
示例2: IsIntersectedByRegionImpl
vector<TCountryId> CountryInfoGetter::GetRegionsCountryIdByRect(m2::RectD const & rect) const
{
size_t constexpr kAverageSize = 10;
vector<TCountryId> result;
result.reserve(kAverageSize);
for (size_t id = 0; id < m_countries.size(); ++id)
{
if (rect.IsRectInside(m_countries[id].m_rect) ||
(rect.IsIntersect(m_countries[id].m_rect) && IsIntersectedByRegionImpl(id, rect)))
{
result.push_back(m_countries[id].m_countryId);
}
}
return result;
}