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

Last change on this file since 3935 was 3935, checked in by ldelgass, 6 years ago

First pass at loading VTK vector data for flows in nanovis

  • Property svn:eol-style set to native
File size: 5.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 NV_NANOVIS_H
17#define NV_NANOVIS_H
18
19#include <math.h>
20#include <stddef.h> // For size_t
21#include <stdio.h>
22#include <sys/time.h>
23#include <sys/types.h> // For pid_t
24
25#include <tcl.h>
26
27#include <GL/glew.h>
28
29#include <vector>
30#include <iostream>
31#include <tr1/unordered_map>
32
33#include <vrmath/BBox.h>
34#include <vrmath/Vector3f.h>
35
36#include "config.h"
37#include "Camera.h"
38#include "FlowTypes.h"
39#include "md5.h"
40
41//defines for the image based flow visualization
42#define NMESH 256       //resolution of flow mesh
43#define NPIX  512       //display size
44
45namespace nv {
46namespace graphics {
47    class RenderContext;
48}
49namespace util {
50    class Fonts;
51}
52
53class Flow;
54class Grid;
55class HeightMap;
56class LIC;
57class OrientationIndicator;
58class PlaneRenderer;
59class Texture2D;
60class TransferFunction;
61class VelocityArrowsSlice;
62class Volume;
63class VolumeRenderer;
64
65class NanoVis
66{
67public:
68    typedef std::string TransferFunctionId;
69    typedef std::string VolumeId;
70    typedef std::string FlowId;
71    typedef std::string HeightMapId;
72    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
73    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
74    typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap;
75    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
76
77    static bool init(const char *path);
78    static bool initGL();
79    static bool initOffscreenBuffer();
80    static bool resizeOffscreenBuffer(int w, int h);
81    static void setBgColor(float color[3]);
82    static void render();
83    static void update();
84    static void removeAllData();
85
86    static const Camera *getCamera()
87    {
88        return _camera;
89    }
90    static void panCamera(float dx, float dy);
91    static void zoomCamera(float z);
92    static void orientCamera(double *quat);
93    static void setCameraPosition(vrmath::Vector3f pos);
94    static void setCameraUpdir(Camera::AxisDirection dir);
95    static void resetCamera(bool resetOrientation = false);
96
97    static void eventuallyRedraw();
98 
99    static TransferFunction *getTransferFunction(const TransferFunctionId& id);
100    static TransferFunction *defineTransferFunction(const TransferFunctionId& id, 
101                                                    size_t n, float *data);
102
103    static int renderLegend(TransferFunction *tf, double min, double max, 
104                            int width, int height, const char *volArg);
105
106    static Volume *loadVolume(const char *tag, int width, int height, int depth,
107                              int numComponents, float *data, double vmin, double vmax, 
108                              double nonZeroMin);
109
110    static void removeVolume(Volume *volume);
111
112    static void readScreen()
113    {
114        glPixelStorei(GL_PACK_ALIGNMENT, 1);
115        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, 
116                     screenBuffer);
117    }
118    static void bindOffscreenBuffer()
119    {
120        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
121    }
122
123    static void setVolumeRanges();
124    static void setHeightmapRanges();
125    static bool setFlowRanges();
126
127    static Flow *getFlow(const char *name);
128    static Flow *createFlow(Tcl_Interp *interp, const char *name);
129    static void deleteFlows(Tcl_Interp *interp);
130    static void deleteFlow(const char *name);
131
132    static void renderFlows();
133    static void resetFlows();
134    static bool updateFlows();
135    static void advectFlows();
136
137    static Tcl_Interp *interp;
138
139    static bool redrawPending;
140    static bool debugFlag;
141
142    static int winWidth;        ///< Width of the render window
143    static int winHeight;       ///< Height of the render window
144    static int renderWindow;    ///< GLUT handle for the render window
145    static unsigned char *screenBuffer;
146    static Texture2D *legendTexture;
147    static util::Fonts *fonts;
148    static graphics::RenderContext *renderContext;
149
150    static TransferFunctionHashmap tfTable; ///< maps transfunc name to TransferFunction object
151    static VolumeHashmap volumeTable;
152    static FlowHashmap flowTable;
153    static HeightMapHashmap heightMapTable;
154
155    static vrmath::BBox sceneBounds;
156
157    static VolumeRenderer *volRenderer;
158    static VelocityArrowsSlice *velocityArrowsSlice;
159    static LIC *licRenderer;
160    static PlaneRenderer *planeRenderer;
161    static OrientationIndicator *orientationIndicator;
162    static Grid *grid;
163
164private:
165    static void collectBounds(bool onlyVisible = false);
166
167    static Camera *_camera;
168
169    //frame buffer for final rendering
170    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
171};
172
173}
174
175#endif
Note: See TracBrowser for help on using the repository browser.