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

Last change on this file since 1380 was 1370, checked in by vrinside, 15 years ago

improving the flow vis engine

  • particle advection for multiple vector field
  • specifying multiple advection planes
  • specifying the position of a particle injection plane
  • specifying the axis of a particle injection plane
  • specifying the visibility of particle injection planes
  • specifying the particle color for each particle injection plane
  • rendering device shapes

[NOTE] Currently, I commented out with the MACRO NEW_FLOW_ENGINE in config
To use this, please comment NEW_FLOW_ENGINE in

File size: 2.7 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 * Volume.cpp: 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#include <memory.h>
17#include <assert.h>
18#include "Volume.h"
19#include "Trace.h"
20
21bool Volume::update_pending = false;
22double Volume::valueMin = 0.0;
23double Volume::valueMax = 1.0;
24
25Volume::Volume(
26                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    width(w),
30    height(h),
31    depth(d),
32    size(s),
33    n_components(n),
34    nonzero_min(nz_min),
35    pointsetIndex(-1),
36    enabled(true),
37    //n_slice(256),             // default value
38    n_slice(512),               // default value
39    specular(6.),               // default value
40    diffuse(3.),                // default value
41    opacity_scale(10.),         // default value
42    data_enabled(true),         // default value
43    outline_enabled(true),      // default value
44    outline_color(1.,1.,1.),    // default value
45    volume_type(CUBIC),         //by default, is a cubic volume
46    iso_surface(0)
47{
48    tex = new Texture3D(w, h, d, NVIS_FLOAT, NVIS_LINEAR_INTERP, n);
49    int fcount = width * height * depth * n_components;
50    _data = new float[fcount];
51    if (data) {
52        Trace("data is copied\n");
53        memcpy(_data, data, fcount * sizeof(float));
54        tex->initialize(_data);
55    } else {
56        Trace("data is null\n");
57        memset(_data, 0, sizeof(width * height * depth * n_components *
58                                sizeof(float)));
59        tex->initialize(_data);
60    }
61
62    id = tex->id;
63   
64    wAxis.SetRange(v0, v1);
65
66        // VOLUME
67        aspect_ratio_width = s*tex->aspect_ratio_width;
68        aspect_ratio_height = s*tex->aspect_ratio_height;
69        aspect_ratio_depth = s*tex->aspect_ratio_depth;
70   
71    location = Vector3(x,y,z);
72   
73    //Add cut planes. We create 3 default cut planes facing x, y, z directions.
74    //The default location of cut plane is in the middle of the data.
75    plane.clear();
76    plane.push_back(CutPlane(1, 0.5));
77    plane.push_back(CutPlane(2, 0.5));
78    plane.push_back(CutPlane(3, 0.5));
79   
80    //initialize the labels 
81    label[0] = "X Label";
82    label[1] = "Y Label";
83    label[2] = "Z Label";
84
85    Trace("End -- Volume constructor\n");
86}
87
88Volume::~Volume()
89{
90    if (pointsetIndex != -1)
91    {
92        // TBD...
93    }
94
95    delete [] _data;
96
97    delete tex;
98}
Note: See TracBrowser for help on using the repository browser.