source: trunk/packages/vizservers/nanovis/nanovis.h @ 1109

Last change on this file since 1109 was 1053, checked in by gah, 16 years ago

fixes to make compile under gcc-4.3

File size: 5.1 KB
Line 
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 */
15#ifndef __NANOVIS_H__
16#define __NANOVIS_H__
17
18#include <tcl.h>
19
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>
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>
41
42#include "define.h"
43#include "global.h"
44#include "socket/Socket.h"
45#include "NvCamera.h"
46#include "ConvexPolygon.h"
47#include "Texture3D.h"
48#include "Texture2D.h"
49#include "Texture1D.h"
50#include "TransferFunction.h"
51#include "Mat4x4.h"
52#include "Volume.h"
53#include "NvParticleRenderer.h"
54#include "PerfQuery.h"
55#include "Event.h"
56#include "VolumeRenderer.h"
57#include "PlaneRenderer.h"
58#include "NvColorTableRenderer.h"
59#include "PointSetRenderer.h"
60#include "PointSet.h"
61#include "HeightMap.h"
62#include "Grid.h"
63
64#include "config.h"
65
66
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
74struct Vector2 {
75    float x, y;
76    float mag(void) {
77        return sqrt(x*x+y*y);
78    }
79};
80
81struct RegGrid2{
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    }
90
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    }
98};
99
100class NvLIC;
101
102class NanoVis {
103    //frame buffer for final rendering
104    static NVISid final_fbo, final_color_tex, final_depth_rb;
105public:
106    static VolumeRenderer* vol_renderer;
107    static PointSetRenderer* pointset_renderer;
108    static NvParticleRenderer* particleRenderer;
109    static NvLIC* licRenderer;
110    static vector<PointSet*> pointSet;
111    static PlaneRenderer* plane_render;
112
113    /**
114     *  pointers to 2D planes, currently handle up 10
115     */
116    static Texture2D* plane[10];
117    static NvColorTableRenderer* color_table_renderer;
118    static graphics::RenderContext* renderContext;
119    static vector<HeightMap*> heightMap;
120    static unsigned char* screen_buffer;
121    static vector<Volume*> volume;
122    static Grid* grid;
123    static R2Fonts* fonts;
124    static int n_volumes;
125    static int updir;
126    static NvCamera *cam;
127
128    static float lic_slice_x;
129    static float lic_slice_y;
130    static float lic_slice_z;
131    static int lic_axis;        /* 0:x, 1:y, 2:z */
132
133    static bool axis_on;
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
137 
138
139    static bool lic_on;
140    static bool particle_on;
141    static bool vector_on;
142
143
144    static TransferFunction* get_transfunc(const char *name);
145    static TransferFunction* DefineTransferFunction(const char *name,
146        size_t n, float *data);
147    static void SetVolumeRanges(void);
148    static void SetHeightmapRanges(void);
149    static void init(const char* path);
150    static void initGL(void);
151    static void init_lic(void);
152    static void init_offscreen_buffer(void);
153    static void initParticle();
154    static void resize_offscreen_buffer(int w, int h);
155    static void ppm_write(const char *prefix);
156    static void bmp_write(const char *prefix);
157    static void bmp_write_to_file(int frame_number, const char* directory_name);
158    static void display(void);
159    static void update(void);
160    static void display_offscreen_buffer();
161    static void zoom(double zoom);
162    static int render_legend(TransferFunction *tf, double min, double max,
163        int width, int height, const char* volArg);
164    static Volume *load_volume(int index, int width, int height, int depth,
165        int n, float* data, double vmin, double vmax, double nzero_min);
166#ifndef XINETD
167    static void keyboard(unsigned char key, int x, int y);
168    static void mouse(int button, int state, int x, int y);
169    static void motion(int x, int y);
170    static void update_rot(int delta_x, int delta_y);
171    static void update_trans(int delta_x, int delta_y, int delta_z);
172#endif
173
174    static void read_screen(void) {
175        glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE,
176                     screen_buffer);
177    }
178    static void offscreen_buffer_capture(void) {
179        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
180    }
181};
182
183#endif  /* __NANOVIS_H__ */
Note: See TracBrowser for help on using the repository browser.