//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00021 #ifndef FALSE 00022 #define FALSE 0 00023 #endif 00024 00025 #ifdef __BORLANDC__ 00026 using std::FILE; 00027 using std::sscanf; 00028 #endif 00029 00030 void read_non_comment(FILE* fp, char* string) 00031 { 00032 char c; /* char to find end of line and end of file */ 00033 00034 fscanf(fp,"%s",string); 00035 00036 /* read until first string is a letter */ 00037 while (string[0] == '$') 00038 { 00039 /* find end of line */ 00040 while ((c = getc(fp)) != '\n') 00041 { 00042 if (c == EOF) 00043 { 00044 string[0] = c; 00045 string[1] = '\0'; 00046 return; 00047 } 00048 } 00049 /* get data */ 00050 fscanf(fp,"%s",string); 00051 } 00052 00053 } 00054 00055 00056 void file_to_obj(FILE* fp, SISLObject** wo, int* jstat) 00057 00058 /* 00059 ********************************************************************************* 00060 * 00061 * Purpose : To read a B-spline communication file. 00062 * File format hplabs. 00063 * Naming conventions SI/HP. 00064 * 00065 * Input : from_file - File name. 00066 * 00067 * Output : wo - Pointer to a SISLObject. 00068 * jstat - status flag 00069 * >= 0 - OK. 00070 * < 0 - Error 00071 * 00072 * Written by : Bjoern Olav Hoset, SI, 06-89. 00073 * 00074 ******************************************************************************** 00075 */ 00076 { 00077 SISLCurve *qc=NULL; /* Pointer to struct SISLCurve */ 00078 SISLSurf *qs=NULL; /* Pointer to struct SISLSurf */ 00079 SISLObject *qo=NULL; /* Pointer to struct SISLObject */ 00080 // FILE *fp=NULL;/* FILE pointer to read from */ 00081 char string[80]; /* character to read $ which identifies a comment */ 00082 int value; /* type of B-Spline and numbers */ 00083 int value2; /* second type of B-Spline and numbers */ 00084 int kcopy=1; /* Flag */ 00085 int kcuopen; /* Open/closed flag for curves */ 00086 int kcuopen1; /* Open/closed flag for surf */ 00087 int kcuopen2; /* Open/closed flag for surf */ 00088 int kdim; /* dimension of target space */ 00089 int kdim1; /* dimension + 1 */ 00090 int kind; /* identify point, curve, surface */ 00091 int kk1; /* Order of curve or in 1st parameter direction of surface */ 00092 int kk2; /* Order in 2nd parameter direction of surface */ 00093 int kn1; /* # of vertices of curve or in 1st parameter direction of surf */ 00094 int kn2=0; /* # of vertices in 2nd parameter direction of surface */ 00095 double *st1=NULL; /* Knot vector of curve or in 1st parameter direction of surface */ 00096 double *st2=NULL; /* Knot vector in 2nd parameter direction of surface */ 00097 double *scoef=NULL; /* Vertices of curve or surface */ 00098 double dummy; /* trashbin for fourth value in vertices */ 00099 double help[4]; /* Help array in computing transformated vertic. */ 00100 double matrix[16]; /* instance matrix */ 00101 double *sptr=NULL; /* Dummy pointer */ 00102 int ki, kj; /* Counters */ 00103 int kkind; 00104 int *ind_hex=0; 00105 int hex=FALSE; 00106 int *ind_2 = (int*)&dummy; 00107 00108 //vector__double__ seg_u; 00109 //vector__double__ seg_v; 00110 //vector__int__ prio_u; 00111 //vector__int__ prio_v; 00112 //vector__double__ pbox; 00113 00114 /* 00115 * Open file with name from_file 00116 * ----------------------------- 00117 */ 00118 00119 /* 00120 * Read data from file. 00121 * -------------------- 00122 */ 00123 00124 read_non_comment(fp,string); 00125 00126 /* 00127 * Test if end of file is reached 00128 * ------------------------------ 00129 */ 00130 00131 if (string[0] == EOF) goto err001; 00132 else 00133 { 00134 sscanf(string,"%d",&value); 00135 00136 if (value >=10) 00137 { 00138 hex=true; 00139 value -=10; 00140 } 00141 switch (value) 00142 { 00143 case 0: /* object is a curve or a surface */ 00144 00145 read_non_comment(fp,string); 00146 sscanf(string,"%d",&value); 00147 for (ki = 0; (string[ki] = getc(fp)) != '\n'; ki++); 00148 string[ki] = '\0'; 00149 00150 /* 00151 * if a second numerical value is specified in this line, 00152 * a surface is assumed 00153 * ------------------------------------------------------ 00154 */ 00155 00156 kind = sscanf(string,"%d",&value2); 00157 00158 /* now back to reading the object */ 00159 00160 if (kind !=1 ) 00161 { 00162 /* 00163 * object is a curve 00164 * ----------------- 00165 */ 00166 00167 /* 00168 * order 00169 * ------ 00170 */ 00171 00172 kk1 = value; 00173 00174 /* 00175 * number of vertices 00176 * ------------------ 00177 */ 00178 00179 read_non_comment(fp,string); 00180 sscanf(string,"%d",&kn1); 00181 00182 /* 00183 * dimension 00184 * --------- 00185 */ 00186 00187 read_non_comment(fp,string); 00188 sscanf(string,"%d",&kdim); 00189 00190 /* 00191 * curve open/closed 00192 * ------------------ 00193 */ 00194 00195 read_non_comment(fp,string); 00196 sscanf(string,"%d",&kcuopen); 00197 00198 /* 00199 * rational B-Spline or not 00200 * ------------------------ 00201 */ 00202 00203 read_non_comment(fp,string); 00204 sscanf(string,"%d",&value); 00205 /* if (value != 0) goto err002; */ 00206 00207 if (value != 0) 00208 { 00209 kdim1 = kdim+1; 00210 kkind = 2; 00211 } 00212 else 00213 { 00214 kdim1 = kdim; 00215 kkind = 1; 00216 } 00217 00218 /* 00219 * Allocate space for knot vector 00220 * ------------------------------ 00221 */ 00222 00223 st1 = new double[kk1+kn1]; 00224 if (!st1) goto err101; 00225 00226 /* 00227 * Read in knot vector 00228 * ------------------- 00229 */ 00230 00231 read_non_comment(fp,string); 00232 if (hex) 00233 { 00234 ind_hex = (int *)st1; 00235 sscanf(string,"%x",ind_hex); 00236 fscanf(fp,"%x",ind_hex+1); 00237 for (ind_hex=(int *)(st1+1),ki=1;ki < kk1+kn1;ki++,ind_hex+=2) 00238 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00239 } 00240 else 00241 { 00242 sscanf(string,"%lf",st1); 00243 for (sptr=st1+1,ki=1;ki < kk1+kn1;ki++,sptr++) 00244 fscanf(fp,"%lf",sptr); 00245 } 00246 00247 /* 00248 * Allocate space for control vertices 00249 * ----------------------------------- 00250 */ 00251 00252 scoef = new double[kn1*kdim1]; 00253 if (!scoef) goto err101; 00254 00255 /* 00256 * Read in control vertices 00257 * ------------------------ 00258 */ 00259 00260 read_non_comment(fp,string); 00261 if (hex) 00262 { 00263 ind_hex = (int *)scoef; 00264 sscanf(string,"%x",ind_hex); 00265 fscanf(fp,"%x",ind_hex+1); 00266 if (kdim > 1) 00267 { 00268 ind_hex +=2; 00269 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00270 if (kdim > 2) 00271 { 00272 ind_hex +=2; 00273 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00274 } 00275 } 00276 fscanf(fp,"%x %x",ind_2,ind_2+1); 00277 if (kkind == 2) 00278 { 00279 ind_hex +=2; 00280 scoef[kdim] = dummy; 00281 } 00282 for (ki = kdim1; ki < kn1*kn2*kdim1; ki += kdim1) 00283 { 00284 ind_hex +=2; 00285 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00286 if (kdim > 1) 00287 { 00288 ind_hex +=2; 00289 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00290 if (kdim > 2) 00291 { 00292 ind_hex +=2; 00293 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00294 } 00295 } 00296 fscanf(fp,"%x %x",ind_2,ind_2+1); 00297 if (kkind == 2) 00298 { 00299 ind_hex +=2; 00300 scoef[ki+kdim] = dummy; 00301 } 00302 } 00303 00304 } 00305 else 00306 { 00307 sscanf(string,"%lf",scoef); 00308 if (kdim > 1) fscanf(fp,"%lf",&scoef[1]); 00309 if (kdim > 2) fscanf(fp,"%lf",&scoef[2]); 00310 fscanf(fp,"%lf",&dummy); 00311 if (kkind == 2) scoef[kdim] = dummy; 00312 for (ki = kdim1; ki < kn1*kdim1; ki += kdim1) 00313 { 00314 fscanf(fp,"%lf",&scoef[ki]); 00315 if (kdim > 1) fscanf(fp,"%lf",&scoef[ki+1]); 00316 if (kdim > 2) fscanf(fp,"%lf",&scoef[ki+2]); 00317 fscanf(fp,"%lf",&dummy); 00318 if (kkind == 2) scoef[ki+kdim] = dummy; 00319 } 00320 } 00321 /* 00322 * transformation data 00323 * ------------------- 00324 */ 00325 00326 read_non_comment(fp,string); 00327 sscanf(string,"%lf",matrix); 00328 for (ki = 1; ki < (kdim+1)*(kdim+1); ki ++) 00329 fscanf(fp,"%lf",&matrix[ki]); 00330 00331 /* 00332 * transform vertices with instance matrix 00333 * --------------------------------------- 00334 */ 00335 00336 00337 /* 00338 * test whether matrix is unit matrix 00339 * ---------------------------------- 00340 */ 00341 00342 if (kdim == 1 && 00343 matrix[0] == (double)1.0 && 00344 matrix[1] == (double)0.0 && 00345 matrix[2] == (double)0.0 && 00346 matrix[3] == (double)1.0 ) 00347 { 00348 } 00349 else if (kdim == 2 && 00350 matrix[0] == (double)1.0 && 00351 matrix[1] == (double)0.0 && 00352 matrix[2] == (double)0.0 && 00353 matrix[3] == (double)0.0 && 00354 matrix[4] == (double)1.0 && 00355 matrix[5] == (double)0.0 && 00356 matrix[6] == (double)0.0 && 00357 matrix[7] == (double)0.0 && 00358 matrix[8] == (double)1.0) 00359 { 00360 } 00361 else if (kdim == 3 && 00362 matrix[0] == (double)1.0 && 00363 matrix[1] == (double)0.0 && 00364 matrix[2] == (double)0.0 && 00365 matrix[3] == (double)0.0 && 00366 matrix[4] == (double)0.0 && 00367 matrix[5] == (double)1.0 && 00368 matrix[6] == (double)0.0 && 00369 matrix[7] == (double)0.0 && 00370 matrix[8] == (double)0.0 && 00371 matrix[9] == (double)0.0 && 00372 matrix[10] == (double)1.0 && 00373 matrix[11] == (double)0.0 && 00374 matrix[12] == (double)0.0 && 00375 matrix[13] == (double)0.0 && 00376 matrix[14] == (double)0.0 && 00377 matrix[15] == (double)1.0) 00378 { 00379 } 00380 00381 else 00382 { 00383 if (kdim > 3) goto err005; 00384 for (ki = 0; ki < kn1*kdim; ki += kdim) 00385 { 00386 kdim1 = kdim + 1; 00387 for (kj = 0; kj < kdim1; kj++) 00388 help[kj] = s6scpr(&scoef[ki], 00389 &matrix[kj*kdim1],kdim) 00390 + matrix[kj*kdim1 + kdim]; 00391 00392 if (help[kdim] == 0.0) goto err004; 00393 00394 for (kj = 0; kj < kdim; kj++) 00395 scoef[ki + kj] = help[kj]/help[kdim]; 00396 } 00397 } 00398 00399 00400 00401 /* 00402 * Create an instance of SISLCurve 00403 * --------------------------- 00404 */ 00405 00406 qc = newCurve(kn1,kk1,st1,scoef,kkind,kdim,kcopy); 00407 if (!qc) goto err101; 00408 else 00409 { 00410 /* 00411 * Fill in open/closed flag 00412 * ------------------------ 00413 */ 00414 00415 qc->cuopen = kcuopen; 00416 00417 /* 00418 * Create an instace of SISLObject and connect curve to the SISLObject. 00419 * ------------------------------------------------------------ 00420 */ 00421 00422 qo = newObject(SISLCURVE); 00423 if (!qo) goto err101; 00424 else 00425 { 00426 qo->c1 = qc; 00427 *wo = qo; 00428 } 00429 } 00430 00431 /* 00432 * Remember to free allocated space. 00433 * --------------------------------- 00434 */ 00435 00436 if (st1) delete [] st1; 00437 if (scoef) delete [] scoef; 00438 00439 } 00440 else 00441 /* object is a surface */ 00442 { 00443 /* 00444 * orders of parameter directions 00445 * ------------------------------ 00446 */ 00447 00448 kk1 = value; 00449 kk2 = value2; 00450 00451 /* 00452 * number of vertices 00453 * ------------------ 00454 */ 00455 00456 read_non_comment(fp,string); 00457 sscanf(string,"%d",&kn1); 00458 fscanf(fp,"%d",&kn2); 00459 00460 00461 /* 00462 * dimension 00463 * --------- 00464 */ 00465 00466 read_non_comment(fp,string); 00467 sscanf(string,"%d",&kdim); 00468 kdim1 = kdim; 00469 00470 /* 00471 * surface open/closed 00472 * ------------------ 00473 */ 00474 00475 read_non_comment(fp,string); 00476 sscanf(string,"%d",&kcuopen1); 00477 fscanf(fp,"%d",&kcuopen2); 00478 00479 /* 00480 * rational B-Spline or not 00481 * ------------------------ 00482 */ 00483 00484 read_non_comment(fp,string); 00485 sscanf(string,"%d",&value); 00486 /* if (value != 0) goto err002; 00487 00488 fscanf(fp,"%d",&value); */ 00489 if (value) kdim1++; 00490 00491 /* 00492 * Allocate space for first knot vector 00493 * ------------------------------------ 00494 */ 00495 00496 st1 = new double[kk1+kn1]; 00497 if (!st1) goto err101; 00498 00499 /* 00500 * Read in first knot vector. 00501 * -------------------------- 00502 */ 00503 00504 read_non_comment(fp,string); 00505 if (hex) 00506 { 00507 ind_hex = (int *)st1; 00508 sscanf(string,"%x",ind_hex); 00509 fscanf(fp,"%x",ind_hex+1); 00510 for (ind_hex=(int*)(st1+1),ki=1;ki < kk1+kn1;ki++,ind_hex+=2) 00511 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00512 } 00513 else 00514 { 00515 00516 sscanf(string,"%lf",st1); 00517 for (sptr = st1+1,ki = 1; ki < kn1+kk1; sptr++,ki++) 00518 fscanf(fp,"%lf",sptr); 00519 } 00520 /* 00521 * Allocate space for second knot vector 00522 * ------------------------------------ 00523 */ 00524 00525 st2 = new double[kk2+kn2]; 00526 if (!st2) goto err101; 00527 00528 /* 00529 * Read in second knot vector. 00530 * -------------------------- 00531 */ 00532 00533 read_non_comment(fp,string); 00534 if (hex) 00535 { 00536 ind_hex = (int *)st2; 00537 sscanf(string,"%x",ind_hex); 00538 fscanf(fp,"%x",ind_hex+1); 00539 for (ind_hex=(int*)(st2+1),ki=1;ki < kk2+kn2;ki++,ind_hex+=2) 00540 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00541 } 00542 else 00543 { 00544 00545 sscanf(string,"%lf",st2); 00546 for (sptr = st2+1,ki = 1; ki < kn2+kk2; sptr++,ki++) 00547 fscanf(fp,"%lf",sptr); 00548 } 00549 00550 /* 00551 * Allocate space for control vertices 00552 * ----------------------------------- 00553 */ 00554 00555 scoef = new double[kn1*kn2*kdim1]; 00556 if (!scoef) goto err101; 00557 00558 /* 00559 * Read in control vertices. 00560 * ------------------------- 00561 */ 00562 00563 read_non_comment(fp,string); 00564 if (hex) 00565 { 00566 ind_hex = (int *)scoef; 00567 sscanf(string,"%x",ind_hex); 00568 fscanf(fp,"%x",ind_hex+1); 00569 if (kdim > 1) 00570 { 00571 ind_hex +=2; 00572 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00573 if (kdim > 2) 00574 { 00575 ind_hex +=2; 00576 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00577 } 00578 } 00579 fscanf(fp,"%x %x",ind_2,ind_2+1); 00580 if (value) 00581 { 00582 ind_hex +=2; 00583 scoef[kdim] = dummy; 00584 } 00585 for (ki = kdim1; ki < kn1*kn2*kdim1; ki += kdim1) 00586 { 00587 ind_hex +=2; 00588 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00589 if (kdim > 1) 00590 { 00591 ind_hex +=2; 00592 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00593 if (kdim > 2) 00594 { 00595 ind_hex +=2; 00596 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 00597 } 00598 } 00599 fscanf(fp,"%x %x",ind_2,ind_2+1); 00600 if (value) 00601 { 00602 ind_hex +=2; 00603 scoef[ki+kdim] = dummy; 00604 } 00605 } 00606 00607 } 00608 else 00609 { 00610 sscanf(string,"%lf",scoef); 00611 if (kdim > 1) fscanf(fp,"%lf",&scoef[1]); 00612 if (kdim > 2) fscanf(fp,"%lf",&scoef[2]); 00613 fscanf(fp,"%lf",&dummy); 00614 if (value) scoef[kdim] = dummy; 00615 for (ki = kdim1; ki < kn1*kn2*kdim1; ki += kdim1) 00616 { 00617 fscanf(fp,"%lf",&scoef[ki]); 00618 if (kdim > 1) fscanf(fp,"%lf",&scoef[ki+1]); 00619 if (kdim > 2) fscanf(fp,"%lf",&scoef[ki+2]); 00620 fscanf(fp,"%lf",&dummy); 00621 if (value) scoef[ki+kdim] = dummy; 00622 } 00623 00624 } 00625 /* 00626 * transformation data 00627 * ------------------- 00628 */ 00629 00630 read_non_comment(fp,string); 00631 sscanf(string,"%lf",matrix); 00632 for (ki = 1; ki < (kdim+1)*(kdim+1); ki ++) 00633 fscanf(fp,"%lf",&matrix[ki]); 00634 00635 /* 00636 * transform vertices with instance matrix 00637 * --------------------------------------- 00638 */ 00639 00640 00641 /* 00642 * test whether matrix is unit matrix 00643 * ---------------------------------- 00644 */ 00645 00646 if (kdim == 1 && 00647 matrix[0] == (double)1.0 && 00648 matrix[1] == (double)0.0 && 00649 matrix[2] == (double)0.0 && 00650 matrix[3] == (double)1.0 ) 00651 { 00652 } 00653 else if (kdim == 2 && 00654 matrix[0] == (double)1.0 && 00655 matrix[1] == (double)0.0 && 00656 matrix[2] == (double)0.0 && 00657 matrix[3] == (double)0.0 && 00658 matrix[4] == (double)1.0 && 00659 matrix[5] == (double)0.0 && 00660 matrix[6] == (double)0.0 && 00661 matrix[7] == (double)0.0 && 00662 matrix[8] == (double)1.0) 00663 { 00664 } 00665 else if (kdim == 3 && 00666 matrix[0] == (double)1.0 && 00667 matrix[1] == (double)0.0 && 00668 matrix[2] == (double)0.0 && 00669 matrix[3] == (double)0.0 && 00670 matrix[4] == (double)0.0 && 00671 matrix[5] == (double)1.0 && 00672 matrix[6] == (double)0.0 && 00673 matrix[7] == (double)0.0 && 00674 matrix[8] == (double)0.0 && 00675 matrix[9] == (double)0.0 && 00676 matrix[10] == (double)1.0 && 00677 matrix[11] == (double)0.0 && 00678 matrix[12] == (double)0.0 && 00679 matrix[13] == (double)0.0 && 00680 matrix[14] == (double)0.0 && 00681 matrix[15] == (double)1.0) 00682 { 00683 } 00684 else if (1) 00685 { 00686 } 00687 00688 else 00689 { 00690 if (kdim > 3 || kdim < 1) goto err005; 00691 if (!value) 00692 { 00693 for (ki = 0; ki < kn2*kn1*kdim; ki += kdim) 00694 { 00695 kdim1 = kdim + 1; 00696 for (kj = 0; kj < kdim1; kj++) 00697 help[kj] = s6scpr(&scoef[ki], 00698 &matrix[kj*kdim1],kdim) 00699 + matrix[kj*kdim1 + kdim]; 00700 00701 if (help[kdim] == 0.0) goto err004; 00702 00703 for (kj = 0; kj < kdim; kj++) 00704 scoef[ki + kj] = help[kj]/help[kdim]; 00705 } 00706 } 00707 else 00708 goto err002; 00709 } 00710 00711 // Read segmentation and parameter box for surface 00712 // Nope I do not 00713 //stat = readSegments(fp,seg_u,seg_v,prio_u,prio_v,pbox); 00714 //if (stat < 0) 00715 //goto error; 00716 00717 /* 00718 * Create an instance of SISLSurf. 00719 * --------------------------- 00720 */ 00721 00722 qs = newSurf(kn1,kn2,kk1,kk2,st1,st2,scoef,(value)?2:1,kdim,kcopy); 00723 if (!qs) goto err101; 00724 else 00725 { 00726 // Set segmentation values and parameter box 00727 // Nope this is ignored here 00728 //if (pbox.size() == 4) 00729 //SI_setparbox(qs, pbox.begin()); 00730 00731 //if (seg_u.size() > 0 || seg_v.size() > 0) 00732 //{ 00733 //stat = SI_set_seg(qs, seg_u.size(), seg_u.begin(), 00734 // prio_u.begin(),seg_v.size(), 00735 // seg_v.begin(), prio_v.begin()); 00736 //if (stat < 0) 00737 // goto error; 00738 00739 // } 00740 /* 00741 * Create an instace of Object and connect surface to the Object. 00742 * -------------------------------------------------------------- 00743 */ 00744 00745 qs->cuopen_1 = kcuopen1; 00746 qs->cuopen_2 = kcuopen2; 00747 00748 qo = newObject(SISLSURFACE); 00749 if (!qo) goto err101; 00750 else 00751 { 00752 qo->s1 = qs; 00753 *wo = qo; 00754 } 00755 } 00756 00757 /* 00758 * Remember to free allocated space. 00759 * --------------------------------- 00760 */ 00761 00762 if (st1) delete [] st1; 00763 if (st2) delete [] st2; 00764 if (scoef) delete[] scoef; 00765 00766 00767 } /* end of if curve or surface */ 00768 break; 00769 00770 default: 00771 goto err003; 00772 } 00773 }/* end else */ 00774 00775 /* 00776 * Object read from file. 00777 * ---------------------- 00778 */ 00779 00780 *jstat = 0; 00781 goto out; 00782 00783 /* 00784 * Error in opening/reading from file. 00785 * ----------------------------------- 00786 */ 00787 00788 err001: *jstat = -1; 00789 s6err("file_to_obj",*jstat,0); 00790 goto out; 00791 00792 /* 00793 * Error, object in file was of type rational. 00794 * ------------------------------------------- 00795 */ 00796 00797 err002: *jstat = -2; 00798 s6err("file_to_obj",*jstat,0); 00799 goto out; 00800 00801 /* 00802 * Error, object in file was of unknown type. 00803 * ------------------------------------------ 00804 */ 00805 00806 err003: *jstat = -3; 00807 s6err("file_to_obj",*jstat,0); 00808 goto out; 00809 00810 /* 00811 * Error, Homeogenous division by zero. 00812 * ------------------------------------------ 00813 */ 00814 00815 err004: *jstat = -4; 00816 s6err("file_to_obj",*jstat,0); 00817 goto out; 00818 00819 /* 00820 * Error, Cannot treat this dimension. 00821 * ------------------------------------------ 00822 */ 00823 00824 err005: *jstat = -5; 00825 s6err("file_to_obj",*jstat,0); 00826 goto out; 00827 /* 00828 * Error in memory allocation. 00829 * --------------------------- 00830 */ 00831 00832 err101: *jstat = -101; 00833 s6err("file_to_obj",*jstat,0); 00834 goto out; 00835 00836 /* 00837 * Exit file_to_obj, remember to close file if opened. 00838 * --------------------------------------------------- 00839 */ 00840 00841 out: 00842 00843 return; 00844 } 00845 00846 00847 void curve_to_file(FILE *f, 00848 struct SISLCurve *c1) 00849 /* 00850 ********************************************************************************* 00851 * 00852 * Purpose : To write a B-spline curve to file. 00853 * File format hplabs. 00854 * Naming conventions SI/HP. 00855 * 00856 * Input : to_file - File name. 00857 * c1 - Pointer to curve. 00858 * 00859 * Output : * jstat - status flag 00860 * >= 0 - OK. 00861 * < 0 - Error 00862 * 00863 * Written by : 00864 * 00865 ******************************************************************************** 00866 */ 00867 { 00868 int i,j; 00869 int linenum; 00870 00871 fprintf(f,"$ This is a B-Spline curve\n"); 00872 fprintf(f,"$ type: 0 is usual, 5 point, 6 analytic\n"); 00873 fprintf(f,"0\n"); 00874 00875 /* order */ 00876 fprintf(f,"$ order ik\n"); 00877 fprintf(f,"%d\n",c1->ik); 00878 00879 /* number of control vertices */ 00880 fprintf(f,"$ number of control vertices in\n"); 00881 fprintf(f,"%d\n",c1->in); 00882 00883 /* dimension of geometry space */ 00884 fprintf(f,"$ dimension\n"); 00885 fprintf(f,"%d\n",c1->idim); 00886 00887 /* curve open/closed */ 00888 fprintf(f,"$ curve open/closed\n"); 00889 fprintf(f,"%d\n",c1->cuopen); 00890 00891 /* nonrational, i.e. polynomial */ 00892 fprintf(f,"$ rational or not\n"); 00893 fprintf(f,"%d\n",(c1->ikind==2 || c1->ikind==4)); 00894 00895 /* knot vector */ 00896 linenum = (c1->in + c1->ik)/4; 00897 fprintf(f,"$ knot vector\n"); 00898 for (j=0; j < linenum; j++){ 00899 for (i=0; i < 4; i++) 00900 fprintf(f,"%20.16g ",c1->et[j * 4 + i]); 00901 fprintf(f,"\n"); 00902 } 00903 for (i = linenum * 4; i < (c1->in + c1->ik); i++) 00904 fprintf(f,"%20.16g ",c1->et[i]); 00905 fprintf(f,"\n"); 00906 00907 /* control vertices */ 00908 fprintf(f,"$ control vertices\n"); 00909 00910 if (c1->ikind == 1 || c1->ikind == 3) 00911 { 00912 for ( i = 0; i < c1->in; i++ ) 00913 { 00914 for ( j = 0; j < c1->idim; j++ ) fprintf(f,"%20.16g ", 00915 c1->ecoef[i*c1->idim+j]); 00916 fprintf(f,"%g\n",(double)1.0); 00917 } 00918 } 00919 else 00920 { 00921 for ( i = 0; i < c1->in; i++ ) 00922 { 00923 for ( j = 0; j < c1->idim+1; j++ ) fprintf(f,"%20.16g ", 00924 c1->rcoef[i*(c1->idim+1)+j]); 00925 fprintf(f,"\n"); 00926 } 00927 } 00928 00929 /* instance matrix */ 00930 fprintf(f,"$ instance matrix\n"); 00931 if (c1->idim == 3) 00932 { 00933 fprintf(f,"%f %f %f %f\n",1.0,0.0,0.0,0.0); 00934 fprintf(f,"%f %f %f %f\n",0.0,1.0,0.0,0.0); 00935 fprintf(f,"%f %f %f %f\n",0.0,0.0,1.0,0.0); 00936 fprintf(f,"%f %f %f %f\n",0.0,0.0,0.0,1.0); 00937 } 00938 else if (c1->idim == 2) 00939 { 00940 fprintf(f,"%f %f %f\n",1.0,0.0,0.0); 00941 fprintf(f,"%f %f %f\n",0.0,1.0,0.0); 00942 fprintf(f,"%f %f %f\n",0.0,0.0,1.0); 00943 } 00944 else 00945 { 00946 fprintf(f,"%f %f\n",1.0,0.0); 00947 fprintf(f,"%f %f\n",0.0,1.0); 00948 } 00949 00950 fprintf(f,"$ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); 00951 00952 return; 00953 } 00954 00955 00956 void surface_to_file(FILE *f, 00957 struct SISLSurf *surf) 00958 /* 00959 ********************************************************************************* 00960 * 00961 * Purpose : To write a B-spline surface to file. 00962 * File format hplabs. 00963 * Naming conventions SI/HP. 00964 * 00965 * Input : to_file - File name. 00966 * surf - Pointer to surface. 00967 * 00968 * Output : * jstat - status flag 00969 * >= 0 - OK. 00970 * < 0 - Error 00971 * 00972 * Written by : 00973 * 00974 ******************************************************************************** 00975 */ 00976 { 00977 int i,j; 00978 int linenum; 00979 00980 fprintf(f,"$ This is a B-Spline surface\n"); 00981 fprintf(f,"$ type: 0 is usual, 5 point, 6 analytic\n"); 00982 fprintf(f,"0\n"); 00983 00984 /* orders */ 00985 fprintf(f,"$ orders in the two directions ik1, ik2\n"); 00986 fprintf(f,"%d %d\n",surf->ik1,surf->ik2); 00987 00988 /* numbers of control vertices */ 00989 fprintf(f,"$ numbers of control vertices in the two directions in1, in2\n"); 00990 fprintf(f,"%d %d\n",surf->in1,surf->in2); 00991 00992 /* dimension of geometry space */ 00993 fprintf(f,"$ dimension\n"); 00994 fprintf(f,"%d\n",surf->idim); 00995 00996 /* surface open/closed */ 00997 fprintf(f,"$ surface open/closed\n"); 00998 fprintf(f,"%d %d\n",surf->cuopen_1,surf->cuopen_2); 00999 01000 /* nonrational, i.e. polynomial in the two directions */ 01001 fprintf(f,"$ rational or not\n"); 01002 fprintf(f,"%d\n",(surf->ikind==2 || surf->ikind==4)); 01003 01004 /* knot vectors */ 01005 linenum = (surf->in1 + surf->ik1)/4; 01006 fprintf(f,"$ knot vector in the first direction et1[]\n"); 01007 for (j=0; j < linenum; j++){ 01008 for (i=0; i < 4; i++) 01009 fprintf(f,"%20.16g ",surf->et1[j * 4 + i]); 01010 fprintf(f,"\n"); 01011 } 01012 for (i = linenum * 4; i < (surf->in1 + surf->ik1); i++) 01013 fprintf(f,"%20.16g ",surf->et1[i]); 01014 fprintf(f,"\n"); 01015 01016 linenum = (surf->in2 + surf->ik2)/4; 01017 fprintf(f,"$ knot vector in the second direction et2[]\n"); 01018 for (j=0; j < linenum; j++){ 01019 for (i=0; i < 4; i++) 01020 fprintf(f,"%20.16g ",surf->et2[j * 4 + i]); 01021 fprintf(f,"\n"); 01022 } 01023 for (i = linenum * 4; i < (surf->in2 + surf->ik2); i++) 01024 fprintf(f,"%20.16g ",surf->et2[i]); 01025 fprintf(f,"\n"); 01026 01027 /* control vertices */ 01028 fprintf(f,"$ control vertices in the two directions \n"); 01029 01030 if (surf->ikind == 1 || surf->ikind == 3) 01031 { 01032 for ( i = 0; i < surf->in1 * surf->in2; i++ ) 01033 { 01034 for ( j = 0; j < surf->idim; j++ ) 01035 fprintf(f,"%20.16g ",surf->ecoef[i*surf->idim+j]); 01036 fprintf(f,"%g\n",(double)1.0); 01037 } 01038 } 01039 else 01040 { 01041 for ( i = 0; i < surf->in1 * surf->in2; i++ ) 01042 { 01043 for ( j = 0; j < surf->idim+1; j++ ) 01044 fprintf(f,"%20.16g ",surf->rcoef[i*(surf->idim+1)+j]); 01045 fprintf(f,"\n"); 01046 } 01047 } 01048 01049 /* instance matrix */ 01050 fprintf(f,"$ instance matrix\n"); 01051 if (surf->idim == 3) 01052 { 01053 fprintf(f,"%f %f %f %f\n",1.0,0.0,0.0,0.0); 01054 fprintf(f,"%f %f %f %f\n",0.0,1.0,0.0,0.0); 01055 fprintf(f,"%f %f %f %f\n",0.0,0.0,1.0,0.0); 01056 fprintf(f,"%f %f %f %f\n",0.0,0.0,0.0,1.0); 01057 } 01058 else if (surf->idim == 2) 01059 { 01060 fprintf(f,"%f %f %f\n",1.0,0.0,0.0); 01061 fprintf(f,"%f %f %f\n",0.0,1.0,0.0); 01062 fprintf(f,"%f %f %f\n",0.0,0.0,1.0); 01063 } 01064 else 01065 { 01066 fprintf(f,"%f %f\n",1.0,0.0); 01067 fprintf(f,"%f %f\n",0.0,1.0); 01068 } 01069 fprintf(f,"$ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); 01070 01071 return; 01072 } 01073 01074 01075 01076 int get_next_surface(FILE *fp, 01077 SISLSurf **qc) 01078 { 01079 SISLSurf *qs=NULL; /* Pointer to struct SISLSurf */ 01080 SISLObject *qo=NULL; /* Pointer to struct SISLObject */ 01081 // SISLObject *qo=NULL; /* Pointer to struct SISLObject */ 01082 char string[80]; /* character to read $ which identifies a comment */ 01083 int value; /* type of B-Spline and numbers */ 01084 int kcopy=1; /* Flag */ 01085 int kcuopen1; /* Open/closed flag for surf */ 01086 int kcuopen2; /* Open/closed flag for surf */ 01087 int kdim; /* dimension of target space */ 01088 int kdim1; /* dimension + 1 */ 01089 int kk1; /* Order of curve or in 1st parameter direction of surface */ 01090 int kk2; /* Order in 2nd parameter direction of surface */ 01091 int kn1; /* # of vertices of curve or in 1st parameter direction of surf */ 01092 int kn2; /* # of vertices in 2nd parameter direction of surface */ 01093 double *st1=NULL; /* Knot vector of curve or in 1st parameter direction of surface */ 01094 double *st2=NULL; /* Knot vector in 2nd parameter direction of surface */ 01095 double *scoef=NULL; /* Vertices of curve or surface */ 01096 double dummy; /* trashbin for fourth value in vertices */ 01097 double help[4]; /* Help array in computing transformated vertic. */ 01098 double matrix[16]; /* instance matrix */ 01099 double *sptr=NULL; /* Dummy pointer */ 01100 int ki, kj; /* Counters */ 01101 int *ind_hex=0; 01102 int hex=FALSE; 01103 int *ind_2 = (int*)&dummy; 01104 std::vector<double> seg_u; 01105 std::vector<double> seg_v; 01106 std::vector<int> prio_u; 01107 std::vector<int> prio_v; 01108 std::vector<double> pbox; 01109 int stat = 0; 01110 01111 01112 /* 01113 * Read data from file. 01114 * -------------------- 01115 */ 01116 read_non_comment(fp,string); 01117 if (string[0] == EOF) goto err001; 01118 sscanf(string,"%d",&value); 01119 01120 read_non_comment(fp,string); 01121 sscanf(string,"%d",&kk1); 01122 fscanf(fp,"%d",&kk2); 01123 01124 read_non_comment(fp,string); 01125 sscanf(string,"%d",&kn1); 01126 fscanf(fp,"%d",&kn2); 01127 01128 01129 /* 01130 * dimension 01131 * --------- 01132 */ 01133 01134 read_non_comment(fp,string); 01135 sscanf(string,"%d",&kdim); 01136 kdim1 = kdim; 01137 01138 /* 01139 * surface open/closed 01140 * ------------------ 01141 */ 01142 01143 read_non_comment(fp,string); 01144 sscanf(string,"%d",&kcuopen1); 01145 fscanf(fp,"%d",&kcuopen2); 01146 01147 /* 01148 * rational B-Spline or not 01149 * ------------------------ 01150 */ 01151 01152 read_non_comment(fp,string); 01153 sscanf(string,"%d",&value); 01154 /* if (value != 0) goto err002; 01155 01156 fscanf(fp,"%d",&value); */ 01157 if (value) kdim1++; 01158 01159 /* 01160 * Allocate space for first knot vector 01161 * ------------------------------------ 01162 */ 01163 01164 // st1 = newarray(kk1+kn1,DOUBLE); 01165 st1 = new double[kk1+kn1]; 01166 if (!st1) goto err101; 01167 01168 /* 01169 * Read in first knot vector. 01170 * -------------------------- 01171 */ 01172 01173 read_non_comment(fp,string); 01174 if (hex) 01175 { 01176 ind_hex = (int *)st1; 01177 sscanf(string,"%x",ind_hex); 01178 fscanf(fp,"%x",ind_hex+1); 01179 for (ind_hex=(int*)(st1+1),ki=1;ki < kk1+kn1;ki++,ind_hex+=2) 01180 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 01181 } 01182 else 01183 { 01184 01185 sscanf(string,"%lf",st1); 01186 for (sptr = st1+1,ki = 1; ki < kn1+kk1; sptr++,ki++) 01187 fscanf(fp,"%lf",sptr); 01188 } 01189 /* 01190 * Allocate space for second knot vector 01191 * ------------------------------------ 01192 */ 01193 01194 // st2 = newarray(kk2+kn2,DOUBLE); 01195 st2 = new double[kk2+kn2]; 01196 if (!st2) goto err101; 01197 01198 /* 01199 * Read in second knot vector. 01200 * -------------------------- 01201 */ 01202 01203 read_non_comment(fp,string); 01204 if (hex) 01205 { 01206 ind_hex = (int *)st2; 01207 sscanf(string,"%x",ind_hex); 01208 fscanf(fp,"%x",ind_hex+1); 01209 for (ind_hex=(int*)(st2+1),ki=1;ki < kk2+kn2;ki++,ind_hex+=2) 01210 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 01211 } 01212 else 01213 { 01214 01215 sscanf(string,"%lf",st2); 01216 for (sptr = st2+1,ki = 1; ki < kn2+kk2; sptr++,ki++) 01217 fscanf(fp,"%lf",sptr); 01218 } 01219 01220 /* 01221 * Allocate space for control vertices 01222 * ----------------------------------- 01223 */ 01224 01225 // scoef = newarray(kn1*kn2*kdim1,DOUBLE); 01226 scoef = new double[kn1*kn2*kdim1]; 01227 if (!scoef) goto err101; 01228 01229 /* 01230 * Read in control vertices. 01231 * ------------------------- 01232 */ 01233 01234 read_non_comment(fp,string); 01235 if (hex) 01236 { 01237 ind_hex = (int *)scoef; 01238 sscanf(string,"%x",ind_hex); 01239 fscanf(fp,"%x",ind_hex+1); 01240 if (kdim > 1) 01241 { 01242 ind_hex +=2; 01243 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 01244 if (kdim > 2) 01245 { 01246 ind_hex +=2; 01247 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 01248 } 01249 } 01250 fscanf(fp,"%x %x",ind_2,ind_2+1); 01251 if (value) 01252 { 01253 ind_hex +=2; 01254 scoef[kdim] = dummy; 01255 } 01256 for (ki = kdim1; ki < kn1*kn2*kdim1; ki += kdim1) 01257 { 01258 ind_hex +=2; 01259 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 01260 if (kdim > 1) 01261 { 01262 ind_hex +=2; 01263 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 01264 if (kdim > 2) 01265 { 01266 ind_hex +=2; 01267 fscanf(fp,"%x %x",ind_hex,ind_hex+1); 01268 } 01269 } 01270 fscanf(fp,"%x %x",ind_2,ind_2+1); 01271 if (value) 01272 { 01273 ind_hex +=2; 01274 scoef[ki+kdim] = dummy; 01275 } 01276 } 01277 01278 } 01279 else 01280 { 01281 sscanf(string,"%lf",scoef); 01282 if (kdim > 1) fscanf(fp,"%lf",&scoef[1]); 01283 if (kdim > 2) fscanf(fp,"%lf",&scoef[2]); 01284 fscanf(fp,"%lf",&dummy); 01285 if (value) scoef[kdim] = dummy; 01286 for (ki = kdim1; ki < kn1*kn2*kdim1; ki += kdim1) 01287 { 01288 fscanf(fp,"%lf",&scoef[ki]); 01289 if (kdim > 1) fscanf(fp,"%lf",&scoef[ki+1]); 01290 if (kdim > 2) fscanf(fp,"%lf",&scoef[ki+2]); 01291 fscanf(fp,"%lf",&dummy); 01292 if (value) scoef[ki+kdim] = dummy; 01293 } 01294 01295 } 01296 /* 01297 * transformation data 01298 * ------------------- 01299 */ 01300 01301 read_non_comment(fp,string); 01302 sscanf(string,"%lf",matrix); 01303 for (ki = 1; ki < (kdim+1)*(kdim+1); ki ++) 01304 fscanf(fp,"%lf",&matrix[ki]); 01305 01306 /* 01307 * transform vertices with instance matrix 01308 * --------------------------------------- 01309 */ 01310 01311 01312 /* 01313 * test whether matrix is unit matrix 01314 * ---------------------------------- 01315 */ 01316 01317 if (kdim == 1 && 01318 matrix[0] == (double)1.0 && 01319 matrix[1] == (double)0.0 && 01320 matrix[2] == (double)0.0 && 01321 matrix[3] == (double)1.0 ) 01322 { 01323 } 01324 else if (kdim == 2 && 01325 matrix[0] == (double)1.0 && 01326 matrix[1] == (double)0.0 && 01327 matrix[2] == (double)0.0 && 01328 matrix[3] == (double)0.0 && 01329 matrix[4] == (double)1.0 && 01330 matrix[5] == (double)0.0 && 01331 matrix[6] == (double)0.0 && 01332 matrix[7] == (double)0.0 && 01333 matrix[8] == (double)1.0) 01334 { 01335 } 01336 else if (kdim == 3 && 01337 matrix[0] == (double)1.0 && 01338 matrix[1] == (double)0.0 && 01339 matrix[2] == (double)0.0 && 01340 matrix[3] == (double)0.0 && 01341 matrix[4] == (double)0.0 && 01342 matrix[5] == (double)1.0 && 01343 matrix[6] == (double)0.0 && 01344 matrix[7] == (double)0.0 && 01345 matrix[8] == (double)0.0 && 01346 matrix[9] == (double)0.0 && 01347 matrix[10] == (double)1.0 && 01348 matrix[11] == (double)0.0 && 01349 matrix[12] == (double)0.0 && 01350 matrix[13] == (double)0.0 && 01351 matrix[14] == (double)0.0 && 01352 matrix[15] == (double)1.0) 01353 { 01354 } 01355 else if (1) 01356 { 01357 } 01358 01359 else 01360 { 01361 if (kdim > 3 || kdim < 1) goto err005; 01362 if (!value) 01363 { 01364 for (ki = 0; ki < kn2*kn1*kdim; ki += kdim) 01365 { 01366 kdim1 = kdim + 1; 01367 for (kj = 0; kj < kdim1; kj++) 01368 help[kj] = s6scpr(&scoef[ki], 01369 &matrix[kj*kdim1],kdim) 01370 + matrix[kj*kdim1 + kdim]; 01371 01372 if (help[kdim] == 0.0) goto err004; 01373 01374 for (kj = 0; kj < kdim; kj++) 01375 scoef[ki + kj] = help[kj]/help[kdim]; 01376 } 01377 } 01378 else goto err002; 01379 } 01380 01381 // Read segmentation and parameter box for surface 01382 01383 // stat = readSegments(fp,seg_u,seg_v,prio_u,prio_v,pbox); 01384 // if (stat < 0) 01385 // goto error; 01386 01387 /* 01388 * Create an instance of SISLSurf. 01389 * --------------------------- 01390 */ 01391 01392 qs = newSurf(kn1,kn2,kk1,kk2,st1,st2,scoef,(value)?2:1,kdim,kcopy); 01393 if (!qs) goto err101; 01394 else 01395 { 01396 // // Set segmentation values and parameter box 01397 01398 // if (pbox.size() == 4) 01399 // SI_setparbox(qs, pbox.begin()); 01400 01401 // if (seg_u.size() > 0 || seg_v.size() > 0) 01402 // { 01403 // stat = SI_set_seg(qs, seg_u.size(), seg_u.begin(), 01404 // prio_u.begin(),seg_v.size(), 01405 // seg_v.begin(), prio_v.begin()); 01406 // if (stat < 0) 01407 // goto error; 01408 01409 // } 01410 /* 01411 * Create an instace of Object and connect surface to the Object. 01412 * -------------------------------------------------------------- 01413 */ 01414 01415 qs->cuopen_1 = kcuopen1; 01416 qs->cuopen_2 = kcuopen2; 01417 01418 qo = newObject(SISLSURFACE); 01419 if (!qo) goto err101; 01420 else 01421 { 01422 qo->s1 = qs; 01423 *qc = qs; // = qo; 01424 } 01425 } 01426 01427 /* 01428 * Remember to free allocated space. 01429 * --------------------------------- 01430 */ 01431 01432 stat = 0; 01433 goto out; 01434 01435 err001: stat = -1; 01436 s6err("file_to_obj",stat,__LINE__); 01437 goto out; 01438 01439 /* 01440 * Error, object in file was of type rational. 01441 * ------------------------------------------- 01442 */ 01443 01444 err002: stat = -2; 01445 s6err("file_to_obj",stat,__LINE__); 01446 goto out; 01447 01448 // /* 01449 // * Error, object in file was of unknown type. 01450 // * ------------------------------------------ 01451 // */ 01452 01453 // err003: stat = -3; 01454 // s6err("file_to_obj",stat,__LINE__); 01455 // goto out; 01456 01457 /* 01458 * Error, Homeogenous division by zero. 01459 * ------------------------------------------ 01460 */ 01461 01462 err004: stat = -4; 01463 s6err("file_to_obj",stat,__LINE__); 01464 goto out; 01465 01466 /* 01467 * Error, Cannot treat this dimension. 01468 * ------------------------------------------ 01469 */ 01470 01471 err005: stat = -5; 01472 s6err("file_to_obj",stat,__LINE__); 01473 goto out; 01474 /* 01475 * Error in memory allocation. 01476 * --------------------------- 01477 */ 01478 01479 err101: stat = -101; 01480 s6err("file_to_obj",stat,__LINE__); 01481 goto out; 01482 01483 /* 01484 * Exit file_to_obj, remember to close file if opened. 01485 * --------------------------------------------------- 01486 */ 01487 01488 out: 01489 if (st1) delete [] st1; 01490 if (st2) delete [] st2; 01491 if (scoef) delete [] scoef; 01492 01493 return stat; 01494 } 01495 01496 01497 // Read sisl sfs from file. 01498 // If returned value is negative something went wrong. 01499 int get_sisl_surfaces(FILE* fp, 01500 std::vector<boost::shared_ptr<SISLSurf> >& sisl_sfs) 01501 { 01502 // read_non_comment(fp,string); 01503 int kstat = 0; 01504 while (kstat == 0) 01505 { 01506 SISLSurf* sisl_sf = NULL; 01507 kstat = get_next_surface(fp, &sisl_sf); 01508 if (kstat < 0) 01509 { 01510 return kstat; 01511 } 01512 else 01513 sisl_sfs.push_back(boost::shared_ptr<SISLSurf>(sisl_sf)); 01514 01515 01516 char string[80]; /* character to read $ which identifies a comment */ 01517 read_non_comment(fp,string); 01518 if (string[0] == EOF) 01519 break; // Hmm, but what about next surface ... Will we not 01520 // miss the first comment? 01521 } 01522 01523 return 0; 01524 }
Generated on Tue Sep 21 15:44:24 2010 for GoTools Core by  doxygen 1.6.3