epswrite.h

Go to the documentation of this file.
00001 
00006 #ifndef EPSWRITE_H
00007 #define EPSWRITE_H
00008 
00009 #include "globals.h"
00010 #include "color.h"
00011 #include "util.h"
00012 #include <cstdio>
00013 
00014 #define DRAW_OFF 0
00015 #define DRAW_GRAYSCALE 1
00016 #define DRAW_RGB 2
00017 
00018 /* Forward declarations to avoid including headers */
00019 class BezierMesh;
00020 class BoundaryMesh;
00021 class BezierEdge;
00022 class BezierTriangle;
00023 
00025 struct PSCoord {
00026    unsigned x;
00027    unsigned y;
00028 };
00029 
00034 struct PSDrawMode {
00035     int mode; /* one of: DRAW_OFF, DRAW_GREYSCALE, DRAW_RGB */
00036     unsigned linewidth;
00037     float grayscale;
00038     Color rgbcolor;
00039 };
00040 
00044 class EPSWrite {
00045     private:
00046         BezierMesh *bezier_mesh;
00047         BoundaryMesh *bdry_mesh;
00048         FILE *epsfile;
00049 
00050         Point2D world_bot;
00051         Point2D world_top;
00052         double world_width;
00053         double world_height;
00054 
00055         Point2D view_bot, view_top;
00056         double view_height, view_width;
00057 
00058         PSCoord page_bot;
00059         PSCoord page_top;
00060         unsigned page_width;
00061         unsigned page_height;
00062         unsigned margin_width;
00063 
00064         PSCoord canvas_bot;
00065         PSCoord canvas_top;
00066         unsigned canvas_width;
00067         unsigned canvas_height;
00068 
00069         PSDrawMode bdry;
00070         PSDrawMode edges;
00071         PSDrawMode border;
00072 
00073         int shade_face_mode;
00074         GrayscaleMap grayscale_map;
00075         ColorMap rgb_map;
00076 
00077         void print_header();
00078         void set_options();
00079         void set_clip();
00080 
00081         void set_ink(const PSDrawMode &mode);
00082         PSCoord convert_coords(const Point2D &pt);
00083         void project_to_canvas();
00084         void draw_edge(BezierEdge *e);
00085         void shade_triangle(BezierTriangle *t);
00086 
00087         void draw_edges();
00088         void draw_bdry();
00089         void draw_border();
00090         void draw_faces();
00091 
00092     public:
00093         EPSWrite(BezierMesh *_bezier_mesh, BoundaryMesh *_bdry_mesh);
00094 
00095         //int load_rgb_map(char *filename);
00096         //int load_grayscale_map(char *filename);
00097         int map_rgbcolor(int idx, const Color &color);
00098         int map_grayscale(int idx, float scale);
00099 
00100         int set_border_draw(int mode);
00101         int set_border_ink(unsigned linewidth, float shade);
00102         int set_border_ink(unsigned linewidth, const Color &rgbcolor);
00103 
00104         int set_edge_draw(int mode);
00105         int set_edge_ink(unsigned linewidth, float shade);
00106         int set_edge_ink(unsigned linewidth, const Color &rgbcolor);
00107 
00108         int set_bdry_draw(int mode);
00109         int set_bdry_ink(unsigned linewidth, float shade);
00110         int set_bdry_ink(unsigned linewidth, const Color &rgbcolor);
00111 
00112         int set_face_draw(int mode);
00113 
00114         int set_page_dim(unsigned xmin, unsigned ymin, unsigned xmax, unsigned ymax, unsigned margin);
00115         int set_page_dim_inch(float xmin, float ymin, float xmax, float ymax, float margin);
00116         int set_world_view(const Point2D& bot, const Point2D& top);
00117 
00118         int write(char *epsfilename);
00119 };
00120 
00121 #endif /* EPSWRITE_H */
00122 

Generated on Mon May 24 09:53:30 2010 for TUMBLE by  doxygen 1.5.2