00001 //=========================================================================== 00002 // GoTools - SINTEF Geometry Tools version 1.1 00003 // 00004 // GoTools module: CORE 00005 // 00006 // Copyright (C) 2000-2007 SINTEF ICT, Applied Mathematics, Norway. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation version 2 of the License. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 00020 // 59 Temple Place - Suite 330, 00021 // Boston, MA 02111-1307, USA. 00022 // 00023 // Contact information: E-mail: tor.dokken@sintef.no 00024 // SINTEF ICT, Department of Applied Mathematics, 00025 // P.O. Box 124 Blindern, 00026 // 0314 Oslo, Norway. 00027 // 00028 // Other licenses are also available for this software, notably licenses 00029 // for: 00030 // - Building commercial software. 00031 // - Building software whose source code you wish to keep private. 00032 //=========================================================================== 00033 #ifndef _SISL_CODE_H 00034 #define _SISL_CODE_H 00035 00036 //=========================================================================== 00037 // SISL DEFINEs 00038 //=========================================================================== 00040 /* Name of geometry objects. Used in branching. */ 00041 #define SISLPOINT 0 00042 #define SISLCURVE 1 00043 #define SISLSURFACE 2 00044 00045 00046 //=========================================================================== 00047 // SISL structs 00048 //=========================================================================== 00049 00050 //=========================================================================== 00051 typedef struct SISLdir 00052 //=========================================================================== 00053 { 00054 int igtpi; /* 0 - The direction of the surface or curve 00055 is not greater than pi in any 00056 parameter direction. 00057 1 - The direction of the surface or curve 00058 is greater than pi in the first 00059 parameter direction. 00060 2 - The direction of the surface is greater 00061 than pi in the second parameter 00062 direction. */ 00063 double *ecoef; /* The coordinates to the center of the cone.*/ 00064 double aang; /* The angle from the center whice describe the 00065 cone. */ 00066 double *esmooth; /* Coordinates of object after smoothing. */ 00067 } SISLdir; 00068 /* The following structure contains 3 different boxes. The 00069 first box is the plain box given by the coefficients of the 00070 object. The second box is expanded with the half of a given 00071 tolerance. The third box is expanded with half the tolerance 00072 in the inner and for the vertices at the edges/endpoints 00073 a distance of half the tolerance is removed. The minimum and 00074 maximum values of the boxes are given by the arrays 00075 e2min[0] - e2min[2] and e2max[0] - e2max[2]. The tolerances used 00076 when making the boxes are stored in etol[0] - etol[2]. etol[0] 00077 will always be equal to zero. If a box is made, the pointers 00078 belonging to this box points to arrays, otherwise they point 00079 to SISL_NULL. */ 00080 00081 //=========================================================================== 00082 typedef struct SISLbox 00083 //=========================================================================== 00084 { 00085 double *emax; /* The minimum values to the boxes. */ 00086 double *emin; /* The maximum values to the boxes. */ 00087 int imin; /* The index of the min coeff (one-dim case) */ 00088 int imax; /* The index of the max coeff (one-dim case) */ 00089 00090 double *e2max[3]; /* The minimum values dependant on tolerance.*/ 00091 double *e2min[3]; /* The maximum values dependant on tolerance.*/ 00092 double etol[3]; /* Tolerances of the boxes. */ 00093 } SISLbox; 00094 00095 //=========================================================================== 00096 typedef struct SISLCurve 00097 //=========================================================================== 00098 { 00099 int ik; /* Order of curve. */ 00100 int in; /* Number of vertices. */ 00101 double *et; /* Pointer to the knotvector. */ 00102 double *ecoef; /* Pointer to the array containing vertices. */ 00103 double *rcoef; /*Pointer to the array of scaled vertices if 00104 rational. */ 00105 int ikind; /* Kind of curve 00106 = 1 : Polynomial B-spline curve. 00107 = 2 : Rational B-spline curve. 00108 = 3 : Polynomial Bezier curve. 00109 = 4 : Rational Bezier curve. */ 00110 int idim; /* Dimension of the space in which the curve 00111 lies. */ 00112 int icopy; /* Indicates whether the arrays of the curve 00113 are copied or referenced by creation of the 00114 curve. 00115 = 0 : Pointer set to input arrays. 00116 = 1 : Copied. 00117 = 2 : Pointer set to input arrays, 00118 but are to be treated as copied. */ 00119 SISLdir *pdir; /* Pointer to a structur to store curve 00120 direction. */ 00121 SISLbox *pbox; /* Pointer to a structur to store the 00122 surrounded boxes. */ 00123 int cuopen; /* Open/closed flag. */ 00124 } SISLCurve; 00125 00126 //=========================================================================== 00127 typedef struct SISLIntcurve 00128 //=========================================================================== 00129 { 00130 int ipoint; /* Number of points defining the curve. */ 00131 int ipar1; /* Number of parameter directions of first 00132 object. */ 00133 int ipar2; /* Number of parameter directions of second 00134 * object. */ 00135 double *epar1; /* Pointer to the parameter-values of the 00136 points 00137 in the first object. */ 00138 double *epar2; /* Pointer to the parameter-values of the 00139 points 00140 in the second object. If one of the objects 00141 is an analytic curve or surface epar2 points 00142 to nothing. */ 00143 SISLCurve *pgeom; /* Pointer to the intersection curve in the 00144 geometry space. If the curve is not 00145 computed, pgeom points to nothing. */ 00146 SISLCurve *ppar1; /* Pointer to the intersection curve in the 00147 parameter plane of the first object. If 00148 the curve is not computed, ppar1 points 00149 to nothing. */ 00150 SISLCurve *ppar2; /* Pointer to the intersection curve in the 00151 parameter plane of the second object. If 00152 the curve is not computed, ppar2 points 00153 to nothing. */ 00154 int itype; /* Kind of curve. 00155 = 1 : Straight line. 00156 = 2 : Closed loop. No singularities. 00157 = 3 : Closed loop. One singularity. 00158 Not used. 00159 = 4 : Open curve. No singularity. 00160 = 5 : Open curve. Singularity at the 00161 beginning of the curve. 00162 = 6 : Open curve. Singularity at the end 00163 of the curve. 00164 = 7 : Open curve. Singularity at the 00165 beginning and end of the curve. 00166 = 8 : An isolated singularity. Not used. 00167 = 9 : The curve is exact, pgeom and either 00168 ppar1 or ppar2 is set. */ 00169 00170 int pretop[4]; /* Pretopology */ 00171 } SISLIntcurve; 00172 00173 //=========================================================================== 00174 typedef struct SISLIntsurf 00175 //=========================================================================== 00176 { 00177 int ipoint; /* Number of points defining the curve. */ 00178 int ipar; /* Number of parameter directions of */ 00179 double *epar; /* Pointer to the parameter-values of the 00180 points, dimension: ipoint*ipar */ 00181 int *const_par; /* Constant parameter direction between 00182 two points in epar. */ 00183 } SISLIntsurf; 00184 00185 //=========================================================================== 00186 typedef struct SISLIntpt 00187 //=========================================================================== 00188 { 00189 int ipar; /* Number of parameter directions in 00190 * intersection problem. */ 00191 double *epar; /* Parametervalues of point, possibly in two 00192 * objects. */ 00193 double adist; /* Distance between the objects in this point. 00194 * tdist is used in closest point problems. */ 00195 struct SISLIntpt *pcurve; /* Not used, kept for compatibility with old 00196 version on the structure.*/ 00197 int iinter; /* = 1 ORDINARY MAIN POINT 00198 = 2 SINGULAR MAIN POINT 00199 = 3 TRIM MAIN POINT 00200 = -1 ORDINARY HELP POINT 00201 = -2 SINGULAR HELP POINT 00202 = -3 TRIM HELP POINT */ 00203 struct SISLIntpt **pnext; /* Pointers to next points in each curve 00204 * chain. */ 00205 int *curve_dir; /* An array of curve directions + from - to 00206 * this point. */ 00207 int no_of_curves; /* Number of curves containing this point. */ 00208 int no_of_curves_alloc; /* The size of the arrays allocated */ 00209 int *left_obj_1; /* Pretopology information, one for each 00210 * curve. */ 00211 int *left_obj_2; /* Pretopology information, one for each 00212 * curve. */ 00213 int *right_obj_1; /* Pretopology information, one for each 00214 curve. */ 00215 int *right_obj_2; /* Pretopology information, one for each 00216 curve. */ 00217 int size_1; /* Size of geo_data_1 */ 00218 int size_2; /* Size of geo_data_2 */ 00219 double *geo_data_1; /* Containing geometric info first object */ 00220 double *geo_data_2; /* Containing geometric info second object */ 00221 /* double geo_aux[3]; Containing auxiliary geo info, see sh6idput*/ 00222 double geo_track_3d[10]; /* To store intersection curve info */ 00223 double geo_track_2d_1[7]; 00224 double geo_track_2d_2[7]; 00225 int edge_1; /* Edge flag for topology */ 00226 int edge_2; 00227 int marker; /* Help attribute when creating lists */ 00228 int evaluated; /* Help attribute when creating tracks */ 00229 struct SISLTrimpar *trim[2]; /* Used if pt is in trim curve. */ 00230 int iside_1; /* Left/right evaluator flag. -1,0+ */ 00231 int iside_2; /* Left/right evaluator flag. -1,0+*/ 00232 } SISLIntpt; 00233 00234 //=========================================================================== 00235 typedef struct SISLIntlist 00236 //=========================================================================== 00237 { 00238 SISLIntpt *pfirst; /* Pointer to first point in list. */ 00239 SISLIntpt *plast; /* Pointer to last point in list. */ 00240 int ind_first; /* Index pointer in pfirst */ 00241 int ind_last; /* Index pointer in plast */ 00242 int itype; /* Status of curve-segment. 00243 = 0 : open curve, no singularities. 00244 = 1 : closed curve, no singularities. 00245 = 2 : more than two curves meet at start point. 00246 = 3 : more than two curves meet at end point. 00247 = 4 : more than two curves meet at start 00248 and end point. 00249 = 5 : isolated singularity. 00250 = 6 : touching area of surface. */ 00251 int inumb; /* Number of points in the list. */ 00252 int pretop[4]; /* Pretopology */ 00253 } SISLIntlist; 00254 00255 00256 00257 //=========================================================================== 00258 typedef struct SISLIntdat 00259 //=========================================================================== 00260 { 00261 SISLIntpt **vpoint; 00262 int ipoint; 00263 int ipmax; 00264 SISLIntlist **vlist; 00265 int ilist; 00266 int ilmax; 00267 } SISLIntdat; 00268 00269 00270 00271 //=========================================================================== 00272 typedef struct SISLSurf 00273 //=========================================================================== 00274 { 00275 int ik1; /* Order of surface in first parameter 00276 direction. */ 00277 int ik2; /* Order of surface in second parameter 00278 direction. */ 00279 int in1; /* Number of vertices in first parameter 00280 direction. */ 00281 int in2; /* Number of vertices in second parameter 00282 direction. */ 00283 double *et1; /* Pointer to knotvector in first parameter 00284 direction. */ 00285 double *et2; /* Pointer to knotvector in second parameter 00286 direction. */ 00287 double *ecoef; /* Pointer to array of vertices of surface. */ 00288 double *rcoef; /* Pointer to the array of scaled vertices 00289 if surface is rational. */ 00290 int ikind; /* Kind of surface 00291 = 1 : Polynomial B-spline tensor-product 00292 surface. 00293 = 2 : Rational B-spline tensor-product 00294 surface. 00295 = 3 : Polynomial Bezier tensor-product 00296 surface. 00297 = 4 : Rational Bezier tensor-product 00298 surface. */ 00299 int idim; /* Dimension of the space in which the surface 00300 lies. */ 00301 int icopy; /* Indicates whether the arrays of the surface 00302 are copied or referenced by creation of 00303 the surface. 00304 = 0 : Pointer set to input arrays. 00305 = 1 : Copied. 00306 = 2 : Pointer set to input arrays, 00307 but are to be treated as copied. */ 00308 SISLdir *pdir; /* Pointer to a structur to store surface 00309 direction. */ 00310 SISLbox *pbox; /* Pointer to a structur to store the 00311 surrounded boxes. */ 00312 int use_count; /* use count so that several tracks can share 00313 surfaces, no internal use */ 00314 int cuopen_1; /* Open/closed flag, 1. par directiion */ 00315 int cuopen_2; /* Open/closed flag. 2. par direction */ 00316 } SISLSurf; 00317 00318 typedef struct SISLTrack 00319 { 00320 SISLSurf *psurf_1; /* Pointer to first surface in intersection */ 00321 SISLSurf *psurf_2; /* Pointer to second surface in intersection */ 00322 SISLCurve *pcurve_3d; /* Pointer to 3D support curve. */ 00323 SISLCurve *pcurve_2d_1; /* Pointer to 2D support curve in first 00324 parameter space. */ 00325 SISLCurve *pcurve_2d_2; /* Pointer to 2D support curve in second 00326 parameter space. */ 00327 int ideg; /* Type of track. 00328 = 0, Bspline vs Bspline 00329 = 1, Bspline vs Plane 00330 = 2, Bspline vs Quadric surface 00331 = 1001 Bspline vs Torus surface 00332 = 1003 Bspline silhouette line, parallel 00333 projection 00334 = 1004 Bspline silhouette line, perspective 00335 projection 00336 = 1005 Bspline silhouette line, circular 00337 projection */ 00338 00339 double eimpli[16]; /* Description of the implicit surface */ 00340 int turned; /* Connection between the direction of the 00341 support curve and the cross product 00342 between the two surface normals. 00343 = 0, same direction 00344 = 1, oposite direction */ 00345 int exact; /* Flag if curve is exact */ 00346 int pretop[4]; /* Pretopology */ 00347 int sing_start; /* Singular start end point markers */ 00348 int sing_end; 00349 } SISLTrack; 00350 00351 //=========================================================================== 00352 typedef struct SISLPoint 00353 //=========================================================================== 00354 { 00355 double ec[3]; 00356 int idim; /* The dimension the point lies in */ 00357 double *ecoef; /* Pointer to the array containing the 00358 coordinates */ 00359 int icopy; /* Indicates whether the arrays of the point 00360 are copied or referenced by creation of 00361 the point. 00362 = 0 : Pointer set to input arrays. 00363 = 1 : Copied. 00364 = 2 : Pointer set to input arrays, 00365 but are to be treated as copied. */ 00366 00367 SISLbox *pbox; /*Pointer to a structur to store the boxes. */ 00368 } SISLPoint; 00369 00370 //=========================================================================== 00371 typedef struct SISLObject 00372 //=========================================================================== 00373 { 00374 int iobj; /* Integer indicates which kind of geometric 00375 object is contained in a particular 00376 instance of the structure. 00377 = 1 (SISLCurve) - curve. 00378 = 2 (SURFACE) - tensor-product surface. */ 00379 SISLPoint *p1; /* Pointer to a point (instance of Point). */ 00380 SISLCurve *c1; /* Pointer to a curve 00381 * (instance of SISLCurve). */ 00382 SISLSurf *s1; /* Pointer to a surface 00383 * (instance of SISLSurf). */ 00384 struct SISLObject *o1; /* Pointer to parent object 00385 * (instance of Object). */ 00386 struct SISLObject *edg[4]; /* Pointer to objects edges 00387 * (instance of Object). */ 00388 struct SISLObject *psimple; /* Indicates if object/object intersection 00389 * is simple case. */ 00390 } SISLObject; 00391 00392 //=========================================================================== 00393 typedef struct SISLPtedge 00394 //=========================================================================== 00395 { 00396 SISLIntpt *ppt; /* Pointer to intersection points. */ 00397 struct SISLPtedge *pnext; /* Pointer to next element in the list. */ 00398 } SISLPtedge; 00399 00400 //=========================================================================== 00401 typedef struct SISLEdge 00402 //=========================================================================== 00403 { 00404 int iedge; /* Number of edges/endpoints of object. */ 00405 int ipoint; /* Number of intersection points found on 00406 * the edges. */ 00407 SISLPtedge **prpt; /* Array containing lists of pointers to the 00408 * intersections at the edges. */ 00409 } SISLEdge; 00410 00411 00412 00413 //=========================================================================== 00414 // SISL constructors/destructors 00415 //=========================================================================== 00416 SISLObject *newObject(int); 00417 SISLCurve *newCurve(int,int,double *,double *,int,int,int); 00418 void freeCurve(SISLCurve *); 00419 SISLSurf *newSurf(int,int,int,int,double *,double *,double *,int,int,int); 00420 void freeIntcrvlist(SISLIntcurve **,int); 00421 void freeIntcurve(SISLIntcurve *pintc); 00422 void freeSurf(SISLSurf *); 00423 00424 //=========================================================================== 00425 // SISL functions directly used by 'sisl_dependent' 00426 //=========================================================================== 00427 00428 void s1220(double *et,int ik,int in,int *ileft, 00429 double ax,int ider,double ebder[],int *jstat); 00430 void s1310(SISLSurf *,SISLSurf *,SISLIntcurve *,double,double,int,int,int *); 00431 void s1314(SISLSurf *,double *,double *,int,double,double,double, 00432 SISLIntcurve *,int,int,int *); 00433 void s1421(SISLSurf *,int,double [],int *,int *,double [],double [],int *); 00434 void s1770(SISLCurve *,SISLCurve *,double,double,double,double,double, 00435 double,double,double *,double *,int *); 00436 void s1851(SISLSurf *,double [],double [],int,double,double, 00437 int *,double **,int *,SISLIntcurve ***,int *); 00438 void s1859(SISLSurf *,SISLSurf *,double,double, 00439 int *,double **,double **,int *,SISLIntcurve ***,int *); 00440 00441 void sh1857(SISLCurve *,SISLCurve *,double,double,int,int *,SISLTrack ***, 00442 int *,double **,double **,int **,int *,SISLIntcurve ***,int *); 00443 00444 double s6scpr(double e1[],double e2[],int idim); 00445 void s6err(char *,int,int); 00446 00448 00449 #endif // _SISL_CODE_H 00450 00451