⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shading.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
字号:
/*
 * MATLAB Compiler: 2.0.1
 * Date: Tue May 08 21:28:21 2001
 * Arguments: "-B" "sgl" "-m" "-W" "mainhg" "-L" "C" "asufit.m" "absfun.m"
 * "absfunfree.m" "absfunshift.m" "absfunwidth.m" "dispfit.m" "dispfitdisp.m"
 * "dispfitfree.m" "dispfitwidth.m" "seqmodfree.m" "spcfun.m" "spcfun1.m"
 * "atamult.m" "aprecon.m" 
 */
#include "shading.h"

/*
 * The function "Mshading" is the implementation version of the "shading"
 * M-function from file "C:\MATLABR11\toolbox\matlab\graph3d\shading.m" (lines
 * 1-75). It contains the actual compiled code for that M-function. It is a
 * static function and must only be called from one of the interface functions,
 * appearing below.
 */
/*
 * function shading(type)
 */
static void Mshading(mxArray * type) {
    mxArray * ans = mclInitializeAns();
    mxArray * ax = mclGetUninitializedArray();
    mxArray * face = mclGetUninitializedArray();
    mxArray * fc = mclGetUninitializedArray();
    mxArray * i = mclGetUninitializedArray();
    mxArray * imesh = mclGetUninitializedArray();
    mxArray * isurf = mclGetUninitializedArray();
    mclForLoopIterator iterator_0;
    mxArray * itext = mclGetUninitializedArray();
    mxArray * kids = mclGetUninitializedArray();
    mxArray * nargin_ = mclGetUninitializedArray();
    mlfAssign(&nargin_, mlfNargin(0, type, NULL));
    mclValidateInputs("shading", 1, &type);
    /*
     * %SHADING Color shading mode.
     * %   SHADING controls the color shading of SURFACE and PATCH objects.
     * %   SURFACE and PATCH objects are created by the functions SURF, MESH,
     * %   PCOLOR, FILL, and FILL3. 
     * %
     * %   SHADING FLAT sets the shading of the current graph to flat.
     * %   SHADING INTERP sets the shading to interpolated.
     * %   SHADING FACETED sets the shading to faceted, which is the default.
     * %
     * %   Flat shading is piecewise constant; each mesh line segment or
     * %   surface patch has a constant color determined by the color value
     * %   at the end point of the segment or the corner of the patch which
     * %   has the smallest index or indices.
     * %
     * %   Interpolated shading, which is also known as Gouraud shading, is
     * %   piecewise bilinear; the color in each segment or patch varies linearly
     * %   and interpolates the end or corner values.
     * %
     * %   Faceted shading is flat shading with superimposed black mesh lines.
     * %   This is often the most effective and is the default.
     * %
     * %   SHADING is an M-file that sets the EdgeColor and FaceColor properties
     * %   of all SURFACE objects in the current axes. It sets them to the
     * %   correct values that depend upon whether the SURFACE objects are
     * %   representing meshes or surfaces.
     * %
     * %   See also HIDDEN, SURF, MESH, PCOLOR, FILL, FILL3, SURFACE, PATCH.
     * 
     * %   Copyright (c) 1984-98 by The MathWorks, Inc.
     * %   $Revision: 5.12 $  $Date: 1998/06/01 22:03:14 $
     * 
     * nargchk(1,1,nargin);
     */
    mclAssignAns(&ans, mlfNargchk(mlfScalar(1.0), mlfScalar(1.0), nargin_));
    /*
     * ax = gca;
     */
    mlfAssign(&ax, mlfGca(NULL));
    /*
     * fc = get(ax,'color');
     */
    mlfAssign(&fc, mlfGet(ax, mxCreateString("color"), NULL));
    /*
     * if strcmp(lower(fc),'none')
     */
    if (mlfTobool(mlfStrcmp(mlfLower(fc), mxCreateString("none")))) {
        /*
         * fc = get(gcf,'color');
         */
        mlfAssign(&fc, mlfGet(mlfGcf(), mxCreateString("color"), NULL));
    /*
     * end
     */
    }
    /*
     * kids = [findobj(ax,'type','surface'); findobj(ax,'type','patch')];
     */
    mlfAssign(
      &kids,
      mlfVertcat(
        mlfHorzcat(
          mlfFindobj(
            ax, mxCreateString("type"), mxCreateString("surface"), NULL),
          NULL),
        mlfHorzcat(
          mlfFindobj(ax, mxCreateString("type"), mxCreateString("patch"), NULL),
          NULL),
        NULL));
    /*
     * imesh = [];
     */
    mlfAssign(&imesh, mclCreateEmptyArray());
    /*
     * isurf = [];
     */
    mlfAssign(&isurf, mclCreateEmptyArray());
    /*
     * itext = [];
     */
    mlfAssign(&itext, mclCreateEmptyArray());
    /*
     * for i = 1:length(kids)
     */
    for (mclForStart(&iterator_0, mlfScalar(1.0), mlfLength(kids), NULL);
         mclForNext(&iterator_0, &i);
         ) {
        /*
         * face = get(kids(i),'facecolor');
         */
        mlfAssign(
          &face,
          mlfGet(
            mlfIndexRef(kids, "(?)", i), mxCreateString("facecolor"), NULL));
        /*
         * if strcmp(face,'none')
         */
        if (mlfTobool(mlfStrcmp(face, mxCreateString("none")))) {
            /*
             * imesh = [imesh ; kids(i)];
             */
            mlfAssign(
              &imesh,
              mlfVertcat(
                mlfHorzcat(imesh, NULL),
                mlfHorzcat(mlfIndexRef(kids, "(?)", i), NULL),
                NULL));
        /*
         * elseif strcmp(face,'texturemap')
         */
        } else if (mlfTobool(mlfStrcmp(face, mxCreateString("texturemap")))) {
            /*
             * itext = [itext; kids(i)];
             */
            mlfAssign(
              &itext,
              mlfVertcat(
                mlfHorzcat(itext, NULL),
                mlfHorzcat(mlfIndexRef(kids, "(?)", i), NULL),
                NULL));
        /*
         * elseif ~isstr(face)
         */
        } else if (mlfTobool(mlfNot(mlfIsstr(face)))) {
            /*
             * if (all(face == fc)) 
             */
            if (mlfTobool(mlfAll(mlfEq(face, fc), NULL))) {
                /*
                 * imesh = [imesh ; kids(i)];
                 */
                mlfAssign(
                  &imesh,
                  mlfVertcat(
                    mlfHorzcat(imesh, NULL),
                    mlfHorzcat(mlfIndexRef(kids, "(?)", i), NULL),
                    NULL));
            /*
             * else
             */
            } else {
                /*
                 * isurf = [isurf; kids(i)];
                 */
                mlfAssign(
                  &isurf,
                  mlfVertcat(
                    mlfHorzcat(isurf, NULL),
                    mlfHorzcat(mlfIndexRef(kids, "(?)", i), NULL),
                    NULL));
            /*
             * end
             */
            }
        /*
         * else
         */
        } else {
            /*
             * isurf = [isurf; kids(i)];
             */
            mlfAssign(
              &isurf,
              mlfVertcat(
                mlfHorzcat(isurf, NULL),
                mlfHorzcat(mlfIndexRef(kids, "(?)", i), NULL),
                NULL));
        /*
         * end
         */
        }
    /*
     * end
     */
    }
    /*
     * 
     * if (strcmp(type, 'flat'))
     */
    if (mlfTobool(mlfStrcmp(type, mxCreateString("flat")))) {
        /*
         * if ~isempty(isurf), set(isurf,'facecolor','flat','edgecolor','none'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(isurf)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                isurf,
                mxCreateString("facecolor"),
                mxCreateString("flat"),
                mxCreateString("edgecolor"),
                mxCreateString("none"),
                NULL));
        }
        /*
         * if ~isempty(imesh), set(imesh,'edgecolor','flat'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(imesh)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                imesh,
                mxCreateString("edgecolor"),
                mxCreateString("flat"),
                NULL));
        }
        /*
         * if ~isempty(itext), set(itext,'edgecolor','none'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(itext)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                itext,
                mxCreateString("edgecolor"),
                mxCreateString("none"),
                NULL));
        }
    /*
     * elseif (strcmp(type, 'interp'))
     */
    } else if (mlfTobool(mlfStrcmp(type, mxCreateString("interp")))) {
        /*
         * if ~isempty(isurf), set(isurf,'facecolor','interp','edgecolor','none'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(isurf)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                isurf,
                mxCreateString("facecolor"),
                mxCreateString("interp"),
                mxCreateString("edgecolor"),
                mxCreateString("none"),
                NULL));
        }
        /*
         * if ~isempty(imesh), set(imesh,'edgecolor','interp'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(imesh)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                imesh,
                mxCreateString("edgecolor"),
                mxCreateString("interp"),
                NULL));
        }
        /*
         * if ~isempty(itext), set(itext,'edgecolor','interp'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(itext)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                itext,
                mxCreateString("edgecolor"),
                mxCreateString("interp"),
                NULL));
        }
    /*
     * elseif (strcmp(type,'faceted'))
     */
    } else if (mlfTobool(mlfStrcmp(type, mxCreateString("faceted")))) {
        /*
         * if ~isempty(isurf), set(isurf,'facecolor','flat','edgecolor','black'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(isurf)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                isurf,
                mxCreateString("facecolor"),
                mxCreateString("flat"),
                mxCreateString("edgecolor"),
                mxCreateString("black"),
                NULL));
        }
        /*
         * if ~isempty(imesh), set(imesh,'edgecolor','flat'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(imesh)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                imesh,
                mxCreateString("edgecolor"),
                mxCreateString("flat"),
                NULL));
        }
        /*
         * if ~isempty(itext), set(itext,'edgecolor','black'); end
         */
        if (mlfTobool(mlfNot(mlfIsempty(itext)))) {
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                itext,
                mxCreateString("edgecolor"),
                mxCreateString("black"),
                NULL));
        }
    /*
     * else
     */
    } else {
        /*
         * error('Shading methods are flat, faceted, and interp.');
         */
        mlfError(
          mxCreateString("Shading methods are flat, faceted, and interp."));
    /*
     * end
     */
    }
    mxDestroyArray(ans);
    mxDestroyArray(ax);
    mxDestroyArray(face);
    mxDestroyArray(fc);
    mxDestroyArray(i);
    mxDestroyArray(imesh);
    mxDestroyArray(isurf);
    mxDestroyArray(itext);
    mxDestroyArray(kids);
    mxDestroyArray(nargin_);
}

/*
 * The function "mlfShading" contains the normal interface for the "shading"
 * M-function from file "C:\MATLABR11\toolbox\matlab\graph3d\shading.m" (lines
 * 1-75). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
void mlfShading(mxArray * type) {
    mlfEnterNewContext(0, 1, type);
    Mshading(type);
    mlfRestorePreviousContext(0, 1, type);
}

/*
 * The function "mlxShading" contains the feval interface for the "shading"
 * M-function from file "C:\MATLABR11\toolbox\matlab\graph3d\shading.m" (lines
 * 1-75). The feval function calls the implementation version of shading
 * through this function. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlxShading(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[1];
    int i;
    if (nlhs > 0) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: shading Line: 1 Column: "
            "0 The function \"shading\" was called with mor"
            "e than the declared number of outputs (0)"));
    }
    if (nrhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: shading Line: 1 Column:"
            " 0 The function \"shading\" was called with m"
            "ore than the declared number of inputs (1)"));
    }
    for (i = 0; i < 1 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 1; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 1, mprhs[0]);
    Mshading(mprhs[0]);
    mlfRestorePreviousContext(0, 1, mprhs[0]);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -