From ec41b7e4321986140bffdb87ca7efefb1d57f881 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 13:01:10 -0500 Subject: move failure-detection so there is only one reset of error behavior. diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 225ff05..6ff1e35 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -104,10 +104,10 @@ public: *(output_nefpoly2d) *= *(tmpnef2d); } - log << "\n\n" - << OpenSCAD::dump_svg( *tmpnef2d ) << "\n" - << "\n\n" - << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n"; + log << "\n\n" + << OpenSCAD::dump_svg( *tmpnef2d ) << "\n" + << "\n\n" + << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n"; contour_counter++; } else { @@ -176,17 +176,10 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node during bigbox intersection: %s", e.what()); - sum.reset(); + sum.p3.reset( new CGAL_Nef_polyhedron3() ); } } - CGAL::set_error_behaviour(old_behaviour); - - if (sum.empty()) { - PRINT("WARNING: Projection failed."); - return NULL; - } - // remove z coordinates to make CGAL_Nef_polyhedron2 log << OpenSCAD::svg_header( 480, 100000 ) << "\n"; try { @@ -204,16 +197,20 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } log << "\n"; } - log << "\n"; - nef_poly.p2 = zremover.output_nefpoly2d; nef_poly.dim = 2; } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node while flattening: %s", e.what()); } + log << "\n"; CGAL::set_error_behaviour(old_behaviour); + if ( sum.p3->is_empty() ) { + PRINT("WARNING: projection() failed."); + return NULL; + } + // Extract polygons in the XY plane, ignoring all other polygons // FIXME: If the polyhedron is really thin, there might be unwanted polygons // in the XY plane, causing the resulting 2D polygon to be self-intersection diff --git a/src/svg.cc b/src/svg.cc index f30e4b8..cbc5695 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -8,10 +8,10 @@ namespace OpenSCAD { // SVG code // currently for debugging, not necessarily pretty or useful for users. (yet) -std::string svg_header() +std::string svg_header( int widthpx, int heightpx ) { std::stringstream out; - out << ""; return out.str(); } diff --git a/src/svg.h b/src/svg.h index 2351288..91d9bc6 100644 --- a/src/svg.h +++ b/src/svg.h @@ -9,11 +9,13 @@ namespace OpenSCAD { // currently for debugging, not necessarily pretty or useful for users. (yet) +#define SVG_PXW 480; +#define SVG_PXH 480; static int svg_cursor_py = 0; -static int svg_px_width = 480; -static int svg_px_height = 480; +static int svg_px_width = SVG_PXW; +static int svg_px_height = SVG_PXH; -std::string svg_header(); +std::string svg_header( int widthpx = SVG_PXW, int heightpx = SVG_PXH ); std::string svg_label( std::string s ); std::string svg_border(); std::string svg_axes(); -- cgit v0.10.1