summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PolySetCGALEvaluator.cc25
-rw-r--r--src/svg.cc4
-rw-r--r--src/svg.h8
3 files changed, 18 insertions, 19 deletions
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<!-- ======== output tmp nef: ==== -->\n"
- << OpenSCAD::dump_svg( *tmpnef2d ) << "\n"
- << "\n<!-- ======== output accumulator: ==== -->\n"
- << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n";
+ log << "\n<!-- ======== output tmp nef: ==== -->\n"
+ << OpenSCAD::dump_svg( *tmpnef2d ) << "\n"
+ << "\n<!-- ======== output accumulator: ==== -->\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 << "<!-- volume end. -->\n";
}
- log << "</svg>\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 << "</svg>\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 << "<svg width='" << svg_px_width << "px' height='" << svg_px_height << "px'"
+ out << "<svg width='" << widthpx << "px' height='" << heightpx << "px'"
<< " xmlns='http://www.w3.org/2000/svg' version='1.1'>";
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();
contact: Jan Huwald // Impressum