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

    function nd=addtoproject(nd,varargin)
%ADDTOPROJECT  add data to the project
%
% ADDTOPROJECT(ND,DATA,NSUB)
%
%  If NSUB (a cgnode) is specified then DATA is ignored, otherwise
%  a cgnode is constructed for DATA.
%

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



% if it doesn't exist in project

AlreadyExists = false;
if nargin==2
    % item could already exist in project
    cgp = project(nd);
    data = findItem(info(cgp),'data',varargin{1});
    AlreadyExists = ~isempty(data);
end

if ~AlreadyExists
    % add to project the normal way
    addtoproject(nd.cgcontainer,varargin{:});
end

% check whether any items should also be attached to featurenode
data = varargin{1};
nd=address(nd);
if data.isa('cglookup') && ~data.isa('cgnormaliser')
	tblnd=cgnode(data.info,nd,data,1);
	nd.AddChild(tblnd);
end