source: trunk/vizservers/nanovis/Volume.h @ 823

Last change on this file since 823 was 799, checked in by vrinside, 17 years ago

remove a statement 'using namespace std;' in order to avoid a conflict with string.h
replace vector with std::vector

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