source: trunk/packages/vizservers/nanovis/Volume.cpp @ 2844

Last change on this file since 2844 was 2844, checked in by ldelgass, 8 years ago

Cleanups, no functional changes

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 * Volume.cpp: 3d volume class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2006  Purdue Research Foundation
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#include <memory.h>
17#include <assert.h>
18
19#include "Volume.h"
20#include "Trace.h"
21
22bool Volume::update_pending = false;
23double Volume::valueMin = 0.0;
24double Volume::valueMax = 1.0;
25
26Volume::Volume(float x, float y, float z,
27               int w, int h, int d, float s,
28               int n, float *data,
29               double v0, double v1, double nz_min) :
30    aspect_ratio_width(1),
31    aspect_ratio_height(1),
32    aspect_ratio_depth(1),
33    id(0),
34    width(w),
35    height(h),
36    depth(d),
37    size(s),
38    pointsetIndex(-1),
39    _tfPtr(NULL),
40    _specular(6.),              // default value
41    _diffuse(3.),               // default value
42    _opacity_scale(10.),        // default value
43    _name(NULL),
44    _data(NULL),
45    _n_components(n),
46    _nonzero_min(nz_min),
47    _tex(NULL),
48    _location(x, y, z),
49    _n_slices(512),             // default value
50    _enabled(true),
51    _data_enabled(true),        // default value
52    _outline_enabled(true),     // default value
53    _outline_color(1., 1., 1.), // default value
54    _volume_type(CUBIC),        // default is a cubic volume
55    _iso_surface(0)
56{
57    _tex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n);
58    int fcount = width * height * depth * _n_components;
59    _data = new float[fcount];
60    if (data != NULL) {
61        TRACE("data is copied\n");
62        memcpy(_data, data, fcount * sizeof(float));
63        _tex->initialize(_data);
64    } else {
65        TRACE("data is null\n");
66        memset(_data, 0, sizeof(width * height * depth * _n_components *
67                                sizeof(float)));
68        _tex->initialize(_data);
69    }
70
71    id = _tex->id;
72
73    wAxis.SetRange(v0, v1);
74
75    // VOLUME
76    aspect_ratio_width  = s * _tex->aspect_ratio_width;
77    aspect_ratio_height = s * _tex->aspect_ratio_height;
78    aspect_ratio_depth =  s * _tex->aspect_ratio_depth;
79
80    //Add cut planes. We create 3 default cut planes facing x, y, z directions.
81    //The default location of cut plane is in the middle of the data.
82    _plane.clear();
83    add_cutplane(1, 0.5f);
84    add_cutplane(2, 0.5f);
85    add_cutplane(3, 0.5f);
86
87    //initialize the labels 
88    label[0] = "X Label";
89    label[1] = "Y Label";
90    label[2] = "Z Label";
91
92    TRACE("End -- Volume constructor\n");
93}
94
95Volume::~Volume()
96{
97    if (pointsetIndex != -1) {
98        // TBD...
99    }
100
101    delete [] _data;
102    delete _tex;
103}
Note: See TracBrowser for help on using the repository browser.