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

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

Fix crash on getting transfer function name, remove unused plane command.

  • Property svn:eol-style set to native
File size: 6.4 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 */
[2831]16#ifndef NANOVIS_H
17#define NANOVIS_H
[259]18
[850]19#include <tcl.h>
[3377]20#include <md5.h>
[226]21#include <GL/glew.h>
[2831]22
[226]23#include <math.h>
[2831]24#include <stddef.h> // For size_t
[226]25#include <stdio.h>
26
[2831]27#include <vector>
28#include <iostream>
[3567]29#include <tr1/unordered_map>
[2831]30
[3492]31#include <vrmath/Vector3f.h>
[2818]32
[251]33#include "config.h"
[226]34
[3362]35#define NANOVIS_VERSION         "1.1"
[251]36
[226]37//defines for the image based flow visualization
38#define NMESH 256       //resolution of flow mesh
39#define NPIX  512       //display size
40
[3463]41namespace nv {
[2831]42namespace graphics {
43    class RenderContext;
44}
[3463]45namespace util {
46    class Fonts;
47}
48}
[2831]49
50class VolumeRenderer;
51class PointSetRenderer;
52class NvParticleRenderer;
53class NvFlowVisRenderer;
54class PlaneRenderer;
55class VelocityArrowsSlice;
56class NvLIC;
57class PointSet;
58class Texture2D;
59class NvColorTableRenderer;
60class HeightMap;
[1370]61class NvVectorField;
[2831]62class Grid;
63class NvCamera;
64class TransferFunction;
65class Volume;
66class FlowCmd;
[1370]67
[2822]68class NanoVis
69{
[2831]70public:
[3492]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
[2831]80    enum NanoVisFlags {
81        REDRAW_PENDING = (1 << 0),
[3492]82        MAP_FLOWS = (1 << 1)
[2831]83    };
[2822]84
[3567]85    typedef std::string TransferFunctionId;
86    typedef std::string VolumeId;
87    typedef std::string FlowId;
88    typedef std::string HeightMapId;
89    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
90    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
91    typedef std::tr1::unordered_map<FlowId, FlowCmd *> FlowHashmap;
92    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
93
[3452]94    static void processCommands();
[2831]95    static void init(const char *path);
96    static void initGL();
[2877]97    static void initOffscreenBuffer();
98    static void resizeOffscreenBuffer(int w, int h);
[3478]99    static void setBgColor(float color[3]);
[3497]100    static void render();
[2951]101    static void draw3dAxis();
[2847]102    static void idle();
103    static void update();
[2951]104    static void removeAllData();
[2930]105
[3362]106    static const NvCamera *getCamera()
107    {
108        return cam;
109    }
[2847]110    static void pan(float dx, float dy);
111    static void zoom(float z);
[3492]112    static void resetCamera(bool resetOrientation = false);
[1299]113
[2877]114    static void eventuallyRedraw(unsigned int flag = 0);
[2847]115
[2877]116    static void setVolumeRanges();
117    static void setHeightmapRanges();
[3362]118
119#ifdef KEEPSTATS
[3377]120    static int getStatsFile(Tcl_Obj *objPtr);
121    static int writeToStatsFile(int f, const char *s, size_t length);
[2951]122#endif
[2877]123    static void ppmWrite(const char *prefix);
[1295]124    static void sendDataToClient(const char *command, const char *data,
[2831]125                                 size_t dlen);
[2877]126    static void bmpWrite(const char *prefix);
127    static void bmpWriteToFile(int frame_number, const char* directory_name);
[2847]128 
[3567]129    static TransferFunction *getTransferFunction(const TransferFunctionId& id);
130    static TransferFunction *defineTransferFunction(const TransferFunctionId& id,
[2847]131                                                    size_t n, float *data);
132
[2877]133    static int renderLegend(TransferFunction *tf, double min, double max,
134                            int width, int height, const char *volArg);
[2847]135
[2877]136    static Volume *loadVolume(const char *tag, int width, int height, int depth,
137                              int n, float* data, double vmin, double vmax,
138                              double nonZeroMin);
[1156]139
[2877]140    static void removeVolume(Volume *volPtr);
141
142    static void readScreen()
[2822]143    {
[2877]144        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
145                     screenBuffer);
[1028]146    }
[2930]147    static void bindOffscreenBuffer()
[2822]148    {
[2877]149        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
[1028]150    }
[1431]151
[3567]152    static FlowCmd *getFlow(const char *name);
153    static FlowCmd *createFlow(Tcl_Interp *interp, const char *name);
154    static void deleteFlow(const char *name);
[3566]155    static void deleteFlows(Tcl_Interp *interp);
156    static bool mapFlows();
157    static void getFlowBounds(vrmath::Vector3f& min,
[3492]158                              vrmath::Vector3f& max,
159                              bool onlyVisible = false);
[3566]160    static void renderFlows();
161    static void resetFlows();
162    static bool updateFlows();
163    static void advectFlows();
[2831]164
[2846]165    static FILE *stdin, *logfile, *recfile;
[3376]166    static int statsFile;
[2846]167    static unsigned int flags;
[2877]168    static bool debugFlag;
169    static bool axisOn;
[3567]170    static struct timeval startTime;       ///< Start of elapsed time.
171
172    static int winWidth;        ///< Width of the render window
173    static int winHeight;       ///< Height of the render window
174    static int renderWindow;    //< GLUT handle for the render window
[2877]175    static unsigned char *screenBuffer;
[2951]176    static Texture2D *legendTexture;
[2846]177    static Grid *grid;
[3463]178    static nv::util::Fonts *fonts;
[2846]179    static int updir;
180    static NvCamera *cam;
[3463]181    static nv::graphics::RenderContext *renderContext;
[2846]182
[3567]183    static TransferFunctionHashmap tfTable; ///< maps transfunc name to TransferFunction object
184    static VolumeHashmap volumeTable;
185    static FlowHashmap flowTable;
186    static HeightMapHashmap heightMapTable;
[2846]187
188    static double magMin, magMax;
189    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
[3492]190    static vrmath::Vector3f sceneMin, sceneMax;
[2846]191
[2951]192    static NvColorTableRenderer *colorTableRenderer;
[2877]193    static VolumeRenderer *volRenderer;
[2951]194#ifdef notdef
[2846]195    static NvFlowVisRenderer *flowVisRenderer;
[2951]196#endif
[2846]197    static VelocityArrowsSlice *velocityArrowsSlice;
198    static NvLIC *licRenderer;
[2877]199    static PlaneRenderer *planeRenderer;
[3568]200
[2846]201#ifdef USE_POINTSET_RENDERER
[2877]202    static PointSetRenderer *pointSetRenderer;
[2846]203    static std::vector<PointSet *> pointSet;
204#endif
205
206    static Tcl_Interp *interp;
[3567]207
[2831]208private:
[3492]209    static void collectBounds(bool onlyVisible = false);
210
[3362]211    static float _licSlice;  ///< Slice position [0,1]
212    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
[2877]213
[2831]214    //frame buffer for final rendering
[2877]215    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
[835]216};
[851]217
[2831]218#endif
Note: See TracBrowser for help on using the repository browser.