mirror of https://github.com/CGAL/cgal
Merge pull request #6376 from sloriot/Stream_support-fix_STL_binary
fix stl binary
This commit is contained in:
commit
78f9324d13
|
|
@ -84,7 +84,6 @@ bool read_STL(std::istream& is,
|
|||
)
|
||||
{
|
||||
const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false);
|
||||
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
||||
|
||||
if(!is.good())
|
||||
{
|
||||
|
|
@ -93,7 +92,6 @@ bool read_STL(std::istream& is,
|
|||
return false;
|
||||
}
|
||||
|
||||
int pos = 0;
|
||||
// Ignore all initial whitespace
|
||||
unsigned char c;
|
||||
|
||||
|
|
@ -104,23 +102,11 @@ bool read_STL(std::istream& is,
|
|||
is.unget(); // move back to the first interesting char
|
||||
break;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
|
||||
if(!is.good()) // reached the end
|
||||
return true;
|
||||
|
||||
// If we have gone beyond 80 characters and have not read anything yet,
|
||||
// then this must be an ASCII file.
|
||||
if(pos > 80)
|
||||
{
|
||||
if(binary)
|
||||
return false;
|
||||
return internal::parse_ASCII_STL(is, points, facets, verbose);
|
||||
}
|
||||
|
||||
// We are within the first 80 characters, both ASCII and binary are possible
|
||||
|
||||
// Read the 5 first characters to check if the first word is "solid"
|
||||
std::string s;
|
||||
|
||||
|
|
@ -133,7 +119,6 @@ bool read_STL(std::istream& is,
|
|||
is.read(reinterpret_cast<char*>(&word[5]), sizeof(c)))
|
||||
{
|
||||
s = std::string(word, 5);
|
||||
pos += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -79,8 +79,8 @@ int main(int argc, char** argv)
|
|||
assert(ok);
|
||||
std::cout << points.size() << " points and " << polygons.size() << " polygons" << std::endl;
|
||||
|
||||
if(argc == 0)
|
||||
assert(points.size() == 434 && polygons.size() == 864);
|
||||
if(argc == 1)
|
||||
assert(points.size() == 4 && polygons.size() == 4);
|
||||
|
||||
points.clear();
|
||||
polygons.clear();
|
||||
|
|
@ -129,6 +129,16 @@ int main(int argc, char** argv)
|
|||
|
||||
further_tests();
|
||||
|
||||
// issue 6374
|
||||
if(argc == 1)
|
||||
{
|
||||
points.clear();
|
||||
polygons.clear();
|
||||
bool ok = CGAL::IO::read_STL("data/binary-issue-6374.stl", points, polygons, CGAL::parameters::verbose(true));
|
||||
assert(ok);
|
||||
assert(points.size()==8 && polygons.size()==12);
|
||||
}
|
||||
|
||||
std::cout << "Done!" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue