source: trunk/gui/vizservers/nanovis/Volume.h @ 723

Last change on this file since 723 was 580, checked in by vrinside, 17 years ago
File size: 4.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 * Volume.h: 3d volume class
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
16#ifndef _VOLUME_H_
17#define _VOLUME_H_
18
19#include <string>
20#include <vector>
21
22#include "define.h"
23#include "Color.h"
24#include "Texture3D.h"
25#include "Vector3.h"
26
27using namespace std;
28
29struct CutPlane{
30  int orient;   //orientation - 1: xy slice, 2: yz slice, 3: xz slice
31  float offset; //normalized offset [0,1] in the volume
32  bool enabled;
33
34  CutPlane(int _orient, float _offset):
35        orient(_orient),
36        offset(_offset),
37        enabled(true){}
38};
39
40
41
42enum {CUBIC, VOLQD, ZINCBLENDE};
43
44
45class Volume{
46       
47
48public:
49        int volume_type;        //cubic or zincblende
50
51        vector <CutPlane> plane; //cut planes
52        int n_components;
53
54        Texture3D* tex; //OpenGL texture storing the volume
55        double vmin;    //minimum (unscaled) value in data
56        double vmax;    //maximum (unscaled) value in data
57
58        float specular; //specular lighting parameter
59        float diffuse;  //diffuse lighting parameter
60        float opacity_scale;    //The scale multiplied to the opacity assigned by the transfer function.
61                                //Rule of thumb: higher opacity_scale the object is to appear like plastic
62
63        bool data_enabled;      // show/hide cloud of volume data
64
65        bool outline_enabled;   // show/hide outline around volume
66        Color outline_color;    // color for outline around volume
67
68
69
70        Vector3 location;
71
72        bool enabled;
73        int n_slice;    //number of slices when rendered. The greater the better quality, lower speed.
74
75        int width;      //The resolution of the data (how many points in each direction.
76        int height;     //It is different from the size of the volume object drawn on screen.
77        int depth;      //Width, height and depth together determing the proprotion of the volume ONLY.
78       
79        float size;     //This is the scaling factor that will size the volume on screen.
80                        //A render program drawing different objects, always knows how large an object
81                        //is in relation to other objects. This size is provided by the render engine.
82
83        float aspect_ratio_width;
84        float aspect_ratio_height;
85        float aspect_ratio_depth;
86
87        NVISid id;   //OpenGL textue identifier (==tex->id)
88
89        Volume(float x, float y, float z,
90                        int width, int height, int depth, float size,
91                        int n_component, float* data, double vmin, double vmax);
92        ~Volume();
93       
94        void enable(); //VolumeRenderer will render an enabled volume and its cutplanes
95        void disable();
96        void move(Vector3 _loc);
97        bool is_enabled();
98        Vector3* get_location();
99
100        double range_min() { return vmin; }
101        double range_max() { return vmax; }
102
103        void set_n_slice(int val); //set number of slices
104        int get_n_slice();      //return number of slices
105
106        void set_size(float s); //set the drawing size of volume
107
108        //methods related to cutplanes
109        int add_cutplane(int _orientation, float _location); //add a plane and returns its index
110        void enable_cutplane(int index);
111        void disable_cutplane(int index);
112        void move_cutplane(int index, float _location);
113        CutPlane* get_cutplane(int index);
114        int get_cutplane_count();       //returns the number of cutplanes in the volume
115        bool cutplane_is_enabled(int index);    //check if a cutplane is enabled
116
117        //methods related to shading. These parameters are per volume
118        float get_specular();
119        float get_diffuse();
120        float get_opacity_scale();
121        void set_specular(float s);
122        void set_diffuse(float d);
123        void set_opacity_scale(float s);
124
125        void enable_data();
126        void disable_data();
127        bool data_is_enabled();
128
129        void enable_outline();
130        void disable_outline();
131        bool outline_is_enabled();
132        void set_outline_color(float* rgb);
133        void get_outline_color(float* rgb);
134
135
136        void set_label(int axis, char* txt);    //change the label displayed on an axis
137        std::string label[3];   // the labels along each axis 0:x , 1:y, 2:z
138};
139
140#endif
Note: See TracBrowser for help on using the repository browser.