c++11
Don Bright 2014-02-17 14:19:12 -06:00
parent e66e1691a9
commit 6326aab677
6 changed files with 24 additions and 6 deletions

View File

@ -226,7 +226,6 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const
std::string line;
std::getline(f, line);
while (!f.eof()) {
std::getline(f, line);
boost::trim(line);
if (boost::regex_search(line, ex_sfe)) {
@ -257,7 +256,7 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const
}
}
}
else
else if (binary && !f.eof())
{
f.ignore(80-5+4);
while (1) {
@ -283,10 +282,12 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const
else {
file >> poly;
file.close();
p = new PolySet();
bool err = createPolySetFromPolyhedron(poly, *p);
if (err) delete p;
if (err) {
delete p;
p = NULL;
}
}
#else
PRINT("WARNING: OFF import requires CGAL.");
@ -301,11 +302,17 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const
dxf_tesselate(p, dd, 0, Vector2d(1,1), true, false, 0);
dxf_border_to_ps(p, dd);
}
else
else
{
PRINTB("ERROR: Unsupported file format while trying to import file '%s'", this->filename);
}
if (p && p->empty()) {
delete p;
p = NULL;
}
if (p) p->convexity = this->convexity;
return p;
}

6
testdata/scad/bugs/empty-stl.scad vendored Normal file
View File

@ -0,0 +1,6 @@
// openscad should exit normally.
// it should not crash and/or freeze and/or gobble RAM
import("../../stl/empty.stl");
import("../../stl/empty2.stl");
echo("empty stl test ok");

0
testdata/stl/empty.stl vendored Normal file
View File

3
testdata/stl/empty2.stl vendored Normal file
View File

@ -0,0 +1,3 @@
solid OpenSCAD_Model
endsolid OpenSCAD_Model

View File

@ -824,7 +824,8 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/expression-shortcircuit-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/parent_module-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/children-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/range-tests.scad)
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/range-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/empty-stl.scad)
list(APPEND DUMPTEST_FILES ${FEATURES_FILES} ${EXAMPLE_FILES})
list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad

View File

@ -0,0 +1 @@
ECHO: "empty stl test ok"