41 int i, j, mid = 0, unsat, nsat;
42 int sat = valence - 1;
52 cout <<
"Adding polygon: " << n <<
":" << endl;
57 for ( comp2 =
model->
comp, comp = NULL; comp2; comp2 = comp2->
next )
58 if ( !comp2->
link[sat] ) comp = comp2;
61 for ( i=mid=0; i<n; i++ ) {
68 cout <<
"Adding vertex: " <<
id << endl;
72 link =
link_add(&link, comp2, comp, 1, 1);
75 cout <<
"Adding link: " << comp2->
id <<
" - " << comp->
id << endl;
82 cout <<
"Adding link: " <<
model->
comp->
id <<
" - " << comp->
id << endl;
89 for ( i = 1; i<n && comp; i++ ) {
90 for ( j=0; comp->link[j] && comp->link[j]->sel > sat; j++ ) ;
104 for ( mid=0, comp2 =
model->
comp; comp2; comp2 = comp2->
next ) {
106 if ( mid < i ) mid = i;
110 for ( j=0; comp2->
link[j]; j++ ) ;
113 cerr <<
"Error: " << comp2->
id <<
" does not have any links!" << endl;
117 cout <<
"Trace:\t\t" << comp2->
id;
118 for ( unsat = 0, i = 1; i<n && unsat == 0 && comp2; i++ ) {
120 for ( j=0; comp2->
link[j]; j++ )
121 if ( comp2->
link[j] != comp3 && comp2->
link[j]->
sel < valence )
break;
124 cerr << endl <<
"Error: No link with the required properties" << endl;
125 cerr <<
"Component: " << comp2->
id << endl;
126 for ( j=0; comp2->
link[j]; j++ )
127 cerr <<
"Link: " << comp2->
link[j]->
id <<
" Flag: "
128 << comp2->
flag[j] <<
" Select: " << comp2->
link[j]->
sel << endl;
133 comp2 = comp2->
link[j];
135 if ( !comp2->
link[sat] ) unsat = 1;
137 cout <<
tab << comp2->
id;
144 cout <<
"Backtrace:";
145 for ( j=i-1, i=0; j>=0; j--, i++ ) {
146 poly->
comp[i] = complist[j];
161 cout <<
"Adding vertex: " <<
id << endl;
162 poly->
comp[i] = comp3;
164 link =
link_add(&link, comp, comp3, 1, 1);
166 cout <<
"Adding link: " << comp->
id <<
" - " << comp3->
id << endl;
169 link =
link_add(&link, comp, comp2, 1, 1);
172 cout <<
"Adding link: " << comp->
id <<
" - " << comp2->
id << endl;
176 for ( nsat=0, comp =
model->
comp; comp; comp = comp->
next ) {
177 if ( comp->
sel == valence ) nsat++;
178 else if ( comp->
sel > valence ) {
180 cerr <<
"Error: Valence too large for " << comp->
id <<
": " << comp->
sel <<
" > " << valence << endl;
188 cerr <<
"Error: Polygon incomplete: " << poly->
number <<
"/" << n << endl;
190 cerr <<
"Error: Polygon not closed" << endl;
200 for ( i=0, j=1; j<seq.
length(); i++, j++ )
201 if ( seq[i] ==
'5' && seq[j] ==
'5' ) adj++;
215 for ( n=0, poly = mp->
poly; poly && n<npoly; poly = poly->next, n++ ) {
216 for ( i=0; poly->
comp[i]; i++ ) {
217 if ( i+1 < poly->
number ) comp = poly->
comp[i+1];
218 else comp = poly->
comp[0];
219 for ( j=0; poly->
comp[i]->
link[j] != comp; j++ ) ;
236 for ( i=n=0; comp->
link[i]; i++ )
if ( comp->
flag[i] == 5 ) n++;
251 for ( i=n=0; comp->
link[i]; i++ )
if ( comp->
flag[i] == 5 ) n++;
277 int vertices = 20 + 2*(npoly - 12);
281 int i, nvert = 1, nsat = 0, adj = 0, good = 1;
283 for ( i=1; nsat < nvert && i<=npoly; i++ ) {
286 cout <<
"Polygon " << i <<
":\t" << nvert << endl;
290 cout <<
"Saturation:\t" << nsat <<
"/" << nvert << endl;
294 if ( requirements%2 == 1 )
if ( nvert != vertices ) good = 0;
299 cout <<
"Model rejected:";
300 if ( nvert != vertices )
301 cout <<
"\tvertices = " << nvert << endl;
302 else if ( nsat > nvert )
303 cout <<
"\tsaturation = " << nsat <<
" > " << nvert << endl;
305 cout <<
"\tadjacent pentagons = " << adj << endl;
307 cout <<
"\tcheck = " << i << endl;
338 int j, ncomp = 0, nlink = 0, npoly = 0, err = 0;
345 cout << endl <<
"Checking the model:" << endl;
347 for ( ncomp=nlink=npoly=0, mp =
model; mp; mp = mp->
next ) {
348 for ( comp = mp->
comp; comp; comp = comp->
next, ncomp++ ) {
349 if ( comp->
sel != valence ) {
351 cerr << comp->
id <<
": select = " << comp->
sel << endl;
354 for ( j=0; comp->
link[j]; j++ ) ;
355 if ( j != valence ) {
357 cerr << comp->
id <<
": valency = " << j << endl;
361 for ( link = mp->
link; link; link = link->
next, nlink++ ) ;
362 for ( poly = mp->
poly; poly; poly = poly->
next, npoly++ )
365 cerr << npoly <<
": polygon not closed!" << endl;
370 if ( ncomp - nlink + npoly != 2 ) {
372 cerr <<
"Euler's formula incorrect: " << ncomp <<
" - " << nlink <<
" + "
373 << npoly <<
" = " << ncomp - nlink + npoly << endl;
378 cout <<
"Number of components: " << ncomp << endl;
379 cout <<
"Number of links: " << nlink << endl;
380 cout <<
"Number of polygons: " << npoly << endl;
381 cout <<
"Errors: " << err << endl << endl;
422 int d = 1, enant = 1;
426 int vertices = 20 + 2*(seq.
length() - 12);
431 cout << nm+1 <<
": " << seq << endl;
440 for ( j=0, d=1; j<nm*vertices && table[j] && d; j+=vertices )
441 for ( k=0, d=0; k<vertices; k++ )
442 if ( fabs(eigval[k] - table[j+k]) > 1e-6 ) d++;
443 if ( d )
for ( k=0; k<vertices; j++, k++ )
444 table[j] = eigval[k];
446 id +=
Bstring(j/vertices,
"%04d");
455 cout <<
id <<
tab << seq << endl;
474 if ( enantiomorph ) {
496 long nt = (long) pow(10, (4*(log(1.0L*vertices) - 3.1)));
498 cout <<
"Generating polyhedra with permutations:" << endl <<
499 "Vertices = " << vertices <<
" Table rows = " << nt << endl;
500 if ( nt < 100 ) nt = 100;
502 cerr <<
"The number of table entries is too large! (" << nt <<
")" << endl;
506 int i, np = 1, nm = 0;
507 double* table =
new double[nt*vertices];
509 for ( i=0; i<(vertices-20)/2; i++ ) seq +=
'6';
510 for ( i=0; i<nt*vertices; i++ ) table[i] = 0;
513 cout <<
"DEBUG model_poly_gen_permutations: " << i <<
": " << seq <<
": start" << endl;
519 for ( i=1, nm=0; np; i++ ) {
523 else mp->
next = new_mp;
527 cout << mp->
id <<
" " << i <<
": " << seq <<
": " << mp->
symmetry << endl;
528 if ( new_mp->
next ) {
532 cout << mp->
id <<
" " << i <<
": " << seq <<
": " << mp->
symmetry << endl;
540 for ( nm=0, mp =
model; mp; mp = mp->
next ) nm++;
542 cout <<
"Models made: " << nm <<
"/" << --i << endl << endl;
559 if ( tip < 6 ) tip = 6;
560 if ( body < 1 ) body = 1;
572 case 1: stip =
"5666665656565";
break;
573 case 2: stip =
"56666656566565";
break;
574 case 3: stip =
"56666665656565";
break;
575 case 4: stip =
"665656565665";
break;
576 case 5: stip =
"6666565656565";
break;
580 while ( stip.
length() < tip ) stip +=
"6";
582 for ( i=0; i<7; i++ ) sbase +=
"56";
600 int i, j, h, k, vertices, nm, nt;
601 int top = 1 + (5*ttop*(ttop + 1))/2;
602 int dm = (5*ttop + 1)/2;
613 for ( nm=0, nt=1, i=0; i<ttop; i++ ) {
615 for ( k=0; k<i; k++ ) stip_rpt +=
"6";
617 for ( k++; k<ttop; k++ ) stip_rpt +=
"6";
620 stip +=
Bstring(
'6', top - 1 - 5*ttop);
621 for ( k=0; k<5; k++ ) stip += stip_rpt;
622 for ( h=body; h<=body+2*dm; h++ ) {
624 if ( h ) sbody =
Bstring(
'6', body+h);
625 for ( j=0; j<ttop; j++, nt++ ) {
627 for ( k=0; k<j; k++ ) sbase_rpt +=
"6";
629 for ( k++; k<ttop; k++ ) sbase_rpt +=
"6";
631 for ( k=0; k<5; k++ ) sbase += sbase_rpt;
633 sbase +=
Bstring(
'6', top - 1 - 5*ttop);
635 seq = stip + sbody + sbase;
638 vertices = 20 + 2*(seq.
length() - 12);
640 cout << new_mp->
id <<
" " << nt <<
": " << seq <<
": " << new_mp->
symmetry << endl;
641 if ( mp ) mp->
next = new_mp;
649 cout <<
"Models made: " << nm <<
"/" << --nt << endl << endl;
667 int i, j, h, k, vertices, nm, nt;
668 int top = 1 + (5*ttop*(ttop + 1))/2;
669 int dm = (5*ttop + 6*tbase + 1)/2;
671 int base = 1 + 3*tbase*(tbase + 1);
681 for ( nm=0, nt=1, i=0; i<ttop; i++ ) {
683 for ( k=0; k<i; k++ ) stip_rpt +=
"6";
685 for ( k++; k<ttop; k++ ) stip_rpt +=
"6";
688 stip +=
Bstring(
'6', top - 1 - 5*ttop);
689 for ( k=0; k<5; k++ ) stip += stip_rpt;
690 for ( h=0; h<dm; h++ ) {
693 for ( j=0; j<tbase; j++, nt++ ) {
695 for ( k=0; k<j; k++ ) sbase_rpt +=
"6";
697 for ( k++; k<tbase; k++ ) sbase_rpt +=
"6";
699 for ( k=0; k<6; k++ ) sbase += sbase_rpt;
702 seq = stip + sbody + sbase;
705 vertices = 20 + 2*(seq.
length() - 12);
707 cout << new_mp->
id <<
" " << nt <<
": " << seq <<
": " << new_mp->
symmetry << endl;
708 if ( mp ) mp->
next = new_mp;
716 cout <<
"Models made: " << nm <<
"/" << --nt << endl << endl;
735 int top = 1 + (5*ttop*(ttop + 1))/2;
736 int body = tbody*(5*ttop + 6*tbase + 1)/2;
737 int base = 1 + 3*tbase*(tbase + 1);
746 for ( i=1; i<ttop; i++ ) stip_rpt +=
"6";
747 for ( i=1; i<tbase; i++ ) sbase_rpt +=
"6";
750 stip +=
Bstring(
'6', top - 1 - 5*ttop);
751 for ( i=0; i<5; i++ ) stip += stip_rpt;
753 for ( i=0; i<6; i++ ) sbase += sbase_rpt;
773 int top = 1 + (5*ttop*(ttop + 1))/2;
774 int body = tbody*(5*ttop + 6*tbase + 1)/2;
775 int base = 1 + 3*tbase*(tbase + 1);
784 for ( i=1; i<ttop; i++ ) stip_rpt +=
"6";
785 for ( i=1; i<tbase; i++ ) sbase_rpt +=
"6";
788 stip +=
Bstring(
'6', top - 1 - 5*ttop);
789 for ( i=0; i<5; i++ ) stip += stip_rpt;
791 for ( i=0; i<6; i++ ) sbase += sbase_rpt;
795 Bstring seq = stip + sbody + sbase;
816 int i, np = 1, npb = 1, nm = 0, max = 1000;
824 Bstring seq = stip + sbody + sbase;
825 int vertices = 20 + 2*(seq.
length() - 12);
826 double* table =
new double[nt*vertices];
827 for ( i=0; i<nt*vertices; i++ ) table[i] = 0;
830 cout <<
"Start: " << seq << endl;
838 seq = stip + sbody + sbase_one;
842 else mp->
next = new_mp;
845 cout << mp->
id <<
" " << i <<
": " << seq <<
": " << mp->
symmetry << endl;
846 if ( new_mp->
next ) {
849 cout << mp->
id <<
" " << i <<
": " << seq <<
": " << mp->
symmetry << endl;
857 for ( nm=0, mp =
model; mp; mp = mp->
next ) nm++;
859 cout <<
"Models made: " << nm <<
"/" << --nt << endl << endl;
873 for ( i=0; i<12; i++ ) pc[i] = p[i];
874 for ( i = -1; i < 2; i++ ) {
876 if ( pc[n] >= 0 && pc[n] < len ) {
877 new_mp =
move_pentagons(len, pc, n+1, valence, enantiomorph, requirements, nm);
880 else mp->
next = new_mp;
889 for ( i=j=0; i<len; i++ )
if ( i==p[j] ) {
917 int i, j, p[12], nm = 0;
919 for ( i=j=0; i<seq.
length() && j<12; i++ )
if ( seq[i] ==
'5' ) p[j++] = i;