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

    function h = draw_surface(ax,vardata,constraints,cmap,options,crange)
%DRAW_SURFACE Draw surface
%
%  h = draw_surface(ax, vardata, constraints, cmap, options, crange) draws
%  the surface representing the specified data, after checking sizes.
%
%  "ax" can be a handle to axes or to a previous surface (which will be
%  modified).
%
%  vardata is a structure with fields
%    x, y, z, c

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


if any(size(vardata.x)~=size(vardata.y))...
    || any(size(vardata.x)~=size(vardata.z))...
    || any(size(vardata.x)~=size(vardata.c))

	error(message('mbc:cgsurfview:draw_surface:InvalidSize'));
end

if nargin<6
    % Generate crange from data
    if ~isempty(constraints)
        crange = mbcmakelimits(vardata.c(constraints<=0));
    else
        crange = mbcmakelimits(vardata.c);
    end
end

% Generate color data from the colormap
cdata = mbczdata2cdata(vardata.c, cmap, crange);

if isempty(constraints)
    constraints = repmat(-1, size(vardata.z));
end


if isgraphics(ax,'patch')
    p = ax;
    ax = get(p,'Parent');
else
    p = [];
end

% Set "grid" visibility according to options object
set(ax,'XGrid',options.grid,'YGrid',options.grid,'ZGrid',options.grid);

% Plot the surface
h = xregsurfaceb(vardata.x, vardata.y, vardata.z, constraints,cdata, ...
    'DisplayExterior', 'on', ...
    'Patch', p,...
    'Parent', ax, ...
    'EdgeColor', 'none', ...
    'FaceLighting', 'flat', ...
    'FaceColor', 'interp', ...
    'EdgeColor', options.edgecolor, ...
    'Tag', 'surfacePlot');