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

    function con = loadobj(con)
%LOADOBJ Load filter for the Star-shaped constraint (CONSTAR)
%
%  CON = LOADOBJ(CON)
%
%  For old forms of constraints, the LOADOBJ method updates the object
%  structure and partially increments the version number. Where required,
%  nominal values will be used for the variable information, etc. Use the
%  UPGRADE method to update this information.
%
%  See also LOADOBJ, CONBASE/UPGRADE.

%  Copyright 2005-2007 The MathWorks, Inc.

if con.Version == 4.5,
    warning(message('mbc:conbase:MissedUpgrade'));
end
if con.Version <= 3,
    [con, spo, bpo] = i_update_v3_to_v4( con );
    
    % TODO : Need to store the boundary and special point options so that
    % the bdry dev can pick them up
    
    % Increment the version number:
    con.Version = 4;
end
if con.Version <= 4,
    % Partial increment of the version number:
    con.Version = 4.5;
end
if con.Version <= 5
    % add Offset to object
    con.Offset = 0;
    if con.Version ~= 4.5
        % we don't need to go through upgrade
        con.Version = 6;
    end
end
if isstruct( con ),
    % Convert the structure to an object.
    con = constar( con );
end

%------------------------------------------------------------------------------|
function [new, spo, bpo] = i_update_v3_to_v4( old )
% Update from version 3 (or earlier) to version 4.
%
% Object structure for version 4:
%       Version: 4
%         Model: [7x1 xreginterprbf]
%        Center: [0 0]
%     Transform: 'None'
%       conbase: [1x1 conbase]
    
new.Version = 4;

new.Model = old.BoundaryModel;
new.Center = old.Center;
new.Transform = get( old.OptionsManger, 'Transform' );

spo = get( old.OptionsManger, 'CenterAlg' );

bpo = get( old.OptionsManger, 'Classification' );
if isfield( old.Store, 'DilationRadius' );
    r = old.Store.DilationRadius;
else
    r = -1;
end
bpo = AddOption( bpo, 'ActualDilationRadius', ...
    r, {'numeric', [-Inf,Inf]}, '', 0 );

% The special point (spo) and boundary point options (bpo) need to be stored in
% the parent CONBASE object. This is achieved with calls like:
%>> new.conbase = setspecialpointoptions( new.conbase, spo );
%>> new.conbase = setbdrypointoptions(    new.conbase, bpo );

%------------------------------------------------------------------------------|
% EOF
%------------------------------------------------------------------------------|