source: trunk/lang/matlab/rpUnitsMakeMetric.cc @ 1018

Last change on this file since 1018 was 165, checked in by dkearney, 19 years ago

1) removing matlab and octave tests for put*id functions
2) adding old fortran examples
3) minor changes to matlab and octave to fix rpUnitsGetBasis
4) rpUnitsMakeMetric does not work in matlab
5) changes to fortran bindings to return proper error codes.
6) added debugging to matlab compiling options and changed outdir location in Makefile

File size: 2.0 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [error] = rpUnitsMakeMetric(basisHandle)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2004-2005  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * ======================================================================
14 */
15
16#include "RpMatlabInterface.h"
17
18/**********************************************************************/
19// METHOD: [err] = rpUnitsMakeMetric(basisHandle)
20/// Create metric extensions for the Rappture Unit referenced by basisHandle
21/**
22 * Create the metric extensions for the Rappture Unit, referenced`
23 * by basisHandle, within Rappture's internal units dictionary.
24 * Return an error code, err, to specify success or failure.
25 * Error code, err=0 on success, anything else is failure.
26 */
27
28void mexFunction(int nlhs, mxArray *plhs[],
29                 int nrhs, const mxArray *prhs[])
30{
31    const RpUnits* basis       = NULL;
32    int            retVal      = 0;
33    int            basisHandle = 0;
34    int            retIndex    = 0;
35
36    /* Check for proper number of arguments. */
37    if (nrhs != 1)
38        mexErrMsgTxt("Two input required.");
39    else if (nlhs > 1)
40        mexErrMsgTxt("Too many output arguments.");
41
42    basisHandle = getIntInput(prhs[0]);
43
44    /* Call the C subroutine. */
45    if (basisHandle > 0) {
46        basis = getObject_UnitsStr(basisHandle);
47
48        if (basis) {
49             retVal = RpUnits::makeMetric(basis);
50        }
51        else {
52            std::string errMsg = "Error while retrieving basis handle.\n";
53            errMsg += "Possibly invalid handle?\n";
54            mexErrMsgTxt(errMsg.c_str());
55        }
56    }
57
58    /* Set C-style string output_buf to MATLAB mexFunction output*/
59    plhs[0] = mxCreateDoubleScalar(retVal);
60
61    return;
62}
Note: See TracBrowser for help on using the repository browser.