[226] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * nanovis.h: package header |
---|
| 4 | * |
---|
| 5 | * ====================================================================== |
---|
| 6 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
| 7 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
| 8 | * |
---|
| 9 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
| 10 | * |
---|
| 11 | * See the file "license.terms" for information on usage and |
---|
| 12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 13 | * ====================================================================== |
---|
| 14 | */ |
---|
[829] | 15 | #ifndef __NANOVIS_H__ |
---|
| 16 | #define __NANOVIS_H__ |
---|
[259] | 17 | |
---|
[850] | 18 | #include <tcl.h> |
---|
| 19 | |
---|
[226] | 20 | #include <GL/glew.h> |
---|
| 21 | #include <GL/glut.h> |
---|
| 22 | #include <Cg/cgGL.h> |
---|
| 23 | #include <stdlib.h> |
---|
| 24 | #include <math.h> |
---|
| 25 | #include <time.h> |
---|
| 26 | #include <iostream> |
---|
| 27 | #include <stdio.h> |
---|
| 28 | #include <assert.h> |
---|
| 29 | #include <float.h> |
---|
[829] | 30 | #include <getopt.h> |
---|
| 31 | #include <stdio.h> |
---|
| 32 | #include <math.h> |
---|
| 33 | #include <fstream> |
---|
| 34 | #include <sstream> |
---|
| 35 | #include <string> |
---|
| 36 | #include <sys/time.h> |
---|
| 37 | #include <sys/types.h> |
---|
| 38 | #include <unistd.h> |
---|
| 39 | #include <fcntl.h> |
---|
| 40 | #include <signal.h> |
---|
[226] | 41 | |
---|
[273] | 42 | #include "define.h" |
---|
| 43 | #include "global.h" |
---|
| 44 | #include "socket/Socket.h" |
---|
[881] | 45 | #include "NvCamera.h" |
---|
[273] | 46 | #include "ConvexPolygon.h" |
---|
| 47 | #include "Texture3D.h" |
---|
| 48 | #include "Texture2D.h" |
---|
| 49 | #include "Texture1D.h" |
---|
[379] | 50 | #include "TransferFunction.h" |
---|
[273] | 51 | #include "Mat4x4.h" |
---|
| 52 | #include "Volume.h" |
---|
[850] | 53 | #include "NvParticleRenderer.h" |
---|
[377] | 54 | #include "PerfQuery.h" |
---|
[383] | 55 | #include "Event.h" |
---|
[406] | 56 | #include "VolumeRenderer.h" |
---|
[431] | 57 | #include "PlaneRenderer.h" |
---|
[835] | 58 | #include "NvColorTableRenderer.h" |
---|
| 59 | #include "PointSetRenderer.h" |
---|
| 60 | #include "PointSet.h" |
---|
| 61 | #include "HeightMap.h" |
---|
| 62 | #include "Grid.h" |
---|
[273] | 63 | |
---|
[251] | 64 | #include "config.h" |
---|
[226] | 65 | |
---|
[251] | 66 | |
---|
[226] | 67 | //defines for the image based flow visualization |
---|
| 68 | #define NPN 256 //resolution of background pattern |
---|
| 69 | #define NMESH 256 //resolution of flow mesh |
---|
| 70 | #define DM ((float) (1.0/(NMESH-1.0))) //distance in world coords between mesh lines |
---|
| 71 | #define NPIX 512 //display size |
---|
| 72 | #define SCALE 3.0 //scale for background pattern. small value -> fine texture |
---|
| 73 | |
---|
[1053] | 74 | struct Vector2 { |
---|
[835] | 75 | float x, y; |
---|
| 76 | float mag(void) { |
---|
| 77 | return sqrt(x*x+y*y); |
---|
| 78 | } |
---|
[226] | 79 | }; |
---|
| 80 | |
---|
[1053] | 81 | struct RegGrid2{ |
---|
[835] | 82 | int width, height; |
---|
| 83 | Vector2* field; |
---|
| 84 | |
---|
| 85 | RegGrid2(int w, int h){ |
---|
| 86 | width = w; |
---|
| 87 | height = h; |
---|
| 88 | field = new Vector2[w*h]; |
---|
| 89 | } |
---|
[226] | 90 | |
---|
[835] | 91 | void put(Vector2& v, int x ,int y) { |
---|
| 92 | field[x+y*width] = v; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | Vector2& get(int x, int y) { |
---|
| 96 | return field[x+y*width]; |
---|
| 97 | } |
---|
[226] | 98 | }; |
---|
[273] | 99 | |
---|
[851] | 100 | class NvLIC; |
---|
| 101 | |
---|
[835] | 102 | class NanoVis { |
---|
[1028] | 103 | //frame buffer for final rendering |
---|
| 104 | static NVISid final_fbo, final_color_tex, final_depth_rb; |
---|
[835] | 105 | public: |
---|
[848] | 106 | static VolumeRenderer* vol_renderer; |
---|
| 107 | static PointSetRenderer* pointset_renderer; |
---|
[850] | 108 | static NvParticleRenderer* particleRenderer; |
---|
[851] | 109 | static NvLIC* licRenderer; |
---|
[848] | 110 | static vector<PointSet*> pointSet; |
---|
| 111 | static PlaneRenderer* plane_render; |
---|
[273] | 112 | |
---|
[848] | 113 | /** |
---|
| 114 | * pointers to 2D planes, currently handle up 10 |
---|
| 115 | */ |
---|
[835] | 116 | static Texture2D* plane[10]; |
---|
[848] | 117 | static NvColorTableRenderer* color_table_renderer; |
---|
[838] | 118 | static graphics::RenderContext* renderContext; |
---|
[848] | 119 | static vector<HeightMap*> heightMap; |
---|
[835] | 120 | static unsigned char* screen_buffer; |
---|
| 121 | static vector<Volume*> volume; |
---|
[848] | 122 | static Grid* grid; |
---|
| 123 | static R2Fonts* fonts; |
---|
[835] | 124 | static int n_volumes; |
---|
| 125 | static int updir; |
---|
[881] | 126 | static NvCamera *cam; |
---|
[273] | 127 | |
---|
[851] | 128 | static float lic_slice_x; |
---|
| 129 | static float lic_slice_y; |
---|
| 130 | static float lic_slice_z; |
---|
[932] | 131 | static int lic_axis; /* 0:x, 1:y, 2:z */ |
---|
[851] | 132 | |
---|
[835] | 133 | static bool axis_on; |
---|
[932] | 134 | static bool config_pending; // Indicates if the limits need to be recomputed. |
---|
| 135 | static int win_width; //size of the render window |
---|
| 136 | static int win_height; //size of the render window |
---|
[1194] | 137 | static int render_window; |
---|
[273] | 138 | |
---|
[1194] | 139 | static bool debug_flag; |
---|
[860] | 140 | static bool lic_on; |
---|
| 141 | static bool particle_on; |
---|
| 142 | static bool vector_on; |
---|
| 143 | |
---|
[1161] | 144 | static Tcl_Interp *interp; |
---|
| 145 | static Tcl_DString cmdbuffer; |
---|
[1028] | 146 | |
---|
[835] | 147 | static TransferFunction* get_transfunc(const char *name); |
---|
[973] | 148 | static TransferFunction* DefineTransferFunction(const char *name, |
---|
[1295] | 149 | size_t n, float *data); |
---|
[932] | 150 | static void SetVolumeRanges(void); |
---|
| 151 | static void SetHeightmapRanges(void); |
---|
[848] | 152 | static void init(const char* path); |
---|
[835] | 153 | static void initGL(void); |
---|
| 154 | static void init_lic(void); |
---|
| 155 | static void init_offscreen_buffer(void); |
---|
[850] | 156 | static void initParticle(); |
---|
[835] | 157 | static void resize_offscreen_buffer(int w, int h); |
---|
[1028] | 158 | static void ppm_write(const char *prefix); |
---|
[1295] | 159 | static void sendDataToClient(const char *command, const char *data, |
---|
| 160 | size_t dlen); |
---|
[1028] | 161 | static void bmp_write(const char *prefix); |
---|
| 162 | static void bmp_write_to_file(int frame_number, const char* directory_name); |
---|
[835] | 163 | static void display(void); |
---|
[1194] | 164 | static void idle(void); |
---|
[884] | 165 | static void update(void); |
---|
[835] | 166 | static void display_offscreen_buffer(); |
---|
| 167 | static int render_legend(TransferFunction *tf, double min, double max, |
---|
[1295] | 168 | int width, int height, const char* volArg); |
---|
[927] | 169 | static Volume *load_volume(int index, int width, int height, int depth, |
---|
[1295] | 170 | int n, float* data, double vmin, double vmax, double nzero_min); |
---|
[1161] | 171 | static void xinetd_listen(void); |
---|
[1156] | 172 | static int render_2d_contour(HeightMap* heightmap, int width, int height); |
---|
[1238] | 173 | static void pan(float dx, float dy); |
---|
[1156] | 174 | |
---|
[835] | 175 | #ifndef XINETD |
---|
| 176 | static void keyboard(unsigned char key, int x, int y); |
---|
| 177 | static void mouse(int button, int state, int x, int y); |
---|
| 178 | static void motion(int x, int y); |
---|
| 179 | static void update_rot(int delta_x, int delta_y); |
---|
| 180 | static void update_trans(int delta_x, int delta_y, int delta_z); |
---|
| 181 | #endif |
---|
[1028] | 182 | |
---|
[1182] | 183 | static FILE *stdin, *logfile, *recfile; |
---|
[1111] | 184 | |
---|
[1028] | 185 | static void read_screen(void) { |
---|
[1295] | 186 | glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE, |
---|
| 187 | screen_buffer); |
---|
[1028] | 188 | } |
---|
| 189 | static void offscreen_buffer_capture(void) { |
---|
[1295] | 190 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo); |
---|
[1028] | 191 | } |
---|
[835] | 192 | }; |
---|
[851] | 193 | |
---|
[1111] | 194 | |
---|
[835] | 195 | #endif /* __NANOVIS_H__ */ |
---|