示例#1
0
toxi::geom::Polygon2D * toxi::geom::Polygon2D::removeDuplicates( const float & tolerance )
{
	Vec2D prev;
	for (auto it = vertices.begin(); it != vertices.end(); ++it ) 
	{
		Vec2D p = *it;
		if (p.equalsWithTolerance(prev, tolerance)) 
		{
			vertices.erase( it );
			//iv.remove();
		} else {
			prev = p;
		}
	}
	int num = vertices.size();
	if (num > 0) {
		Vec2D last = vertices.at(num - 1);
		if (last.equalsWithTolerance(vertices.at(0), tolerance)) {
			//TODO: how to nicely remove things from a vector ffs?
			//vertices.remove(last);
		}
	}
	return this;
}