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-2012 HUBzero Foundation, LLC |
---|
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 | |
---|
28 | void 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 | } |
---|