2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2006 - INRIA - Fabrice Leray
4 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
17 /*------------------------------------------------------------------------*/
18 /* file: sci_param3d.c */
19 /* desc : interface for param3d routine */
20 /*------------------------------------------------------------------------*/
22 #include "gw_graphics.h"
23 #include "GetCommandArg.h"
24 #include "BuildObjects.h"
26 #include "api_scilab.h"
27 #include "localization.h"
29 #include "DefaultCommandArg.h"
30 /*------------------------------------------------------------------------*/
31 int sci_param3d(char * fname, void *pvApiCtx)
34 int izcol = 0, isfac = 0;
35 static double ebox_def[6] = { 0, 1, 0, 1, 0, 1};
36 double *ebox = ebox_def;
37 static int iflag_def[3] = {1, 2, 4};
38 int iflag[3], *ifl = NULL, ix1 = 0, one = 1;
39 double alpha_def = 35.0 , theta_def = 45.0;
40 double *alpha = &alpha_def, *theta = &theta_def;
41 int m1 = 0, n1 = 0, m2 = 0, n2 = 0, m3 = 0, n3 = 0;
42 int m3n = 0, n3n = 0; /* F.Leray 19.03.04*/
44 static rhs_opts opts[] =
46 { -1, "alpha", -1, 0, 0, NULL},
47 { -1, "ebox", -1, 0, 0, NULL},
48 { -1, "flag", -1, 0, 0, NULL},
49 { -1, "leg", -1, 0, 0, NULL},
50 { -1, "theta", -1, 0, 0, NULL},
51 { -1, NULL, -1, 0, 0, NULL}
55 BOOL freeLabels = FALSE;
65 if (nbInputArgument(pvApiCtx) <= 0)
67 sci_demo(fname, pvApiCtx);
71 CheckInputArgument(pvApiCtx, 3, 8);
73 if (getOptionals(pvApiCtx, fname, opts) == 0)
75 ReturnArguments(pvApiCtx);
78 if (FirstOpt(pvApiCtx) < 4)
80 Scierror(999, _("%s: Misplaced optional argument: #%d must be at position %d.\n"), fname, 1, 4);
84 //get variable address
85 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
88 printError(&sciErr, 0);
92 // Retrieve a matrix of double at position 1.
93 sciErr = getMatrixOfDouble(pvApiCtx, piAddr1, &m1, &n1, &l1);
96 Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
97 printError(&sciErr, 0);
103 AssignOutputVariable(pvApiCtx, 1) = 0;
104 ReturnArguments(pvApiCtx);
107 //get variable address
108 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
111 printError(&sciErr, 0);
115 // Retrieve a matrix of double at position 2.
116 sciErr = getMatrixOfDouble(pvApiCtx, piAddr2, &m2, &n2, &l2);
119 Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2);
120 printError(&sciErr, 0);
124 //get variable address
125 sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3);
128 printError(&sciErr, 0);
132 // Retrieve a matrix of double at position 3.
133 sciErr = getMatrixOfDouble(pvApiCtx, piAddr3, &m3, &n3, &l3);
136 Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 3);
137 printError(&sciErr, 0);
142 if (m1 != m2 || n1 != n2)
144 Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1);
149 if (m2 != m3 || n2 != n3)
151 Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 2, m2, n2);
156 if (get_optional_double_arg(pvApiCtx, fname, 4, "theta", &theta, 1, opts) == 0)
160 if (get_optional_double_arg(pvApiCtx, fname, 5, "alpha", &alpha, 1, opts) == 0)
164 if (get_labels_arg(pvApiCtx, fname, 6, opts, &labels) == 0)
168 freeLabels = !isDefLegend(labels);
170 ifl = &(iflag_def[1]);
171 if (get_optional_int_arg(pvApiCtx, fname, 7, "flag", &ifl, 2, opts) == 0)
175 freeAllocatedSingleString(labels);
179 iflag[0] = iflag_def[0];
182 if (get_optional_double_arg(pvApiCtx, fname, 8, "ebox", &ebox, 6, opts) == 0)
186 freeAllocatedSingleString(labels);
191 getOrCreateDefaultSubwin();
199 Objplot3d (fname, &isfac, &izcol, (l1), (l2), (l3), (double *) NULL, &ix1, &one, theta, alpha, labels, iflag, ebox, &m1, &n1, &m2, &n2, &m3, &n3, &m3n, &n3n); /*Adding F.Leray 12.03.04 */
205 freeAllocatedSingleString(labels);
207 AssignOutputVariable(pvApiCtx, 1) = 0;
208 ReturnArguments(pvApiCtx);
211 /*------------------------------------------------------------------------*/