source: nanovis/trunk/nanovis.h @ 5722

Last change on this file since 5722 was 5717, checked in by ldelgass, 4 years ago

Downsample volume if dims exceed hardware limits

  • Property svn:eol-style set to native
File size: 5.0 KB
RevLine 
[2798]1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
[226]2/*
3 * ----------------------------------------------------------------------
4 *  nanovis.h: package header
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
[3502]10 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
[226]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 */
[3614]16#ifndef NV_NANOVIS_H
17#define NV_NANOVIS_H
[259]18
[4887]19#include <cstddef> // For size_t
20#include <string>
21#include <tr1/unordered_map>
[226]22
[3605]23#include <tcl.h>
24
25#include <GL/glew.h>
26
[3630]27#include <vrmath/BBox.h>
[3492]28#include <vrmath/Vector3f.h>
[2818]29
[251]30#include "config.h"
[3630]31#include "Camera.h"
[226]32
33//defines for the image based flow visualization
34#define NMESH 256       //resolution of flow mesh
35#define NPIX  512       //display size
36
[3463]37namespace nv {
[2831]38namespace graphics {
39    class RenderContext;
40}
[3463]41namespace util {
42    class Fonts;
43}
[3611]44
45class Flow;
46class Grid;
47class HeightMap;
48class LIC;
[3605]49class OrientationIndicator;
50class PlaneRenderer;
[2831]51class Texture2D;
52class TransferFunction;
[3611]53class VelocityArrowsSlice;
[2831]54class Volume;
[3611]55class VolumeRenderer;
[1370]56
[2822]57class NanoVis
58{
[2831]59public:
[3567]60    typedef std::string TransferFunctionId;
61    typedef std::string VolumeId;
62    typedef std::string FlowId;
63    typedef std::string HeightMapId;
64    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
65    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
[3597]66    typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap;
[3567]67    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
68
[3605]69    static bool init(const char *path);
70    static bool initGL();
71    static bool initOffscreenBuffer();
72    static bool resizeOffscreenBuffer(int w, int h);
[3478]73    static void setBgColor(float color[3]);
[3497]74    static void render();
[2847]75    static void update();
[2951]76    static void removeAllData();
[2930]77
[3611]78    static const Camera *getCamera()
[3362]79    {
[3630]80        return _camera;
[3362]81    }
[3630]82    static void panCamera(float dx, float dy);
83    static void zoomCamera(float z);
84    static void orientCamera(double *quat);
85    static void setCameraPosition(vrmath::Vector3f pos);
86    static void setCameraUpdir(Camera::AxisDirection dir);
[3492]87    static void resetCamera(bool resetOrientation = false);
[1299]88
[3630]89    static void eventuallyRedraw();
[4949]90
[3567]91    static TransferFunction *getTransferFunction(const TransferFunctionId& id);
92    static TransferFunction *defineTransferFunction(const TransferFunctionId& id, 
[2847]93                                                    size_t n, float *data);
94
[2877]95    static int renderLegend(TransferFunction *tf, double min, double max, 
[5716]96                            int width, int height, const char *tag);
[2847]97
[2877]98    static Volume *loadVolume(const char *tag, int width, int height, int depth,
[3597]99                              int numComponents, float *data, double vmin, double vmax, 
[2877]100                              double nonZeroMin);
[1156]101
[3597]102    static void removeVolume(Volume *volume);
[2877]103
104    static void readScreen()
[2822]105    {
[3605]106        glPixelStorei(GL_PACK_ALIGNMENT, 1);
[2877]107        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, 
108                     screenBuffer);
[1028]109    }
[2930]110    static void bindOffscreenBuffer()
[2822]111    {
[2877]112        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
[1028]113    }
[1431]114
[3630]115    static void setVolumeRanges();
116    static void setHeightmapRanges();
[3935]117    static bool setFlowRanges();
[3630]118
[3597]119    static Flow *getFlow(const char *name);
120    static Flow *createFlow(Tcl_Interp *interp, const char *name);
[3605]121    static void deleteFlows(Tcl_Interp *interp);
[3567]122    static void deleteFlow(const char *name);
[3935]123
[3566]124    static void renderFlows();
125    static void resetFlows();
126    static bool updateFlows();
127    static void advectFlows();
[2831]128
[3605]129    static Tcl_Interp *interp;
130
[3630]131    static bool redrawPending;
[2877]132    static bool debugFlag;
[3567]133
134    static int winWidth;        ///< Width of the render window
135    static int winHeight;       ///< Height of the render window
[3630]136    static int renderWindow;    ///< GLUT handle for the render window
[2877]137    static unsigned char *screenBuffer;
[2951]138    static Texture2D *legendTexture;
[3611]139    static util::Fonts *fonts;
140    static graphics::RenderContext *renderContext;
[5717]141    static GLint max3dTextureSize;
[2846]142
[3567]143    static TransferFunctionHashmap tfTable; ///< maps transfunc name to TransferFunction object
144    static VolumeHashmap volumeTable;
145    static FlowHashmap flowTable;
146    static HeightMapHashmap heightMapTable;
[2846]147
[3630]148    static vrmath::BBox sceneBounds;
[2846]149
[2877]150    static VolumeRenderer *volRenderer;
[2846]151    static VelocityArrowsSlice *velocityArrowsSlice;
[3611]152    static LIC *licRenderer;
[2877]153    static PlaneRenderer *planeRenderer;
[3611]154    static OrientationIndicator *orientationIndicator;
[3605]155    static Grid *grid;
[3568]156
[2831]157private:
[3492]158    static void collectBounds(bool onlyVisible = false);
159
[3630]160    static Camera *_camera;
[2877]161
[2831]162    //frame buffer for final rendering
[2877]163    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
[835]164};
[851]165
[3611]166}
167
[2831]168#endif
Note: See TracBrowser for help on using the repository browser.