1

我想融合第 10 课和第 17 课来可视化音量、规范切片(如第 10 课中所示)和 sliceX 的重新切片(第 17 课)。为此,我修改了第 10 课的代码。

检测到的问题有:

  1. 启用体积渲染时会出现切片 X。
  2. 音量消失了!!!!
  3. 启用体积渲染时,仅在屏幕上显示 X 切片。

在以下情况下会出现问题:

问题出现在体积可视化上。当我们在体积可视化和切片可视化之间切换时,当我们在体积可视化时,我们需要移动体积,然后就会出现错误。

具体错误在volume.js的第1385行(昨天下载的master分支,commit 318986e6b1d4a195a78b87f81a082ca249cbd866)...截图: https ://mega.co.nz/#!d8hVCIhY!TWegqY2pRPcvl09CyMocJYeZu55sDOc_xRCiAed2Jhg

错误:未捕获的类型错误:无法设置未定义 volume.js:1385 的属性“_visible”

    for (i = 0; i < _numberOfSlices; i++) {
       //THE ERROR IS IN THE NEXT LINE
        _child._children[i]._visible = true;

    }

我做什么....我用以下方式修改了第 10 课:

1.添加X Slice法线控件。要修改 xNormX、xNormY 和 xNormZ,我们使用第 17 课中的代码:

var slicegui = gui.addFolder('Slice X Orientation');
var sliceXNXController = slicegui.add(volume, 'xNormX', -1.00,1.00).name('Normal X Dir.').listen();
var sliceXNYController = slicegui.add(volume, 'xNormY', -1.00,1.00).name('Normal Y Dir.').listen();
var sliceXNZController = slicegui.add(volume, 'xNormZ', -1.00,1.00).name('Normal Z Dir.').listen();
normalChange = function(value){
    volume.sliceInfoChanged(0);
    sliceXController.max(volume.range[0] - 1);
}
sliceXNXController.onChange(normalChange);
sliceXNYController.onChange(normalChange);
sliceXNZController.onChange(normalChange);
slicegui.open();

2. 将 Listen() 添加到 sliceXController 以在我们修改法线时允许自动更新:

var sliceXController = volumegui.add(volume, 'indexX', 0.00, volume.range[0] - 1).listen();

3.添加代码用于存储和恢复法线和sliceX索引当用户更改volumeRendering时。

//Store the initial normals
var _xNormX_initial = volume.xNormX; 
var _xNormY_initial = volume.yNormX;
var _xNormZ_initial = volume.zNormX;
//Store the user defined normals
var _xNormX_current = null; 
var _xNormY_current = null;
var _xNormZ_current = null;

//store the initial indexX slice
var _indexX_initial = volume.indexX;
//store the user defined indexX slice
var _indexX_current = null;

//IF volumeRendering  change we catch the event
vrController.onChange(function(value) {
  if (value == true) {
    //Store the user defined normals
    _xNormX_current = volume.xNormX;
    _xNormY_current = volume.xNormY;
    _xNormZ_current = volume.xNormZ;
    //store  user defined indexX slice
    _indexX_current = volume.indexX;

    //set the initials normals
    volume.xNormX = _xNormX_initial;
    volume.xNormY = _xNormY_initial;
    volume.xNormZ = _xNormZ_initial;  
    //Set the initial indexX slice
    volume.indexX = _indexX_initial;                
  }else{
    //Go back to the  user defined normals
    volume.xNormX = _xNormX_current;
    volume.xNormY = _xNormY_current;
    volume.xNormZ = _xNormZ_current;
    //Go back to the  user defined indexX slice
    volume.indexX = _indexX_current;
  }
  volume.sliceInfoChanged(0);
});

我希望你能帮助我。提前致谢!!!


我在显示错误时分享了一个视频(mp4和webm),第10课的完整源代码已修改(需要存储在“X-master\testing\visualization”中)和错误的屏幕截图

https://mega.co.nz/#F!I8pxgBqa!M0ZCBUTWXlcIDtYqvboo3w


编辑 1,已解决的问题:对于未编译的 XTK,我使用以下代码:

//Modify Normals
volume.xNormX = _xNormX_current;
volume.xNormY = _xNormY_current;
volume.xNormZ = _xNormZ_current;
//Rebuild the sliceX data
volume.sliceInfoChanged(0);
//reset the "volume._volumeRenderingCache", thanks Nicolas :)
//this is the trick
volume._volumeRenderingCache = [];
//Modify the indexX slice
volume.indexX = _indexX_current;

功能代码在这里(demo_ok.js):mega.co.nz/#!R1p0lKAC!C806T7tLTpQTdBN7mJBRS0_ANWa4fqv3wvJtZR_kMg4

4

1 回答 1

0

Did you try to reset the "volume._volumeRenderingCache" after modifying the slice normal?

something like:

...
volume.sliceInfoChanged(0);
volume._volumeRenderingCache = [];
...

if it does work with the uncompiled XTK, we can add getters/setters to access this variable from the compiled XTK.

Does it make sense?

Thanks

于 2014-02-03T15:12:31.017 回答