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

Last change on this file since 2825 was 2816, checked in by ldelgass, 13 years ago

Fix Volume::add_cutplane and use it.

  • 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
17#include <memory.h>
18#include <assert.h>
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, double v0, double v1, double nz_min) :
29    _tfPtr(NULL),
30    _specular(6.),              // default value
31    _diffuse(3.),               // default value
32    _opacity_scale(10.),        // default value
33    _name(NULL),
34    _n_components(n),
35    _nonzero_min(nz_min),
36    _pointsetIndex(-1),
37    _n_slices(512),             // default value
38    _enabled(true),
39    //n_slice(256),             // default value
40    _data_enabled(true),        // default value
41    _outline_enabled(true),     // default value
42    _outline_color(1.,1.,1.),   // default value
43    _volume_type(CUBIC),        // default is a cubic volume
44    _iso_surface(0),
45    width(w),
46    height(h),
47    depth(d),
48    size(s)
49{
50    _tex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n);
51    int fcount = width * height * depth * _n_components;
52    _data = new float[fcount];
53    if (data != NULL) {
54        TRACE("data is copied\n");
55        memcpy(_data, data, fcount * sizeof(float));
56        _tex->initialize(_data);
57    } else {
58        TRACE("data is null\n");
59        memset(_data, 0, sizeof(width * height * depth * _n_components *
60                                sizeof(float)));
61        _tex->initialize(_data);
62    }
63
64    id = _tex->id;
65
66    wAxis.SetRange(v0, v1);
67
68    // VOLUME
69    aspect_ratio_width  = s * _tex->aspect_ratio_width;
70    aspect_ratio_height = s * _tex->aspect_ratio_height;
71    aspect_ratio_depth =  s * _tex->aspect_ratio_depth;
72
73    _location = Vector3(x, y, z);
74
75    //Add cut planes. We create 3 default cut planes facing x, y, z directions.
76    //The default location of cut plane is in the middle of the data.
77    _plane.clear();
78    add_cutplane(1, 0.5f);
79    add_cutplane(2, 0.5f);
80    add_cutplane(3, 0.5f);
81
82    //initialize the labels 
83    label[0] = "X Label";
84    label[1] = "Y Label";
85    label[2] = "Z Label";
86
87    TRACE("End -- Volume constructor\n");
88}
89
90Volume::~Volume()
91{
92    if (_pointsetIndex != -1) {
93        // TBD...
94    }
95
96    delete [] _data;
97
98    delete _tex;
99}
Note: See TracBrowser for help on using the repository browser.