本文整理汇总了C++中Mapping::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Mapping::begin方法的具体用法?C++ Mapping::begin怎么用?C++ Mapping::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapping
的用法示例。
在下文中一共展示了Mapping::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: within
inline bool within(const Point & point, const Poly & poly, const Mapping & mapping, const S & ieps)
{
auto i = std::lower_bound(mapping.begin(), mapping.end(), point.y, detail::CmpY<decltype(*mapping.begin())>());
if(i == mapping.begin())
{
if(ieps < 0 || point.y < i->y - ieps)
return false;
return onEdge(point, poly, i->edges, ieps);
}
if(i == mapping.end())
{
if(ieps < 0)
return false;
--i;
if(point.y > i->y + ieps)
return false;
if(!i->edges.empty() && onEdge(point, poly, i->edges, ieps))
return true;
--i;
return onEdge(point, poly, i->edges, ieps);
}
S eps = std::abs(ieps);
if(i->y - point.y < eps)
{
if(onEdge(point, poly, i->edges, eps))
return ieps > 0;
}
--i;
if(onEdge(point, poly, i->edges, eps))
return ieps > 0;
bool result = false;
for(auto j = i->edges.begin(), jend = i->edges.end(); j != jend; ++j)
{
auto & p1 = poly[*j];
auto & p2 = *j == 0 ? poly.back() : poly[*j - 1];
auto d = p2.y - p1.y;
if(std::abs(d) > eps)
{
auto t = (point.y - p1.y) / d;
if(point.x + eps > p1.x + (p2.x - p1.x) * t)
result = !result;
}
}
return result;
}
示例2: openSubArchive
Archive* Archive::openSubArchive(const std::string& name)
{
Mapping* mapping = findMapping(name);
Archive* archive = 0;
if(mapping->isValid()){
archive = dynamic_cast<Archive*>(mapping);
}
if(!archive){
archive = new Archive();
archive->inheritSharedInfoFrom(*this);
if(mapping->isValid()){
Mapping::const_iterator p = mapping->begin();
while(p != mapping->end()){
archive->insert(p->first, p->second);
++p;
}
}
insert(name, archive);
}
return archive;
}