简体   繁体   English

在xtk中加载体积而不初始化渲染器

[英]Load volume in xtk without initializing a renderer

I'm using xtk to read remote NIfTI volumes into an application. 我正在使用xtk将远程NIfTI卷读入应用程序。 My sole objective is to obtain a volume object so I can extract its data; 我唯一的目标是获得一个体积对象,以便提取其数据。 I don't need to render anything. 我不需要渲染任何东西。 The examples I've seen all initialize a renderer and attach a volume before accessing its contents. 我看过的示例都初始化了渲染器,并在访问其内容之前附加了一个卷。 Eg (from http://jsfiddle.net/QxMSt/5/ ): 例如(来自http://jsfiddle.net/QxMSt/5/ ):

var r = new X.renderer3D();
r.init();

var v = new X.volume();
v.file = 'http://www.cogitatum.org/mprage003.nii.gz';

r.add(v);

r.render();

r.onShowtime = function() {

    r.destroy();    
    // get the image data
    var data = v.image;       
}

This works very nicely, but I'd rather not have to go to the trouble of creating a renderer for nothing, and would also prefer not to require WebGL support. 这可以很好地工作,但是我宁愿不必费力地创建渲染器,也不希望不需要WebGL支持。 Is there any way to initialize the volume and access its properties without rendering? 有没有办法初始化卷并访问其属性而不渲染? I've looked through the codebase but don't see any place an onLoad() event or comparable is fired at the moment, though X.loader clearly tracks loading completion internally. 我查看了代码库,但没有看到onLoad()事件或类似事件被触发的任何地方,尽管X.loader清楚地在内部跟踪加载完成。 It looks as though setting the volume's file property is sufficient to trigger volume loading, but I don't see any way to pass a callback function that gets triggered on completion. 似乎设置卷的file属性足以触发卷加载,但是我看不到任何传递完成时触发的回调函数的方法。 Any suggestions? 有什么建议么?

Unfortunately this is currently the only solution. 不幸的是,这是目前唯一的解决方案。 The file loading starts when adding the object to the renderer. 将对象添加到渲染器时,文件加载开始。

To avoid the WebGL requirement, just use a X.renderer2D . 为了避免WebGL需求,只需使用X.renderer2D

A separate and generic i/o library externally from XTK is planned and should be available in the next couple of weeks. 已计划从XTK外部提供一个单独的通用I / O库,并将在接下来的几周内提供。

I also need just the volume information, so what I did is: 我还只需要卷信息,所以我要做的是:

var filename =  "../data/data.nrrd";
var volume = new X.volume();
volume.file = filename;

var request = new XMLHttpRequest();
request.open("GET", filename, true);
request.responseType = 'arraybuffer';
request.onload=function()
{
    var _data = request.response;
    volume._filedata = _data;

    var loader = new X.loader();
    loader.load(volume, volume);

    loader.complete = function()
    {
        volumeImage = volume.image;
        // process volumeImage
    }
}
request.send(null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM