Added the ability to limit the number of points loaded from a file

This commit is contained in:
Clement Jamin 2014-12-18 09:21:28 +01:00
parent 61c208a0d2
commit 68a4eb92af
1 changed files with 7 additions and 2 deletions

View File

@ -146,7 +146,8 @@ sparsify_point_set(
template<typename Point, typename OutputIterator>
bool load_points_from_file(
const std::string &filename, OutputIterator points)
const std::string &filename, OutputIterator points,
std::size_t only_first_n_points = std::numeric_limits<std::size_t>::max())
{
std::ifstream in(filename);
if (!in.is_open())
@ -159,8 +160,12 @@ bool load_points_from_file(
int dim_from_file;
in >> dim_from_file;
while(in >> p)
std::size_t i = 0;
while(i < only_first_n_points && in >> p)
{
*points++ = p;
++i;
}
return true;
}