www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@xregbdryroot/loadobj.m

    function root = loadobj(root)
%LOADOBJ Load filter for boundary root class (XREGBDRYROOT)
%
%  ROOT = LOADOBJ(ROOT)
%
%  See also XREGBDRYROOT, LOADOBJ.

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

Friend = [];
if root.Version <= 1,
    % Upgarde from version 1 to version 2 structure.
    %
    %     Version: 1
    %             Data: []
    %             Best: []
    %        NumStages: 1
    %           Friend: []
    %     xregbdrynode: [1x1 xregbdrynode]
    
    % Get input factors from friend model
    if isempty( root.Friend ),
        root.InputFactors = [];
    else
        root.InputFactors = coninputfactor( root.Friend );
        Friend = root.Friend;
    end
    % Remove the friend field as it's no longer used.
    root = mv_rmfield( root, 'Friend' );

    % Increment the version number:
    root.Version = 2;
end
if root.Version <= 2,
    % The only difference between version 2 and version 3 is that in
    % version 2 root.Data could be a cell array of SSFs or a single SSF. If
    % version 3, root.Data must be a cell array of SSFs.

    % Data is now removed

    % Increment the version number:
    root.Version = 2;
end
if root.Version < 4 && ~isempty(root.InputFactors)
    if isempty(Friend)
       Friend = makeXregmodel( root.InputFactors, @xregcubic );
    end
    % Need to upgrade the constraints held in any children using
    % the friend model. Will the children have been loaded yet?
    hLoad = mbcloadrecorder( 'current' );

    hLoad.add( {@i_UpgradeChildConstraints, address( root.xregbdrynode ), ...
        Friend}, '13-Jul-2005' );
    root.Version = 4;
        
end
if root.Version < 5 
    %  Data is replaced by an xregbdrydata interface
    root = rmfield(root,'Data');
    root.BoundaryData = xregbdrydata(xregpointer);
    root.Version = 5;
end


if isstruct( root ),
    % Convert the structure to an object.
    root = xregbdryroot( root );
end

%--------------------------------------------------------------------------
function i_UpgradeChildConstraints( pProject, evt, pRoot, friend )
% Upgrade the constraint held by the children
pRoot.children( @pUpgradeConstraint, friend );

%--------------------------------------------------------------------------
% EOF
%--------------------------------------------------------------------------