www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgfeaturenode/upgradeV1ToV2.m

    function FN = upgradeV1ToV2(FN)
%UPGRADEV1TOV2 Upgrade the object to version 2.
%
%   OBJ = UPGRADEV1TOV2(OBJ) performs the changes that are necessary to
%   upgrade the object from version 1 to version 2.  This involves fixing
%   the number of child nodes of the feature node.

%   Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.


pf = getdata(FN);
f = pf.info;
pe = get(f,'equation');
if ~isempty(pe)
    % find all items to include as children, i.e. tables or subfeatures
    all_p = unique([pe;getptrsnosf(pe.info)]);
    istbl = parrayeval(all_p, @istable, {} , @false);
    isfeat = parrayeval(all_p, @isfeature, {} , @false);
    p = all_p(istbl | isfeat);
else
    p = mbcpointer(1,0);
end

ch = children(FN);
if ~isempty(ch)
    % Check that there are no child nodes that should not be there
    pd = parrayeval(ch, @getdata, {}, mbcpointer);
    [pd,ind] = removeDuplicates(pd);
    OK = ismember(pd,p);
    
    % Indices of child nodes that are OK. Duplicates will be in the removal
    % list
    CorrectKids = ind(OK);
    
    if length(ch)~=length(CorrectKids)
        Kids = ch(CorrectKids);
        KidsToRemove = setdiff(ch,Kids);
        pveceval(KidsToRemove, @delete);
        FN = info(FN);
    end
end