From 66b6433ffe6f8e0236cf8ab1edad7045df360b2a Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 12:37:27 -0500 Subject: [PATCH] cleanup --- src/PolySetCGALEvaluator.cc | 10 +++++----- src/cgal.h | 5 +++-- src/cgalutils.cc | 7 +++---- src/func.cc | 1 - src/printutils.cc | 3 --- src/printutils.h | 2 -- src/svg.cc | 26 +++++++++++++++----------- src/svg.h | 22 +++++++--------------- 8 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 2fd2a6fd..a5393fd8 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 << " \n"; @@ -108,10 +108,10 @@ public: *(output_nefpoly2d) *= *(tmpnef2d); } - log << "\n\n"; - log << OpenSCAD::dump_svg( *tmpnef2d ) << "\n"; - log << "\n\n"; - log << 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 { diff --git a/src/cgal.h b/src/cgal.h index 518d0828..a7300c63 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -59,8 +59,9 @@ typedef CGAL::Polyhedron_incremental_builder_3 CGAL_Polybuilder; typedef CGAL::Point_3 CGAL_Point_3; typedef CGAL::Iso_cuboid_3 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 > CGAL_Iso_rectangle_2e; diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 601b6f31..51838dfe 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 + 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 21c6f33a..e427bf2d 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 57c6b491..a8b62aa2 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 935463e7..9d99a19f 100644 --- a/src/printutils.h +++ b/src/printutils.h @@ -3,9 +3,7 @@ #include #include -#include #include -#include #include typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata); diff --git a/src/svg.cc b/src/svg.cc index 6f2cda9a..f30e4b8e 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 << ""; return out.str(); } @@ -28,7 +27,10 @@ std::string svg_border() { std::stringstream out; out << " \n"; - out << " \n"; out << " "; 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 << " \n"; + out << " \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 << " \n"; diff --git a/src/svg.h b/src/svg.h index f8d3c0d3..23512883 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