visualization.h

Go to the documentation of this file.
00001 
00013 #ifndef VISUALIZATION_H
00014 #define VISUALIZATION_H
00015 
00016 //#include <vector>
00017 
00018 #include "pic.h"
00019 
00020 #include "globals.h"
00021 #include "color.h"
00022 #include "util.h"
00023 #include "cell.h"
00024 #include "celltuple.h"
00025 
00026 
00027 /*This makes all triangles no matter how small be drawn */
00028 /* as of riught now turingin this off draw less triangles, but may leave empty regions on the screen */
00029 #define DRAW_SMALL_TRIS
00030 
00031 
00032 /* Forward declarations */
00033 class BezierMesh;
00034 class BoundaryMesh;
00035 class Simulation;
00036 
00049 class Visualization {
00050     private:
00051         Pic* dump_pixels(Pic* &p);
00052         void init_zoom();
00053         void initialize(BezierMesh *_bezier_mesh, BoundaryMesh *_bdry_mesh, int _screen_width=-1, int _screen_height=-1,bool _project=false);
00054 
00055         /* visibility predicates*/
00056         bool is_visible(const Point2D &p);
00057         bool is_visible(const BoundaryVertex *v);
00058         bool is_visible(const BezierVertex *v);
00059         bool is_visible(const BezierEdge *e);
00060         bool is_visible(const BezierTriangle *t);
00061 
00062     public:
00068         Point2D world_top; 
00069         Point2D world_bot; 
00070         Point2D world_center; 
00071         double world_width; 
00072         double world_height; 
00073         double world_ratio; 
00075 
00083         Point2D zoom_top; 
00084         Point2D zoom_bot; 
00085         Point2D zoom_center; 
00086         double zoom_width; 
00087         double zoom_height; 
00088         double zoom_ratio; 
00089         bool zoomed; 
00091 
00099         Point2D view_top; 
00100         Point2D view_bot;
00101         double pixel_area; 
00103 
00104 
00105 
00113         int screen_width; 
00114         int screen_height; 
00115         double screen_ratio; 
00117 
00118         ColorMap colormap;
00119 
00127         int edge_draw_acc; 
00128         int face_draw_acc; 
00134         BezierMesh *bezier_mesh; 
00135         BoundaryMesh *bdry_mesh; 
00137         /* Constructor */
00138         Visualization(Simulation *sim, int _screen_width, int _screen_height);
00139         Visualization(Simulation *_sim);
00140         Visualization(BezierMesh *_bezier_mesh, BoundaryMesh *_bdry_mesh, int _screen_width, int _screen_height);
00141         Visualization(BezierMesh *_bezier_mesh, BoundaryMesh *_bdry_mesh);
00142         Visualization(BezierMesh *_bezier_mesh, BoundaryMesh *_bdry_mesh, bool _project);
00143 
00144         /* Destructor */
00145         ~Visualization();
00146 
00147         /* Control for colormap */
00148         int map_color(int idx, const Color &color);
00149 
00150         /* Set drawing accuracy */
00151         void set_accuracy(int edge_acc, int face_acc)
00152         {
00153             assert(edge_acc>0);
00154             assert(face_acc>0);
00155             edge_draw_acc = edge_acc;
00156             face_draw_acc = face_acc;
00157         }
00158 
00159         /* Image ouput via libpicio */
00160         int write_jpeg(char *filename);
00161         int write_tiff(char *filename);
00162         int write_ppm(char *filename);
00163 
00164         /* Functions to control projection onto screen */
00165         void resize(int width, int height);
00166         void get_bbox(BezierTriangle* t[], int num, Point2D &top, Point2D &bot);
00167         void compute_world_size();
00168         void project();
00169         Point2D convert_from_screen_coords(int x, int y);
00170         void zoomin(Point2D zt, Point2D zb);
00171         void zoomout();
00172 
00173         /* Normzalization functions */
00174         int get_norms(std::vector<double> &min, std::vector<double> &max);
00175 
00176         /* High Level Drawing functions to draw entire mesh */
00177         void draw( const Color &bdry_color, const Color &edge_color);
00178         void draw_bezier( const Color &edge_color, const Color &tri_color);
00179         void draw_solid( const Color &bdry_color, const Color &edge_color);
00180         void draw_data( const Color &bdry_color, const Color &edge_color, unsigned rp, unsigned gp, unsigned bp);
00181         void draw_debug( const Color &bdry_vert_color, const Color &bdry_edge_color, const Color &mesh_color );
00182         void draw_debug( const Color &bdry_vert_color, const Color &bdry_edge_color, const Color &mesh_color, const Color &tri_color );
00183         void draw_bdry_debug( const Color &vert_color, const Color &edge_color,const Color &control_color, const Color &deboor_color);
00184 
00185         /* High level drawing functions to work with tumble-view.rb */
00186         void draw_skeleton( const Color &bdry_color, const Color &edge_color, bool draw_edges);
00187         void draw_solid( const Color &bdry_color, const Color &edge_color, bool draw_edges);
00188         void draw_data_channel(const Color &bdry_color, const Color &edge_color, unsigned channel, double min, double max, bool draw_edges);
00189 
00190         /* Low level drawing functions to draw individual elements */
00191         void draw_tuple(const BezierTuple &tup, const Color &vc, const Color &ec, const Color &fc);
00192         void draw_point(BezierTriangle *t, double u, double v, const Color &tc, const Color &vc);
00193         void draw_point(BezierEdge *e, double u, const Color &ec, const Color &vc);
00194         void draw_point(const Point2D &p, const Color &color, double size);
00195         void draw_circle(const Color &color, const Point2D &p, double radius);
00196         void draw_boundary_vertex(BoundaryVertex *v, const Color &color);
00197         void draw_boundary_edge(const BoundaryEdge *e, const Color &color);
00198         void draw_boundary_edge_debug(const BoundaryEdge *e, const Color &edge, const Color &control, const Color &deboor);
00199         void draw_bezier_vertex(BezierVertex *v, const Color &color);
00200         void draw_bezier_edge(BezierEdge *e, const Color &color);
00201         void draw_bezier_triangle(BezierTriangle *f);
00202         void draw_bezier_triangle(BezierTriangle *f, const Color &color);
00203         void draw_bezier_triangle(BezierTriangle *f, unsigned r, unsigned g, unsigned b);
00204         void draw_bezier_triangle(BezierTriangle *f, unsigned channel, double min, double max);
00205         void draw_control_net(BezierTriangle *t, const Color &color);
00206         void draw_polygon(Point2D ps[], int len, const Color &color);
00207         void draw_smooth_debug(BezierEdge *e, Point2D poly[], const Point2D &primary, const Point2D &secodary);
00208         void draw_flip_debug(BezierEdge *e, Point2D poly[], const Point2D &primary, const Point2D &secodary);
00209 
00210         void start_draw();
00211         void finish_draw();
00212 
00213 
00214 
00215         /* Debugging functions for ruby */
00216         BezierTuple visual_locate(Point2D pt);
00217         void visual_switch(int snum,BezierTuple &tup);
00218         void draw_newton();
00219         void draw_inverted_classes();
00220         int draw_smoothable_edges();
00221         int draw_flippable_edges();
00222 
00223         /* Obsolete Debugging functions
00224         double get_jacobian(BezierTriangle *t, Point2D p);
00225         void check_for_inversions();
00226         void draw_troubled_triangles(BezierTriangle *t1, BezierTriangle *t2, Point2D pt, Point2D *poly);
00227         void draw_troubled_interp_triangles(BezierTriangle *t1, GhostTriangle **oldts, Point2D pt);
00228         */
00229 
00230 };
00231 #endif /* VISUALIZATION_H */

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