1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
|
/*
* Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
* Applied Mathematics, Norway.
*
* Contact information: E-mail: tor.dokken@sintef.no
* SINTEF ICT, Department of Applied Mathematics,
* P.O. Box 124 Blindern,
* 0314 Oslo, Norway.
*
* This file is part of SISL.
*
* SISL is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* SISL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with SISL. If not, see
* <http://www.gnu.org/licenses/>.
*
* In accordance with Section 7(b) of the GNU Affero General Public
* License, a covered work must retain the producer line in every data
* file that is created or manipulated using SISL.
*
* Other Usage
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial activities involving the SISL library without
* disclosing the source code of your own applications.
*
* This file may be used in accordance with the terms contained in a
* written agreement between you and SINTEF ICT.
*/
#include "sisl-copyright.h"
/*
*
* $Id: s1614.c,v 1.2 1994-12-07 12:05:37 pfu Exp $
*
*/
#define S1614
#include "sislP.h"
#if defined(SISLNEEDPROTOTYPES)
void s1614(double epoint[], int inbpnt, int idim, int eptyp[],
double spoint[], int *jnbpnt, int sptyp[], int *jstat)
#else
void s1614(epoint, inbpnt, idim, eptyp,spoint, jnbpnt, sptyp, jstat)
double epoint[];
int inbpnt;
int idim;
int eptyp[];
double spoint[];
int *jnbpnt;
int sptyp[];
int *jstat;
#endif
/*
*************************************************************************
*
* PURPOSE: To check the point description vector to ensure that the
* points returned from this routine can be used directly in the
* conversion of conics to B-spline representation.
*
* INPUT:
* Epoint - The points/tangents describing the conic.
* Inbpnt - No. of points/tangents in the epoint array.
* Idim - The dimension of the space in which the points lie.
* Eptyp - Type indicator for points/tangents :
* 1 - Ordinary point.
* 2 - Knuckle point. (Is treated as an ordinary point.)
* 3 - Tangent to next point.
* 4 - Tangent to prior point.
*
* Output:
* Spoint - The corrected points.
* Jnbpnt - No. of corrected points.
* Sptyp - Type indicator for corrected points.
* Jstat - status messages:
* < 0 : Error.
* = 0 : Ok.
* > 0 : Warning.
*
* Method:
* The point description is run through, to check if some points are
* assigned two tangents. If two tangents are detected, the first is
* used and the second discarded. In addition, the first points
* interpolation-condition detected is put in the start of the output
* array, and the last points interpolation-condition is put in the end
* of the output array.
*-
* Calls: s6err.
*
* Written by: A.M. Ytrehus, SI Oslo Oct.91.
* After FORTRAN (P1614) written by: T. Dokken SI.
* Revised by: J. Kaasa, SI, Aug. 92 (Fixed bugs in connection with
* type handling).
*****************************************************************
*/
{
int ki, kp, kk, kki;
int khelp;
int ktell = 0;
int kflag = 0;
int knbpnt = 0;
int ktyp = 1;
int ktypm1;
double tdum;
int kpos = 0;
*jstat = 0;
/* Run through and test the type of the data points. Copy
approved points and tangents into output variables. */
for (ki = 0; ki < inbpnt; ki++)
{
ktypm1 = ktyp;
ktyp = eptyp[ki];
if (!((ktyp < 1 || ktyp > 4) ||
(knbpnt == 0 && ktyp == 4) ||
(ktyp == 3 && ktypm1 == 3) ||
(ktyp == 4 && ktypm1 == 4) ||
(ktyp == 4 && ktypm1 == 3)))
{
/* Save this point or tangent in spoint and sptyp. */
sptyp[knbpnt] = ktyp;
kki = idim * ki;
kk = idim * knbpnt;
for (kp = 0; kp < idim; kp++)
spoint[kk + kp] = epoint[kki + kp];
knbpnt++;
}
}
/* Remove last point if the type is 3 (which means tangent to next point. */
if (ktyp == 3)
knbpnt--;
/* We cannot make use of more than five points.
Choose the first five points. */
if (knbpnt > 5)
{
knbpnt = 5;
/* Check the type of (new) last point. */
if (sptyp[knbpnt - 1] == 3)
{
/* Cut out this point, and use point no. 6 instead. */
sptyp[knbpnt - 1] = sptyp[knbpnt];
kk = idim * (knbpnt - 1);
for (kp = 0; kp < idim; kp++)
spoint[kk + kp] = spoint[kk + idim + kp];
}
}
/* Ensure that first entry is a point. */
ktyp = sptyp[0];
if (ktyp > 2)
{
/* Interchange the two first conditions. */
kflag = 1;
sptyp[0] = 1;
sptyp[1] = 4;
for (kp = 0; kp < idim; kp++)
{
tdum = spoint[kp];
spoint[kp] = spoint[kp + idim];
spoint[kp + idim] = tdum;
}
}
/* Ensure that last entry is a point. */
ktyp = sptyp[knbpnt - 1];
if (ktyp > 2)
{
/* Interchange the two last conditions. */
kflag = 1;
sptyp[knbpnt - 1] = 1;
sptyp[knbpnt - 2] = 3;
kk = idim * (knbpnt - 1);
for (kp = 0; kp < idim; kp++)
{
tdum = spoint[kk + kp];
spoint[kk + kp] = spoint[kk - idim + kp];
spoint[kk - idim + kp] = tdum;
}
}
/* Count no. of points. If less than two, we cannot even
create a straight line. */
for (ki = 0; ki < knbpnt; ki++)
{
ktyp = sptyp[ki];
if (ktyp < 3)
ktell++;
}
if (ktell <= 1)
goto err181;
/* Run through and remove double tangents that may be introduced by
the interchange of end-point/end-tangents. */
ktyp = 1;
if (kflag == 1)
{
khelp = knbpnt;
ktypm1 = ktyp;
for (ki = 0; ki < khelp; ki++)
{
ktyp = sptyp[ki];
if ((ktyp == 3 && ktypm1 == 3) ||
(ktyp == 4 && ktypm1 == 4) ||
(ktyp == 4 && ktypm1 == 3))
{
/* Remove last of doble tangent. */
knbpnt--;
for (kk = ki; kk < knbpnt; kk++)
{
sptyp[kk] = sptyp[kk + 1];
kki = idim * kk;
for (kp = 0; kp < idim; kp++)
spoint[kki + kp] = spoint[kki + idim + kp];
}
}
}
}
*jnbpnt = knbpnt;
goto out;
/* Error in input, less than two points given in problem formulation. */
err181:
*jstat = -181;
s6err ("s1614", *jstat, kpos);
goto out;
out:
return;
}
|