1 /* 2 * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT, 3 * Applied Mathematics, Norway. 4 * 5 * Contact information: E-mail: tor.dokken@sintef.no 6 * SINTEF ICT, Department of Applied Mathematics, 7 * P.O. Box 124 Blindern, 8 * 0314 Oslo, Norway. 9 * 10 * This file is part of SISL. 11 * 12 * SISL is free software: you can redistribute it and/or modify 13 * it under the terms of the GNU Affero General Public License as 14 * published by the Free Software Foundation, either version 3 of the 15 * License, or (at your option) any later version. 16 * 17 * SISL is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU Affero General Public License for more details. 21 * 22 * You should have received a copy of the GNU Affero General Public 23 * License along with SISL. If not, see 24 * <http://www.gnu.org/licenses/>. 25 * 26 * In accordance with Section 7(b) of the GNU Affero General Public 27 * License, a covered work must retain the producer line in every data 28 * file that is created or manipulated using SISL. 29 * 30 * Other Usage 31 * You can be released from the requirements of the license by purchasing 32 * a commercial license. Buying such a license is mandatory as soon as you 33 * develop commercial activities involving the SISL library without 34 * disclosing the source code of your own applications. 35 * 36 * This file may be used in accordance with the terms contained in a 37 * written agreement between you and SINTEF ICT. 38 */ 39 40 #include "sisl-copyright.h" 41 42 #define S1356 43 44 #include "sislP.h" 45 46 #if defined(SISLNEEDPROTOTYPES) 47 void s1356(double epoint[],int inbpnt,int idim,int nptyp[],int icnsta,int icnend,int iopen,int ik,double astpar,double * cendpar,SISLCurve ** rc,double ** gpar,int * jnbpar,int * jstat)48 s1356(double epoint[],int inbpnt,int idim,int nptyp[], 49 int icnsta,int icnend,int iopen,int ik,double astpar, 50 double *cendpar,SISLCurve **rc,double **gpar,int *jnbpar,int *jstat) 51 #else 52 void s1356(epoint,inbpnt,idim,nptyp,icnsta,icnend,iopen,ik,astpar, 53 cendpar,rc,gpar,jnbpar,jstat) 54 double epoint[]; 55 int inbpnt; 56 int idim; 57 int nptyp[]; 58 int icnsta; 59 int icnend; 60 int iopen; 61 int ik; 62 double astpar; 63 double *cendpar; 64 SISLCurve **rc; 65 double **gpar; 66 int *jnbpar; 67 int *jstat; 68 #endif 69 /* 70 ************************************************************************* 71 * 72 * Purpose: To calculate a B-spline curve interpolating a set of points. 73 * The points can be assigned a tangent (derivative). 74 * The curve can be closed or open. If end-conditions are 75 * conflicting, the condition closed curve rules out other 76 * end conditions. 77 * 78 * Input: 79 * Epoint - Array (length idim*inbpnt) containing the points/ 80 * derivatives to be interpolated. 81 * Inbpnt - No. of points/derivatives in the epoint array. 82 * Idim - The dimension of the space in which the points lie. 83 * nptyp - Array (length inbpnt) containing type indicator for 84 * points/derivatives/second-derivatives: 85 * 1 - Ordinary point. 86 * 2 - Knuckle point. (Is treated as an ordinary point.) 87 * 3 - Derivative to next point. 88 * 4 - Derivative to prior point. 89 * ( 5 - Second derivative to next point. ) 90 * ( 6 - Second derivative to prior point. ) 91 * 13 - Start-point of tangent to next point. 92 * 14 - End-point of tangent to prior point. 93 * Icnsta - Additional condition at the start of the curve: 94 * 0 : No additional condition. 95 * 1 : Zero curvature at start. 96 * Icnend - Additional condition at the end of the curve: 97 * 0 : No additional condition. 98 * 1 : Zero curvature at end. 99 * Iopen - Flag telling if the curve should be open or closed: 100 * 1 : Open curve. 101 * 0 : Closed, non-periodic curve. 102 * -1 : Periodic curve. 103 * Ik - The order of the B-spline curve to be produced. 104 * Astpar - Parameter-value to be used at the start of the curve. 105 * 106 * Output: 107 * cendpar - Parameter-value used at the end of the curve. 108 * Rc - Pointer to output-curve. 109 * Gpar - Pointer to the parameter-values of the points in 110 * the curve. Represented only once, although derivatives 111 * and second-derivatives will have the same parameter- 112 * value as the points. 113 * Jnbpar - No. of different parameter-values. 114 * Jstat - status variable: 115 * < 0 : Error. 116 * = 0 : Ok. 117 * > 0 : Warning. 118 * 119 * Method: First the parametrization of the curve and the type 120 * specification of points/derivatives are checked and/or 121 * corrected. Then the knots are calculated, and the 122 * interpolation is performed. 123 * 124 * Calls: s1906,s1901,s6err. 125 * 126 * Written by: A.M. Ytrehus Si Oslo, Norway Sep. 1988. 127 * The main routine, p19501, is written by: T. Dokken SI. 128 * Rewised by: Trond Vidar Stensby, SI, 1991-07 129 * REWISED BY: Vibeke Skytt, 03.94. This routine corresponds to s1334, 130 * but differ in the use of the parameter 131 * iopen and the input array ntype is of 132 * type int. 133 ***************************************************************** 134 */ 135 { 136 int kpos = 0; 137 int kstat = 0; 138 int *ltype = SISL_NULL; /* The kind of interpolation conditions. */ 139 int knpt; /* Number of acepted interpolation conditions. */ 140 double *lcond = SISL_NULL; /* The number of acepted interpolation conditions. */ 141 142 *jstat = 0; 143 144 /* Transform interpolation conditions. */ 145 146 s1906 (epoint, nptyp, icnsta, icnend, inbpnt, idim, &lcond, 147 <ype, &knpt, &kstat); 148 if (kstat < 0) 149 goto error; 150 151 /* Interpolate. */ 152 153 s1912(s1909, s1902, lcond, ltype, knpt, astpar, ik, idim, iopen, 154 cendpar, rc, gpar, jnbpar, &kstat); 155 if (kstat < 0) goto error; 156 157 *jstat = 0; 158 goto out; 159 160 /* Error in lower level routine. */ 161 error: *jstat = kstat; 162 s6err("s1356",*jstat,kpos); 163 goto out; 164 165 out: 166 if (ltype != SISL_NULL) 167 freearray (ltype); 168 if (lcond != SISL_NULL) 169 freearray (lcond); 170 171 return; 172 } 173