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

📄 surf.cpp

📁 第一个例子
💻 CPP
字号:
//
// MATLAB Compiler: 3.0
// Date: Sun Dec 14 21:22:13 2003
// Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
// "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
// "array_indexing:on" "-O" "optimize_conditionals:on" "-B" "sglcpp" "-p" "-W"
// "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg"
// "libmwsglm.mlib" "test.m" 
//
#include "surf.hpp"
#include "libmatlbm.hpp"
#include "libmmfile.hpp"
static mwArray _mxarray0_ = mclInitializeDouble(1.0);
static double _ieee_plusinf_ = mclGetInf();
static mwArray _mxarray1_ = mclInitializeDouble(_ieee_plusinf_);
static mwArray _mxarray2_ = mclInitializeDoubleVector(0, 0, (double *)NULL);

static mxChar _array4_[6] = { 'p', 'a', 'r', 'e', 'n', 't' };
static mwArray _mxarray3_ = mclInitializeString(6, _array4_);
static mwArray _mxarray5_ = mclInitializeDouble(3.0);

static mxChar _array7_[2] = { 'o', 'n' };
static mwArray _mxarray6_ = mclInitializeString(2, _array7_);

void InitializeModule_surf() {
}

void TerminateModule_surf() {
}

static mwArray Msurf(int nargout_, mwArray varargin);

_mexLocalFunctionTable _local_function_table_surf
  = { 0, (mexFunctionTableEntry *)NULL };

//
// The function "Nsurf" contains the nargout interface for the "surf"
// M-function from file "e:\matlab6p5\toolbox\matlab\graph3d\surf.m" (lines
// 1-78). This interface is only produced if the M-function uses the special
// variable "nargout". The nargout interface allows the number of requested
// outputs to be specified via the nargout argument, as opposed to the normal
// interface which dynamically calculates the number of outputs based on the
// number of non-NULL inputs it receives. This function processes any input
// arguments and passes them to the implementation version of the function,
// appearing above.
//
mwArray Nsurf(int nargout, mwVarargin varargin) {
    mwArray h = mwArray::UNDEFINED;
    h = Msurf(nargout, varargin.ToArray());
    return h;
}

//
// The function "surf" contains the normal interface for the "surf" M-function
// from file "e:\matlab6p5\toolbox\matlab\graph3d\surf.m" (lines 1-78). This
// function processes any input arguments and passes them to the implementation
// version of the function, appearing above.
//
mwArray surf(mwVarargin varargin) {
    int nargout = 1;
    mwArray h = mwArray::UNDEFINED;
    h = Msurf(nargout, varargin.ToArray());
    return h;
}

//
// The function "Vsurf" contains the void interface for the "surf" M-function
// from file "e:\matlab6p5\toolbox\matlab\graph3d\surf.m" (lines 1-78). The
// void interface is only produced if the M-function uses the special variable
// "nargout", and has at least one output. The void interface function
// specifies zero output arguments to the implementation version of the
// function, and in the event that the implementation version still returns an
// output (which, in MATLAB, would be assigned to the "ans" variable), it
// deallocates the output. This function processes any input arguments and
// passes them to the implementation version of the function, appearing above.
//
void Vsurf(mwVarargin varargin) {
    mwArray h = mwArray::UNDEFINED;
    h = Msurf(0, varargin.ToArray());
}

//
// The function "mlxSurf" contains the feval interface for the "surf"
// M-function from file "e:\matlab6p5\toolbox\matlab\graph3d\surf.m" (lines
// 1-78). The feval function calls the implementation version of surf through
// this function. This function processes any input arguments and passes them
// to the implementation version of the function, appearing above.
//
void mlxSurf(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    MW_BEGIN_MLX();
    {
        mwArray mprhs[1];
        mwArray mplhs[1];
        mclCppUndefineArrays(1, mplhs);
        if (nlhs > 1) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: surf Line: 1 Column: 1"
                  " The function \"surf\" was called with more "
                  "than the declared number of outputs (1).")));
        }
        mprhs[0] = mclCreateVararginCell(nrhs, prhs);
        mplhs[0] = Msurf(nlhs, mprhs[0]);
        plhs[0] = mplhs[0].FreezeData();
    }
    MW_END_MLX();
}

//
// The function "Msurf" is the implementation version of the "surf" M-function
// from file "e:\matlab6p5\toolbox\matlab\graph3d\surf.m" (lines 1-78). 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 h = surf(varargin)
//
static mwArray Msurf(int nargout_, mwArray varargin) {
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_surf;
    int nargin_ = nargin(-1, mwVarargin(varargin));
    mwArray h = mwArray::UNDEFINED;
    mwArray hh = mwArray::UNDEFINED;
    mwArray i = mwArray::UNDEFINED;
    mwArray cax = mwArray::UNDEFINED;
    mwArray ans = mwArray::UNDEFINED;
    //
    // %SURF   3-D colored surface.
    // %   SURF(X,Y,Z,C) plots the colored parametric surface defined by
    // %   four matrix arguments.  The view point is specified by VIEW.
    // %   The axis labels are determined by the range of X, Y and Z,
    // %   or by the current setting of AXIS.  The color scaling is determined
    // %   by the range of C, or by the current setting of CAXIS.  The scaled
    // %   color values are used as indices into the current COLORMAP.
    // %   The shading model is set by SHADING.
    // %
    // %   SURF(X,Y,Z) uses C = Z, so color is proportional to surface height.
    // %
    // %   SURF(x,y,Z) and SURF(x,y,Z,C), with two vector arguments replacing
    // %   the first two matrix arguments, must have length(x) = n and
    // %   length(y) = m where [m,n] = size(Z).  In this case, the vertices
    // %   of the surface patches are the triples (x(j), y(i), Z(i,j)).
    // %   Note that x corresponds to the columns of Z and y corresponds to
    // %   the rows.
    // %
    // %   SURF(Z) and SURF(Z,C) use x = 1:n and y = 1:m.  In this case,
    // %   the height, Z, is a single-valued function, defined over a
    // %   geometrically rectangular grid.
    // %
    // %   SURF(...,'PropertyName',PropertyValue,...) sets the value of the 
    // %   specified surface property.  Multiple property values can be set
    // %   with a single statement.
    // %
    // %   SURF returns a handle to a SURFACE object.
    // %
    // %   AXIS, CAXIS, COLORMAP, HOLD, SHADING and VIEW set figure, axes, and 
    // %   surface properties which affect the display of the surface.
    // %
    // %   See also SURFC, SURFL, MESH, SHADING.
    // 
    // %-------------------------------
    // %   Additional details:
    // %
    // %   If the NextPlot axis property is REPLACE (HOLD is off), SURF resets 
    // %   all axis properties, except Position, to their default values
    // %   and deletes all axis children (line, patch, surf, image, and 
    // %   text objects).
    // 
    // %   Copyright 1984-2002 The MathWorks, Inc. 
    // %   $Revision: 5.14 $  $Date: 2002/04/08 22:00:16 $
    // 
    // %   J.N. Little 1-5-92
    // 
    // error(nargchk(1,inf,nargin))
    //
    error(mwVarargin(nargchk(_mxarray0_, _mxarray1_, nargin_)));
    //
    // 
    // cax = [];
    //
    cax = _mxarray2_;
    //
    // 
    // 
    // if nargin > 1
    //
    if (nargin_ > 1) {
        //
        // % try to fetch axes handle from input args
        // for i = 1:length(varargin)
        //
        int v_ = mclForIntStart(1);
        int e_ = mclLengthInt(mwVa(varargin, "varargin"));
        if (v_ > e_) {
            i = _mxarray2_;
        } else {
            //
            // if isstr(varargin{i}) & strncmpi(varargin{i}, 'parent', length(varargin{i})) & nargin > i
            // cax = varargin{i+1};
            // break;
            // end
            // end
            //
            for (; ; ) {
                mwArray a_
                  = feval(
                      mwValueVarargout(),
                      mlxIsstr,
                      mwVarargin(mwVa(varargin, "varargin").cell(v_)));
                if (tobool(a_)) {
                    a_
                      = a_
                        & feval(
                            mwValueVarargout(),
                            mlxStrncmpi,
                            mwVarargin(
                              mwVa(varargin, "varargin").cell(v_),
                              _mxarray3_,
                              feval(
                                mwValueVarargout(),
                                mlxLength,
                                mwVarargin(
                                  mwVa(varargin, "varargin").cell(v_)))));
                } else {
                    a_ = 0;
                }
                if (tobool(a_) && tobool(a_ & nargin_ > v_)) {
                    cax = mwVa(varargin, "varargin").cell(v_ + 1);
                    break;
                } else {
                }
                if (v_ == e_) {
                    break;
                }
                ++v_;
            }
            i = v_;
        }
    //
    // end
    //
    }
    //
    // 
    // % use nextplot unless user specifed an axes handle
    // if isempty(cax)
    //
    if (tobool(isempty(mwVv(cax, "cax")))) {
        //
        // cax = newplot;
        //
        cax = Nnewplot(1, mwArray::DIN);
    //
    // end
    //
    }
    //
    // 
    // hh = surface(varargin{:});
    //
    hh = Nsurface(1, mwVarargin(mwVa(varargin, "varargin").cell(colon())));
    //
    // 
    // if ~ishold(cax)
    //
    if (mclNotBool(ishold(mwVv(cax, "cax")))) {
        //
        // view(cax,3);
        //
        ans.EqAns(
          Nview(0, mwAnsVarargout(), mwVarargin(mwVv(cax, "cax"), _mxarray5_)));
        //
        // grid(cax,'on');
        //
        grid(mwVv(cax, "cax"), _mxarray6_);
    //
    // end
    //
    }
    //
    // 
    // if nargout == 1
    //
    if (nargout_ == 1) {
        //
        // h = hh;
        //
        h = mwVv(hh, "hh");
    //
    // end
    //
    }
    mwValidateOutput(h, 1, nargout_, "h", "surf");
    return h;
}

⌨️ 快捷键说明

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