#include "precompiled.h" # include "sr_sa_eps_export.h" # include "sr_sa_bbox.h" # include "sr_sn_shape.h" # include "sr_lines.h" # include "sr_points.h" # include "sr_polygons.h" //# define SR_USE_TRACE1 // constructor / destructor //# define SR_USE_TRACE2 // render # include "sr_trace.h" //============================= export functions ==================================== // detect if lines are in 3d or 2d!!? // make use of current matrix (and camera) transformation static void export_lines ( SrSnShapeBase* shape, SrOutput& o, const SrSaEpsExport* epsexp ) { SrLines& l = ((SrSnLines*)shape)->shape(); SrArray& V = l.V; SrArray& C = l.C; SrArray& I = l.I; float c[4]; if ( V.size()<2 ) return; shape->material().diffuse.get ( c ); o << c[0] << srspc << c[1] << srspc << c[2] << " setrgbcolor\n"; float res = shape->resolution(); // 0.5 1.0 1.5 res *= 0.02f; // makes resolution 1 be .02 cms res *= 28.346f; // put in unit pts res /= epsexp->scale_factor(); o << res << " setlinewidth\n"; int v=0; // current V index int i; // current I index int imax = I.size()-1; // max value for i int i1=-1, i2; // pair I[i],I[i+1] if ( I.size()>1 ) { i=0; i1=I[i]; i2=I[i+1]; } while ( vget(); if ( p.P.size()==0 ) return; glDisable ( GL_LIGHTING ); glColor ( shape->material().diffuse ); if ( shape->render_mode()==srRenderModeSmooth ) { // render shperes, with resolution as radius? } glPointSize ( shape->resolution() ); // default is 1.0 int i; glBegin ( GL_POINTS ); for ( i=0; i tris; p.ear_triangulation ( tris ); glBegin ( GL_TRIANGLES ); for ( i=0; ishape(); if ( p.size()==0 ) return; float resolution = shape->resolution(); // glDisable ( GL_LIGHTING ); // glColor ( shape->material().diffuse ); // glLineWidth ( resolution ); // default is 1.0 export_polygon ( p, shape->render_mode(), resolution, o, epsexp ); } static void export_polygons ( SrSnShapeBase* shape, SrOutput& o, const SrSaEpsExport* epsexp ) { SrPolygons& p = ((SrSnPolygons*)shape)->shape(); if ( p.size()==0 ) return; float resolution = shape->resolution(); /* glDisable ( GL_LIGHTING ); glColor ( shape->material().diffuse ); glLineWidth ( resolution ); // default is 1.0 */ int i; for ( i=0; irender_mode(), resolution, o, epsexp ); } //=============================== SrSaEpsExport ==================================== SrArray SrSaEpsExport::_efuncs; SrSaEpsExport::SrSaEpsExport ( SrOutput& o ) : _output ( o ) { SR_TRACE1 ( "Constructor" ); _page_width = 21.59f; // == 612 pts _page_height = 27.94f; // == 792 pts _page_margin = 4.0f; _bbox_margin = 0.1f; if ( _efuncs.size()==0 ) // no functions registered { //register_export_function ( "model", export_model ); register_export_function ( "lines", export_lines ); register_export_function ( "points", export_points ); //register_export_function ( "box", export_box ); //register_export_function ( "sphere", export_sphere ); register_export_function ( "polygon", export_polygon ); register_export_function ( "polygons", export_polygons ); } } SrSaEpsExport::~SrSaEpsExport () { SR_TRACE1 ( "Destructor" ); } void register_export_function ( const char* class_name, SrSaEpsExport::export_function efunc ) // friend function { SrArray &ef = SrSaEpsExport::_efuncs; int i; for ( i=0; iinst_class_name (); SrArray& ef = SrSaEpsExport::_efuncs; for ( i=0; ivisible() ) return true; // 3. Export ef[i].efunc ( s, _output, this ); return true; } //======================================= PS GUIDE ==================================== /* http://adela.karlin.mff.cuni.cz/netkarl/prirucky/Flat/paths.html 72 72 scale points to inches, 1 pt = 1/72 inches 2.8346 2.8346 scale points to mms 1.0 setlinewidth 0 is valid 2 setlinecap 0, 1, 2: butt ends, round ends, square ends 2 setlinejoin 0, 1, 2: miter corners, round corners, bevel corners 0.5 setgray 0 to 1 gsave grestore EXAMPLE: %! 0.025 setlinewidth 72 72 scale 0.8 setgray newpath 1 1 moveto 7 1 lineto 1 5 lineto closepath fill 0 setgray newpath 1 1 moveto 7 1 lineto 1 5 lineto closepath stroke showpage */ //======================================= EOF ====================================