summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PolySetCGALEvaluator.cc10
-rw-r--r--src/cgal.h5
-rw-r--r--src/cgalutils.cc7
-rw-r--r--src/func.cc1
-rw-r--r--src/printutils.cc3
-rw-r--r--src/printutils.h2
-rw-r--r--src/svg.cc26
-rw-r--r--src/svg.h22
8 files changed, 33 insertions, 43 deletions
diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc
index 2fd2a6f..a5393fd 100644
--- a/src/PolySetCGALEvaluator.cc
+++ b/src/PolySetCGALEvaluator.cc
@@ -94,7 +94,7 @@ public:
contour.push_back( point2d );
}
- assert(contour.size()>1);
+ if (contour.size()==0) continue;
log << " <!-- is_simple_2:" << CGAL::is_simple_2( contour.begin(), contour.end() ) << " --> \n";
@@ -108,10 +108,10 @@ public:
*(output_nefpoly2d) *= *(tmpnef2d);
}
- log << "\n<!-- ======== output tmp nef: ==== -->\n";
- log << OpenSCAD::dump_svg( *tmpnef2d ) << "\n";
- log << "\n<!-- ======== output accumulator: ==== -->\n";
- log << 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 {
diff --git a/src/cgal.h b/src/cgal.h
index 518d082..a7300c6 100644
--- a/src/cgal.h
+++ b/src/cgal.h
@@ -59,8 +59,9 @@ typedef CGAL::Polyhedron_incremental_builder_3<CGAL_HDS> CGAL_Polybuilder;
typedef CGAL::Point_3<CGAL_Kernel3> CGAL_Point_3;
typedef CGAL::Iso_cuboid_3<CGAL_Kernel3> CGAL_Iso_cuboid_3;
-// The type given to Iso_rectangle_2 needs to match CGAL_Nef2::Explorer::Point
-// which is different than a CGAL_Kernel2::Point. Hence the suffix 'e'
+// CGAL_Nef_polyhedron2 uses CGAL_Kernel2, but Iso_rectangle_2 needs to match
+// CGAL_Nef_polyhedron2::Explorer::Point which is different than
+// CGAL_Kernel2::Point. Hence the suffix 'e'
typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2e;
typedef CGAL::Iso_rectangle_2< CGAL::Simple_cartesian<NT> > CGAL_Iso_rectangle_2e;
diff --git a/src/cgalutils.cc b/src/cgalutils.cc
index 601b6f3..51838df 100644
--- a/src/cgalutils.cc
+++ b/src/cgalutils.cc
@@ -3,8 +3,11 @@
#include "cgalutils.h"
#include "polyset.h"
#include "printutils.h"
+
#include "cgal.h"
+#include <map>
+
PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p)
{
PolySet *ps = new PolySet();
@@ -142,7 +145,6 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps)
return P;
}
-
CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N )
{
CGAL_Iso_cuboid_3 result(-1,-1,-1,1,1,1);
@@ -171,8 +173,5 @@ CGAL_Iso_rectangle_2e bounding_box( const CGAL_Nef_polyhedron2 &N )
return result;
}
-
-
-
#endif /* ENABLE_CGAL */
diff --git a/src/func.cc b/src/func.cc
index 21c6f33..e427bf2 100644
--- a/src/func.cc
+++ b/src/func.cc
@@ -530,4 +530,3 @@ void register_builtin_functions()
Builtins::init("version", new BuiltinFunction(&builtin_version));
Builtins::init("version_num", new BuiltinFunction(&builtin_version_num));
}
-
diff --git a/src/printutils.cc b/src/printutils.cc
index 57c6b49..a8b62aa 100644
--- a/src/printutils.cc
+++ b/src/printutils.cc
@@ -49,6 +49,3 @@ void PRINT_NOCACHE(const std::string &msg)
outputhandler(msg, outputhandler_data);
}
}
-
-
-
diff --git a/src/printutils.h b/src/printutils.h
index 935463e..9d99a19 100644
--- a/src/printutils.h
+++ b/src/printutils.h
@@ -3,9 +3,7 @@
#include <string>
#include <list>
-#include <map>
#include <iostream>
-#include <sstream>
#include <boost/format.hpp>
typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata);
diff --git a/src/svg.cc b/src/svg.cc
index 6f2cda9..f30e4b8 100644
--- a/src/svg.cc
+++ b/src/svg.cc
@@ -5,14 +5,13 @@
namespace OpenSCAD {
-
// SVG code
-// currently for debugging, not necessarily pretty or useful for users.
+// currently for debugging, not necessarily pretty or useful for users. (yet)
-std::string svg_header( int pixw, int pixh )
+std::string svg_header()
{
std::stringstream out;
- out << "<svg width='" << pixw << "px' height='" << pixh << "px'"
+ out << "<svg width='" << svg_px_width << "px' height='" << svg_px_height << "px'"
<< " xmlns='http://www.w3.org/2000/svg' version='1.1'>";
return out.str();
}
@@ -28,7 +27,10 @@ std::string svg_border()
{
std::stringstream out;
out << " <!-- border -->\n";
- out << " <polyline points='0,0 480,0 480,480 0,480'"
+ out << " <polyline points='0,0 "
+ << svg_px_width << ",0 "
+ << svg_px_width << "," << svg_px_height
+ << " 0," << svg_px_height << "'"
<< " style='fill:none;stroke:black' />\n";
out << " <!-- /border -->";
return out.str();
@@ -46,8 +48,8 @@ std::string svg_axes()
CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox )
{
- NT screenw(480);
- NT screenh(480);
+ NT screenw(svg_px_width);
+ NT screenh(svg_px_height);
NT screenxc = screenw / 2;
NT screenyc = screenh / 2;
NT bboxx = ( bbox.xmax() - bbox.xmin() );
@@ -70,8 +72,8 @@ CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox )
{
double x = CGAL::to_double( p.x() );
double y = CGAL::to_double( p.y() );
- double screenw = 480;
- double screenh = 480;
+ double screenw = svg_px_width;
+ double screenh = svg_px_height;
double borderw = screenw * 0.1618;
double borderh = screenh * 0.1618;
double vizw = screenw - borderw*2;
@@ -132,9 +134,11 @@ std::string dump_svg( const CGAL_Nef_polyhedron2 &N )
CGAL_Iso_rectangle_2e bbox = bounding_box( N );
CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i;
- out << " <svg y='" << svg_cursor << "' width='480px' height='480px' xmlns='http://www.w3.org/2000/svg' version='1.1'>\n";
+ out << " <svg y='" << svg_cursor_py << "' width='" << svg_px_width
+ << "' height='" << svg_px_height
+ << "' xmlns='http://www.w3.org/2000/svg' version='1.1'>\n";
out << svg_border() << "\n" << svg_axes() << "\n";
- svg_cursor+=480;
+ svg_cursor_py += svg_px_height;
for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) {
out << " <!-- face begin. mark: " << i->mark() << " -->\n";
diff --git a/src/svg.h b/src/svg.h
index f8d3c0d..2351288 100644
--- a/src/svg.h
+++ b/src/svg.h
@@ -7,27 +7,19 @@
namespace OpenSCAD {
-static int svg_cursor = 0;
+// currently for debugging, not necessarily pretty or useful for users. (yet)
-std::string svg_header( int pixwidth = 480, int pixheight = 480 );
-std::string svg_label(std::string s);
+static int svg_cursor_py = 0;
+static int svg_px_width = 480;
+static int svg_px_height = 480;
+
+std::string svg_header();
+std::string svg_label( std::string s );
std::string svg_border();
std::string svg_axes();
-CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox );
-CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox );
-
-std::string dump_cgal_nef_polyhedron2_face_svg(
- CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1,
- CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2,
- CGAL_Nef_polyhedron2::Explorer explorer,
- std::string color,
- bool mark,
- CGAL_Iso_rectangle_2e bbox );
std::string dump_svg( const CGAL_Nef_polyhedron2 &N );
-class NefPoly3_dumper_svg;
std::string dump_svg( const CGAL_Nef_polyhedron3 &N );
-
} // namespace
#endif
contact: Jan Huwald // Impressum