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

Last change on this file since 3464 was 3452, checked in by ldelgass, 7 years ago

Remove XINETD define from nanovis. We only support server mode now, no glut
interaction loop with mouse/keyboard handlers. Fixes for trace logging to make
output closer to vtkvis: inlcude function name for trace messages, remove
newlines from format strings in macros since newlines get added by syslog.

  • Property svn:eol-style set to native
File size: 2.4 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-2012  HUBzero Foundation, LLC
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::updatePending = 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,
28               int n, float *data,
29               double v0, double v1, double nonZeroMin) :
30    _id(0),
31    _width(w),
32    _height(h),
33    _depth(d),
34    _tfPtr(NULL),
35    _ambient(0.6f),
36    _diffuse(0.4f),
37    _specular(0.3f),
38    _specularExp(90.0f),
39    _lightTwoSide(false),
40    _opacityScale(0.5f),
41    _name(NULL),
42    _data(NULL),
43    _numComponents(n),
44    _nonZeroMin(nonZeroMin),
45    _tex(NULL),
46    _location(x, y, z),
47    _numSlices(512),
48    _enabled(true),
49    _dataEnabled(true),
50    _outlineEnabled(true),
51    _outlineColor(1., 1., 1.),
52    _volumeType(CUBIC),
53    _isosurface(0)
54{
55    TRACE("Enter: %dx%dx%d", _width, _height, _depth);
56
57    _tex = new Texture3D(_width, _height, _depth, GL_FLOAT, GL_LINEAR, n);
58    int fcount = _width * _height * _depth * _numComponents;
59    _data = new float[fcount];
60    if (data != NULL) {
61        TRACE("data is copied");
62        memcpy(_data, data, fcount * sizeof(float));
63        _tex->initialize(_data);
64    } else {
65        TRACE("data is null");
66        memset(_data, 0, sizeof(_width * _height * _depth * _numComponents * 
67                                sizeof(float)));
68        _tex->initialize(_data);
69    }
70
71    _id = _tex->id();
72
73    wAxis.setRange(v0, v1);
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    addCutplane(1, 0.5f);
79    addCutplane(2, 0.5f);
80    addCutplane(3, 0.5f);
81
82    TRACE("Leave");
83}
84
85Volume::~Volume()
86{
87    TRACE("Enter");
88
89    delete [] _data;
90    delete _tex;
91}
Note: See TracBrowser for help on using the repository browser.