Ignore:
Timestamp:
Apr 16, 2013, 12:52:20 AM (11 years ago)
Author:
ldelgass
Message:

Nanovis refactoring to fix problems with scaling and multiple results.
Do rendering in world space to properly place and scale multiple data sets.
Also fix flows to reduce resets of animations. More work toward removing
Cg dependency. Fix panning to convert viewport coords to world coords.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Volume.cpp

    r3611 r3630  
    3131double Volume::valueMax = 1.0;
    3232
    33 Volume::Volume(float x, float y, float z,
    34                int w, int h, int d,
     33Volume::Volume(int w, int h, int d,
    3534               int n, float *data,
    3635               double v0, double v1, double nonZeroMin) :
     
    5049    _nonZeroMin(nonZeroMin),
    5150    _tex(NULL),
    52     _location(x, y, z),
     51    _position(0,0,0),
     52    _scale(1,1,1),
    5353    _numSlices(512),
    5454    _enabled(true),
     
    6565    int fcount = _width * _height * _depth * _numComponents;
    6666    _data = new float[fcount];
    67     if (data != NULL) {
    68         TRACE("data is copied");
    69         memcpy(_data, data, fcount * sizeof(float));
    70         _tex->initialize(_data);
    71     } else {
    72         TRACE("data is null");
    73         memset(_data, 0, sizeof(_width * _height * _depth * _numComponents *
    74                                 sizeof(float)));
    75         _tex->initialize(_data);
    76     }
     67    memcpy(_data, data, fcount * sizeof(float));
     68    _tex->initialize(_data);
    7769
    7870    _id = _tex->id();
     
    8375    //The default location of cut plane is in the middle of the data.
    8476    _plane.clear();
    85     addCutplane(1, 0.5f);
    86     addCutplane(2, 0.5f);
    87     addCutplane(3, 0.5f);
     77    addCutplane(CutPlane::X_AXIS, 0.5f);
     78    addCutplane(CutPlane::Y_AXIS, 0.5f);
     79    addCutplane(CutPlane::Z_AXIS, 0.5f);
    8880
    8981    TRACE("Leave");
     
    9890}
    9991
    100 void Volume::getWorldSpaceBounds(Vector3f& bboxMin, Vector3f& bboxMax) const
     92void Volume::setData(float *data, double v0, double v1, double nonZeroMin)
    10193{
    102     Vector3f scale = getPhysicalScaling();
     94    int fcount = _width * _height * _depth * _numComponents;
     95    memcpy(_data, data, fcount * sizeof(float));
     96    _tex->update(_data);
     97    wAxis.setRange(v0, v1);
     98    _nonZeroMin = nonZeroMin;
     99    updatePending = true;
     100}
    103101
    104     Matrix4x4d mat;
    105     mat.makeTranslation(_location);
    106     Matrix4x4d mat2;
    107     mat2.makeScale(scale);
    108 
    109     mat.multiply(mat2);
    110 
    111     bboxMin.set(FLT_MAX, FLT_MAX, FLT_MAX);
    112     bboxMax.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
    113 
    114     Vector3f modelMin(0, 0, 0);
    115     Vector3f modelMax(1, 1, 1);
    116 
    117     Vector4f bvert[8];
    118     bvert[0] = Vector4f(modelMin.x, modelMin.y, modelMin.z, 1);
    119     bvert[1] = Vector4f(modelMax.x, modelMin.y, modelMin.z, 1);
    120     bvert[2] = Vector4f(modelMin.x, modelMax.y, modelMin.z, 1);
    121     bvert[3] = Vector4f(modelMin.x, modelMin.y, modelMax.z, 1);
    122     bvert[4] = Vector4f(modelMax.x, modelMax.y, modelMin.z, 1);
    123     bvert[5] = Vector4f(modelMax.x, modelMin.y, modelMax.z, 1);
    124     bvert[6] = Vector4f(modelMin.x, modelMax.y, modelMax.z, 1);
    125     bvert[7] = Vector4f(modelMax.x, modelMax.y, modelMax.z, 1);
    126 
    127     for (int i = 0; i < 8; i++) {
    128         Vector4f worldVert = mat.transform(bvert[i]);
    129         if (worldVert.x < bboxMin.x) bboxMin.x = worldVert.x;
    130         if (worldVert.x > bboxMax.x) bboxMax.x = worldVert.x;
    131         if (worldVert.y < bboxMin.y) bboxMin.y = worldVert.y;
    132         if (worldVert.y > bboxMax.y) bboxMax.y = worldVert.y;
    133         if (worldVert.z < bboxMin.z) bboxMin.z = worldVert.z;
    134         if (worldVert.z > bboxMax.z) bboxMax.z = worldVert.z;
    135     }
     102void Volume::getBounds(Vector3f& bboxMin, Vector3f& bboxMax) const
     103{
     104    bboxMin.set(xAxis.min(), yAxis.min(), zAxis.min());
     105    bboxMax.set(xAxis.max(), yAxis.max(), zAxis.max());
    136106}
Note: See TracChangeset for help on using the changeset viewer.