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 /*
43 *
44 * $Id: s1732.c,v 1.2 1994-10-19 14:55:31 pfu Exp $
45 *
46 */
47
48
49 #define S1732
50
51 #include "sislP.h"
52
53 #if defined(SISLNEEDPROTOTYPES)
54 void
s1732(SISLCurve * pc,int icont,double * cstart,double * cend,double * gcoef,int * jstat)55 s1732(SISLCurve *pc,int icont,double *cstart,double *cend,double *gcoef,int *jstat)
56 #else
57 void s1732(pc,icont,cstart,cend,gcoef,jstat)
58 SISLCurve *pc;
59 int icont;
60 double *cstart;
61 double *cend;
62 double *gcoef;
63 int *jstat;
64 #endif
65 /*
66 *********************************************************************
67 *
68 *********************************************************************
69 *
70 * PURPOSE : To pick out the next Bezier curve of a B-spline curve.
71 * This function requere a B_spline curve that is the
72 * result of s1730. This rutine do not check that the
73 * curve is correct.
74 *
75 *
76 *
77 * INPUT : pc - B-spline curve to convert.
78 * icont - The number of the Bezier curve to pick.
79 *
80 *
81 *
82 * OUTPUT : cstart - The start parameter value to the Bezier curve.
83 * cend - The end parameter value to the Bezier curve.
84 * gcoef - The vertices to the Bezier curve.
85 * jstat - status messages
86 * > 0 : warning
87 * = 0 : ok
88 * < 0 : error
89 *
90 *
91 * METHOD :
92 *
93 *
94 * REFERENCES :
95 *
96 *-
97 * CALLS :
98 *
99 * WRITTEN BY : Arne Laksaa, SI, 88-11.
100 * REVISED BY : Johannes Kaasa, SI, May 1992 (Introduced NURBS)
101 * REVISED BY : Christophe Birkeland, July 1992 (Test line 97)
102 * Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.
103 * *jstat = 0 in begining
104 * Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994.
105 * Added check on 'icont' lower bound.
106 *
107 *********************************************************************
108 */
109 {
110 int kpos=0; /* Position of error. */
111 int kfi,kla; /* Index to the first and last element
112 in the knot-vector with the start
113 value to the Bezier curve. */
114 double *rcoef; /* Potential rational vertices. */
115 int kdim; /* Potential rational dimension. */
116
117 *jstat = 0;
118
119 /* Check if this is a rational curve. */
120
121 if (pc->ikind == 2 || pc->ikind ==4)
122 {
123 rcoef = pc->rcoef;
124 kdim = pc->idim + 1;
125 }
126 else
127 {
128 rcoef = pc->ecoef;
129 kdim = pc->idim;
130 }
131
132 /* Check that we have a Bezier curve to treat. */
133
134 if ( icont >= 0 && icont < pc->in/pc->ik )
135 {
136 /* The first and last element in pc->et with the
137 start value. */
138
139 kfi = icont*pc->ik;
140 kla = kfi + pc->ik;
141
142 /* Updating the start and the end parameter value
143 to the curve. */
144
145 *cstart = pc->et[kfi];
146 *cend = pc->et[kla+1];
147
148 /* Updating the vertices to the Bezier curve. */
149
150 memcopy(gcoef,&rcoef[kfi*kdim],kdim*pc->ik,double);
151 }
152 else
153 {
154 /* Error, no curve to return. */
155
156 *jstat = -151;
157 s6err("s1732",*jstat,kpos);
158 }
159 }
160