⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bvqx_srf_parseneighbors.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function neighbors = bvqx_srf_parseneighbors(fid, numvtx)
% bvqx_srf_parseneighbors  - parse neighbors from SRF file
%
% FORMAT:       neighbors = bvqx_srf_parseneighbors(fid, numvtx)
%
% Input fields:
%
%       fid         input file fid (fopen)
%       numvtx      number of vertices
%
% Output fields
%
%       neighbors   Nx2 cell array with content
%        {N, 1}     1x1 double, number of neighbors for vertex(N)
%        {N, 2}     1xN double, list of neighbors
%
% See also BVQXfile, bffio

% Version:  v0.7b
% Build:    7083015
% Date:     Aug-30 2007, 3:22 PM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 2 || ...
   ~isa(fid, 'double') || ...
    isempty(fid) || ...
   ~isreal(fid) || ...
   ~any(fopen('all') == fid(1)) || ...
   ~isa(numvtx, 'double') || ...
    isempty(numvtx) || ...
   ~isreal(numvtx) || ...
    isnan(numvtx(1)) || ...
    isinf(numvtx(1)) || ...
    numvtx(1) < 1
    error( ...
        'BVQXtools:BadArgument', ...
        'Bad or missing argument.' ...
    );
end

% grand TRY loop
try
    
% get current position
cpos = ftell(fid);

% get remainder of contents
vcont = fread(fid, [1, Inf], 'uint32=>double');
vlen  = length(vcont);

% sanity check, in a mesh triangle vertices MUST have at least 3 neighbors
if vlen < (4 * numvtx)
    error('Too few DWORDs left.');
end

% create output array
neighbors = cell(numvtx, 2);

% loop over content
vc = 1;
pc = 1;
while vc <= numvtx && ...
    pc < vlen
    numnei = vcont(pc);
    neighbors{vc, 1} = numnei;
    neighbors{vc, 2} = vcont(pc + 1:pc + numnei) + 1;
    pc = pc + 1 + numnei;
    vc = vc + 1;
end

% if too little content
if vc <= numvtx
    error('Too few DWORDs left.');
end

% seek to good position
fseek(fid, cpos + 4 * (pc - 1), -1);

catch
    error( ...
        'BVQXtools:BadFileOrContent', ...
        'Reading of file failed with: ''%s''.', ...
        lasterr ...
    );
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -