mirror of https://github.com/CGAL/cgal
Misc minor enhancements
This commit is contained in:
parent
25f5b91de5
commit
862f3ee4f9
|
|
@ -138,7 +138,7 @@ bool read_OFF(std::istream& is,
|
||||||
if (line.empty () || line[0] == '#')
|
if (line.empty () || line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
lineNumber++;
|
++lineNumber;
|
||||||
|
|
||||||
// Reads file signature on first line
|
// Reads file signature on first line
|
||||||
if (lineNumber == 1)
|
if (lineNumber == 1)
|
||||||
|
|
@ -150,13 +150,12 @@ bool read_OFF(std::istream& is,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads number of points on 2nd line
|
// Reads number of points on 2nd line
|
||||||
else if (lineNumber == 2)
|
else if (lineNumber == 2)
|
||||||
{
|
{
|
||||||
if ( !(iss >> pointsCount >> facesCount >> edgesCount) )
|
if ( !(iss >> pointsCount >> facesCount >> edgesCount) )
|
||||||
{
|
{
|
||||||
std::cerr << "Error line " << lineNumber << " of file" << std::endl;
|
std::cerr << "Error line " << lineNumber << " of file (incorrect header format)" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -179,7 +178,7 @@ bool read_OFF(std::istream& is,
|
||||||
if(iss >> IO::iformat(ny) >> IO::iformat(nz)){
|
if(iss >> IO::iformat(ny) >> IO::iformat(nz)){
|
||||||
normal = Vector(FT(nx),FT(ny),FT(nz));
|
normal = Vector(FT(nx),FT(ny),FT(nz));
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Error line " << lineNumber << " of file" << std::endl;
|
std::cerr << "Error line " << lineNumber << " of file (incomplete normal coordinates)" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -193,17 +192,16 @@ bool read_OFF(std::istream& is,
|
||||||
put(point_map, pwn, point); // point_map[&pwn] = point
|
put(point_map, pwn, point); // point_map[&pwn] = point
|
||||||
if (has_normals)
|
if (has_normals)
|
||||||
put(normal_map, pwn, normal); // normal_map[&pwn] = normal
|
put(normal_map, pwn, normal); // normal_map[&pwn] = normal
|
||||||
*output++ = pwn;
|
|
||||||
pointsRead++;
|
|
||||||
|
|
||||||
|
*output++ = pwn;
|
||||||
|
++pointsRead;
|
||||||
}
|
}
|
||||||
// ...or skip comment line
|
|
||||||
}
|
}
|
||||||
// Skip remaining lines
|
|
||||||
}
|
}
|
||||||
if(is.eof()) {
|
|
||||||
|
if(is.eof())
|
||||||
is.clear(is.rdstate() & ~std::ios_base::failbit); // set by getline
|
is.clear(is.rdstate() & ~std::ios_base::failbit); // set by getline
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,35 +139,37 @@ bool read_XYZ(std::istream& is,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// ...or reads position...
|
// ...or reads position...
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
iss.clear();
|
iss.clear();
|
||||||
iss.str(line);
|
iss.str(line);
|
||||||
if (iss >> iformat(x) >> iformat(y) >> iformat(z))
|
if (iss >> iformat(x) >> iformat(y) >> iformat(z))
|
||||||
|
{
|
||||||
|
Point point(x,y,z);
|
||||||
|
Vector normal = CGAL::NULL_VECTOR;
|
||||||
|
// ... + normal...
|
||||||
|
if (iss >> iformat(nx))
|
||||||
{
|
{
|
||||||
Point point(x,y,z);
|
// In case we could read one number, we expect that there are two more
|
||||||
Vector normal = CGAL::NULL_VECTOR;
|
if(iss >> iformat(ny) >> iformat(nz)){
|
||||||
// ... + normal...
|
normal = Vector(nx,ny,nz);
|
||||||
if (iss >> iformat(nx))
|
} else {
|
||||||
{
|
std::cerr << "Error line " << lineNumber << " of file (incomplete normal coordinates)" << std::endl;
|
||||||
// In case we could read one number, we expect that there are two more
|
return false;
|
||||||
if(iss >> iformat(ny) >> iformat(nz)){
|
}
|
||||||
normal = Vector(nx,ny,nz);
|
|
||||||
} else {
|
|
||||||
std::cerr << "Error line " << lineNumber << " of file" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Enriched_point pwn;
|
|
||||||
put(point_map, pwn, point); // point_map[pwn] = point
|
|
||||||
|
|
||||||
if (has_normals)
|
|
||||||
put(normal_map, pwn, normal); // normal_map[pwn] = normal
|
|
||||||
|
|
||||||
*output++ = pwn;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Enriched_point pwn;
|
||||||
|
put(point_map, pwn, point); // point_map[pwn] = point
|
||||||
|
|
||||||
|
if (has_normals)
|
||||||
|
put(normal_map, pwn, normal); // normal_map[pwn] = normal
|
||||||
|
|
||||||
|
*output++ = pwn;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...or skips number of points on first line (optional)
|
// ...or skips number of points on first line (optional)
|
||||||
if (lineNumber == 1 && std::istringstream(line) >> pointsCount)
|
if (lineNumber == 1 && std::istringstream(line) >> pointsCount)
|
||||||
{
|
{
|
||||||
|
|
@ -175,13 +177,13 @@ bool read_XYZ(std::istream& is,
|
||||||
}
|
}
|
||||||
else // if wrong file format
|
else // if wrong file format
|
||||||
{
|
{
|
||||||
std::cerr << "Error line " << lineNumber << " of file" << std::endl;
|
std::cerr << "Error line " << lineNumber << " of file (expected point coordinates)" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(is.eof()) {
|
|
||||||
|
if(is.eof())
|
||||||
is.clear(is.rdstate() & ~std::ios_base::failbit); // set by getline
|
is.clear(is.rdstate() & ~std::ios_base::failbit); // set by getline
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue