From f39cb81549333c9305ac0330751bad6654838838 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 11:51:43 -0500 Subject: remove debugging. cleanup diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index f6fb1d4..781c4fc 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -160,6 +160,9 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } } + //std::cout << sum.dump(); + //std::cout.flush(); + CGAL_Nef_polyhedron nef_poly; if (node.cut_mode) { @@ -205,7 +208,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } // remove z coordinates to make CGAL_Nef_polyhedron2 - log << ""; + log << OpenSCAD::svg_header( 480, 100000 ) << "\n"; try { ZRemover zremover; CGAL_Nef_polyhedron3::Volume_const_iterator i; diff --git a/src/cgal.h b/src/cgal.h index c3b52a3..518d082 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -34,6 +34,7 @@ using boost::uintmax_t; #include #include #include +#include #include #include diff --git a/src/svg.cc b/src/svg.cc index a40bd9f..6f2cda9 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -5,10 +5,14 @@ namespace OpenSCAD { -std::string svg_header() + +// SVG code +// currently for debugging, not necessarily pretty or useful for users. + +std::string svg_header( int pixw, int pixh ) { std::stringstream out; - out << ""; return out.str(); } @@ -16,7 +20,7 @@ std::string svg_header() std::string svg_label(std::string s) { std::stringstream out; - out << "" << s << ""; + out << " " << s << ""; return out.str(); } @@ -42,26 +46,23 @@ std::string svg_axes() CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) { - // do simple fake isometric projection - double x = CGAL::to_double( p.x() ); - double y = CGAL::to_double( p.y() ); - double z = CGAL::to_double( p.z() ); - double screenw = 480; - double screenh = 480; - double borderw = screenw * 0.1618; - double borderh = screenh * 0.1618; - double vizw = screenw - borderw*2; - double vizh = screenh - borderh*2; - double bboxx = CGAL::to_double( bbox.xmax() - bbox.xmin() ); - double bboxy = CGAL::to_double( bbox.ymax() - bbox.ymin() ); - double bboxz = CGAL::to_double( bbox.zmax() - bbox.zmin() ); - double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); - double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); - double zinbox = CGAL::to_double( p.z() ) - CGAL::to_double( bbox.zmin() ); - double tx = borderw + ( xinbox / ( bboxx==0?1:bboxx ) ) * ( vizw ); - double ty = screenh - borderh - ( zinbox / ( bboxz==0?1:bboxz ) ) * ( vizh ); - tx += ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; - ty -= ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; + NT screenw(480); + NT screenh(480); + NT screenxc = screenw / 2; + NT screenyc = screenh / 2; + NT bboxx = ( bbox.xmax() - bbox.xmin() ); + NT bboxy = ( bbox.ymax() - bbox.ymin() ); + NT bboxz = ( bbox.zmax() - bbox.zmin() ); + NT largest_dim = CGAL::max( CGAL::max( bboxx, bboxy ), bboxz ); + NT bboxxc = bboxx / 2 + bbox.xmin(); + NT bboxyc = bboxy / 2 + bbox.ymin(); + NT bboxzc = bboxz / 2 + bbox.zmin(); + NT xinbox = ( p.x() - bboxxc ) / largest_dim; + NT yinbox = ( p.y() - bboxyc ) / largest_dim; + NT zinbox = ( p.z() - bboxzc ) / largest_dim; + // do simple fake paralell projection + NT tx = screenxc + xinbox * screenw / 1.618 + yinbox * screenh / 3.2; + NT ty = screenyc - zinbox * screenh / 1.618 - yinbox * screenh / 3.2; return CGAL_Point_2e( tx, ty ); } @@ -81,16 +82,9 @@ CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox ) double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); double tx = borderw + ( xinbox / ( bboxw==0?1:bboxw ) ) * ( vizw ); double ty = screenh - borderh - ( yinbox / ( bboxh==0?1:bboxh ) ) * ( vizh ); -/* std::cout << "\nx, y " << x << "," << y << "\n"; - std::cout << "bbw, bbh " << bboxw << "," << bboxh << "\n"; - std::cout << "xinb, yinb " << xinbox << "," << yinbox << "\n"; - std::cout << "vizw, vizh " << vizw << "," << vizh << "\n"; - std::cout << "tx, ty " << tx << "," << ty << "\n"; -*/ return CGAL_Point_2e( tx, ty ); } -// for debugging, not necessarily pretty or useful for users. 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, @@ -115,7 +109,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg( << " x2='" << CGAL::to_double(tp2.x()) + mod << "'" << " y2='" << CGAL::to_double(tp2.y()) - mod << "'" << " stroke='" << color << "'"; - if (mark) out << " stroke-dasharray='4 4' />\n"; + if (!mark) out << " stroke-dasharray='4 4' />\n"; else out << " />\n"; // crude "arrowhead" to indicate directionality out << " \n"; + } else { + out << " \n"; } } return out.str(); @@ -139,10 +135,6 @@ std::string dump_svg( const CGAL_Nef_polyhedron2 &N ) out << " \n"; out << svg_border() << "\n" << svg_axes() << "\n"; svg_cursor+=480; - if ((svg_cursor/480)%3==0) svg_cursor += 24; - if ((svg_cursor/480)%3==1) out << svg_label("old accumulator") << "\n"; - if ((svg_cursor/480)%3==2) out << svg_label("new nef poly") << "\n"; - if ((svg_cursor/480)%3==0) out << svg_label("new accumulator") << "\n"; for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { out << " \n"; @@ -185,6 +177,8 @@ public: { int contour_count = 0; out << " \n"; + std::string color = "gold"; + if (!(*hfacet).mark()) color = "green"; CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; CGAL_forall_facet_cycles_of( i, hfacet ) { CGAL_Nef_polyhedron3::SHalfloop_const_handle shl_handle; @@ -207,7 +201,9 @@ public: << "y1='" << CGAL::to_double(tp1.y()) << "' " << "x2='" << CGAL::to_double(tp2.x()) << "' " << "y2='" << CGAL::to_double(tp2.y()) << "' " - << "stroke='red' />\n"; + << " stroke='" << color << "'"; + if (!(*hfacet).mark()) out << " stroke-dasharray='4 4' />\n"; + else out << " />\n"; } contour_count++; } // next facet cycle (i.e. next contour) @@ -219,7 +215,7 @@ public: std::string dump_svg( const CGAL_Nef_polyhedron3 &N ) { std::stringstream out; - out << svg_header << "\n" << svg_border() << "\n" << svg_axes() << "\n"; + out << svg_header() << "\n" << svg_border() << "\n" << svg_axes() << "\n"; out << "\n"; CGAL_Nef_polyhedron3::Volume_const_iterator c; diff --git a/src/svg.h b/src/svg.h index c7c7e1a..f8d3c0d 100644 --- a/src/svg.h +++ b/src/svg.h @@ -9,7 +9,7 @@ namespace OpenSCAD { static int svg_cursor = 0; -std::string svg_header(); +std::string svg_header( int pixwidth = 480, int pixheight = 480 ); std::string svg_label(std::string s); std::string svg_border(); std::string svg_axes(); -- cgit v0.10.1