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

Last change on this file since 3502 was 3502, checked in by ldelgass, 11 years ago

Add basic VTK structured points reader to nanovis, update copyright dates.

  • Property svn:eol-style set to native
File size: 6.1 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 *  nanovis.h: package header
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16#ifndef NANOVIS_H
17#define NANOVIS_H
18
19#include <tcl.h>
20#include <md5.h>
21#include <GL/glew.h>
22
23#include <math.h>
24#include <stddef.h> // For size_t
25#include <stdio.h>
26
27#include <vector>
28#include <iostream>
29
30#include <vrmath/Vector3f.h>
31
32#include "config.h"
33
34#define NANOVIS_VERSION         "1.1"
35
36//defines for the image based flow visualization
37#define NMESH 256       //resolution of flow mesh
38#define NPIX  512       //display size
39
40namespace nv {
41namespace graphics {
42    class RenderContext;
43}
44namespace util {
45    class Fonts;
46}
47}
48
49class VolumeRenderer;
50class PointSetRenderer;
51class NvParticleRenderer;
52class NvFlowVisRenderer;
53class PlaneRenderer;
54class VelocityArrowsSlice;
55class NvLIC;
56class PointSet;
57class Texture2D;
58class NvColorTableRenderer;
59class HeightMap;
60class NvVectorField;
61class Grid;
62class NvCamera;
63class TransferFunction;
64class Volume;
65class FlowCmd;
66class FlowIterator;
67
68class NanoVis
69{
70public:
71    enum AxisDirections {
72        X_POS = 1,
73        Y_POS = 2,
74        Z_POS = 3,
75        X_NEG = -1,
76        Y_NEG = -2,
77        Z_NEG = -3
78    };
79
80    enum NanoVisFlags {
81        REDRAW_PENDING = (1 << 0),
82        MAP_FLOWS = (1 << 1)
83    };
84
85    static void processCommands();
86    static void init(const char *path);
87    static void initGL();
88    static void initOffscreenBuffer();
89    static void resizeOffscreenBuffer(int w, int h);
90    static void setBgColor(float color[3]);
91    static void render();
92    static void draw3dAxis();
93    static void idle();
94    static void update();
95    static void removeAllData();
96
97    static const NvCamera *getCamera()
98    {
99        return cam;
100    }
101    static void pan(float dx, float dy);
102    static void zoom(float z);
103    static void resetCamera(bool resetOrientation = false);
104
105    static void eventuallyRedraw(unsigned int flag = 0);
106
107    static void setVolumeRanges();
108    static void setHeightmapRanges();
109
110#ifdef KEEPSTATS
111    static int getStatsFile(Tcl_Obj *objPtr);
112    static int writeToStatsFile(int f, const char *s, size_t length);
113#endif
114    static void ppmWrite(const char *prefix);
115    static void sendDataToClient(const char *command, const char *data,
116                                 size_t dlen);
117    static void bmpWrite(const char *prefix);
118    static void bmpWriteToFile(int frame_number, const char* directory_name);
119 
120    static TransferFunction *getTransfunc(const char *name);
121    static TransferFunction *defineTransferFunction(const char *name,
122                                                    size_t n, float *data);
123
124    static int renderLegend(TransferFunction *tf, double min, double max,
125                            int width, int height, const char *volArg);
126
127    static Volume *loadVolume(const char *tag, int width, int height, int depth,
128                              int n, float* data, double vmin, double vmax,
129                              double nonZeroMin);
130
131    static void removeVolume(Volume *volPtr);
132
133    static void readScreen()
134    {
135        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
136                     screenBuffer);
137    }
138    static void bindOffscreenBuffer()
139    {
140        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
141    }
142
143    static FlowCmd *FirstFlow(FlowIterator *iterPtr);
144    static FlowCmd *NextFlow(FlowIterator *iterPtr);
145    static void InitFlows();
146    static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr,
147                       FlowCmd **flowPtrPtr);
148    static int CreateFlow(Tcl_Interp *interp, Tcl_Obj *objPtr);
149    static void DeleteFlows(Tcl_Interp *interp);
150    static bool MapFlows();
151    static void GetFlowBounds(vrmath::Vector3f& min,
152                              vrmath::Vector3f& max,
153                              bool onlyVisible = false);
154    static void RenderFlows();
155    static void ResetFlows();
156    static bool UpdateFlows();
157    static void AdvectFlows();
158
159    static FILE *stdin, *logfile, *recfile;
160    static int statsFile;
161    static unsigned int flags;
162    static bool debugFlag;
163    static bool axisOn;
164    static int winWidth;        //size of the render window
165    static int winHeight;       //size of the render window
166    static int renderWindow;
167    static unsigned char *screenBuffer;
168    static Texture2D *legendTexture;
169    static Grid *grid;
170    static nv::util::Fonts *fonts;
171    static int updir;
172    static NvCamera *cam;
173    static nv::graphics::RenderContext *renderContext;
174
175    static Tcl_HashTable tfTable;
176    static Tcl_HashTable volumeTable;
177    static Tcl_HashTable flowTable;
178    static Tcl_HashTable heightmapTable;
179
180    static double magMin, magMax;
181    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
182    static vrmath::Vector3f sceneMin, sceneMax;
183
184    static NvColorTableRenderer *colorTableRenderer;
185    static VolumeRenderer *volRenderer;
186#ifdef notdef
187    static NvFlowVisRenderer *flowVisRenderer;
188#endif
189    static VelocityArrowsSlice *velocityArrowsSlice;
190    static NvLIC *licRenderer;
191    static PlaneRenderer *planeRenderer;
192#if PLANE_CMD
193    static int numPlanes;
194    static Texture2D *plane[]; ///< Pointers to 2D planes
195#endif
196#ifdef USE_POINTSET_RENDERER
197    static PointSetRenderer *pointSetRenderer;
198    static std::vector<PointSet *> pointSet;
199#endif
200
201    static Tcl_Interp *interp;
202    static struct timeval startTime;           /* Start of elapsed time. */
203private:
204    static void collectBounds(bool onlyVisible = false);
205
206    static float _licSlice;  ///< Slice position [0,1]
207    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
208
209    //frame buffer for final rendering
210    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
211};
212
213#endif
Note: See TracBrowser for help on using the repository browser.