本文整理汇总了C++中Polygon_2::vertices_circulator方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon_2::vertices_circulator方法的具体用法?C++ Polygon_2::vertices_circulator怎么用?C++ Polygon_2::vertices_circulator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon_2
的用法示例。
在下文中一共展示了Polygon_2::vertices_circulator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_collinear
Polygon_2 remove_collinear(const Polygon_2& p, Number_type epsilon)
{
static log4cplus::Logger logger = log4cplus::Logger::getInstance("polygon_utils.remove_collinear");
LOG4CPLUS_TRACE(logger, pp(p));
if (!p.is_simple()) {
stringstream ss;
ss << "Polygon is not simple in remove_collinear: " << pp(p);
throw logic_error(ss.str());
}
Polygon_2::Vertex_circulator start = p.vertices_circulator();
Polygon_2::Vertex_circulator c = start;
Polygon_2::Vertex_circulator n = c;
Polygon_2::Vertex_circulator prev = c;
++n;
--prev;
Polygon_2 newp;
do
{
Triangle_2 t(*prev, *c, *n);
Number_type a = abs(t.area());
if (a > epsilon)
// if (!CGAL::collinear(*prev, *c, *n))
newp.push_back(*c);
else
LOG4CPLUS_TRACE(logger, "Removing collinearity at " << pp(*c) << " area = " << a);
++prev;
++c;
++n;
} while (c != start);
return newp;
}
示例2: centre
static Point_2 centroid(const Polygon_2& poly)
{
assert(poly.size() >= 3);
Polygon_2::Vertex_circulator vcir = poly.vertices_circulator();
Polygon_2::Vertex_circulator vend = vcir;
Polygon_2::Vertex_circulator vnext = vcir; ++vnext;
Vector_2 centre(0, 0);
NT a(0), asum(0);
do {
a = (vcir->x() * vnext->y()) - (vnext->x() * vcir->y());
centre = centre + a * ((*vcir - CGAL::ORIGIN) + (*vnext - CGAL::ORIGIN)); // slow...
asum += a;
vcir = vnext;
++vnext;
} while(vcir != vend);
centre = centre / (asum * 3);
return CGAL::ORIGIN + centre;
}
示例3: is_strictly_convex
bool is_strictly_convex(const Polygon_2& polygon,
const boost::unordered_map<Point_3, boost::unordered_set<Segment_3_undirected> >& point2edges)
{
Polygon_2::Vertex_circulator start = polygon.vertices_circulator();
Polygon_2::Vertex_circulator c = start;
Polygon_2::Vertex_circulator p = c;
Polygon_2::Vertex_circulator n = c;
--p;
++n;
do
{
if (!CGAL::left_turn(*p, *c, *n) ||
!is_legal(*p, *c, *n, point2edges))
return false;
++p;
++c;
++n;
} while (c != start);
return true;
}