skip comments while reading off files

This commit is contained in:
Sébastien Loriot 2014-12-18 08:40:48 +01:00
parent e3ba8201c7
commit 7e0b5a3fe6
3 changed files with 15 additions and 2 deletions

View File

@ -13,7 +13,7 @@ typedef CGAL::Surface_mesh<Point> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
int main(int argc, char* argv[])
int main(int, char* argv[])
{
Mesh P;
//std::cin >> P;

View File

@ -2134,7 +2134,18 @@ private: //------------------------------------------------------- private data
os << "\n";
}
return os;
}
}
inline std::istream& sm_skip_comments( std::istream& in) {
char c;
in >> c;
if (c == '#')
in.ignore((std::numeric_limits<std::streamsize>::max)(), '\n');
else
in.putback(c);
return in;
}
/// \relates Surface_mesh
/// Extracts the surface mesh from an input stream in Ascii OFF format.
/// The operator only reads the point property and does not read files
@ -2154,6 +2165,7 @@ private: //------------------------------------------------------- private data
sm.reserve(n,2*f,e);
P p;
for(int i=0; i < n; i++){
is >> sm_skip_comments;
is >> p;
sm.add_vertex(p);
is.ignore((std::numeric_limits<std::streamsize>::max)(), '\n');
@ -2161,6 +2173,7 @@ private: //------------------------------------------------------- private data
std::vector<size_type> vr;
std::size_t d;
for(std::size_t i=0; i < f; i++){
is >> sm_skip_comments;
is >> d;
vr.resize(d);
for(std::size_t j=0; j<d; j++){