50 for ( comp2 = comp1->
next; comp2; comp2 = comp2->
next )
if ( comp2->
sel ) {
51 v0 = (comp1->
loc + comp2->
loc)/2;
53 for ( found = 0, comp =
model->
comp; comp && !found; comp = comp->
next )
54 if ( comp != comp1 && comp != comp2 )
55 if ( v0.
scalar(comp->
loc) > d0 ) found = 1;
57 link =
link_add(&link, comp1, comp2, 0, 0);
65 cout <<
"Number of links generated: " << nlink << endl << endl;
87 if ( poly->
closed )
return nlink;
88 if ( !comp->
link[ilink] )
return nlink;
91 double a, mina =
TWOPI;
95 poly->
comp[nlink] = comp;
100 if ( nlink >=
MAXLINK )
return nlink;
103 for ( i=0, j=-1; i<
MAXLINK && comp->
link[i]; i++ ) {
116 if ( j < 0 )
return 0;
117 if ( comp->
flag[j] )
return 0;
120 compsel = comp->
link[j];
121 if ( compsel == poly->
comp[0] ) {
124 for ( i=0; i<
MAXLINK && compsel->
link[i] != comp; i++ ) ;
129 cout <<
tab << compsel->
id;
147 int i, j, m, nmod, nmods, n, nc, npm = 20, np[20], npc[20], nv[1000000];
150 memset(np, 0, npm*
sizeof(
int));
151 memset(npc, 0, npm*
sizeof(
int));
152 memset(nv, 0, 1000000*
sizeof(
int));
160 cout <<
"Generating a polygon list" << endl << endl;
163 cout <<
"Vertex normals:" << endl;
164 cout <<
"ID\tLinks\tx\ty\tz" << endl;
170 for ( comp = mp->
comp; comp; comp = comp->
next ) {
171 rloc = comp->
loc - com;
175 maxang =
TWOPI/(i - 1.0L);
178 for ( j=0; j<i; j++ ) {
180 a = vec1.
angle(vec2);
181 if ( a > 0.001 && a < maxang ) {
189 if ( comp->
vec == 0 ) comp->
vec = rloc;
192 cout << comp->
id <<
tab << i <<
tab <<
198 for ( comp = mp->
comp; comp; comp = comp->
next )
206 for ( n=0, comp = mp->
comp; comp; comp = comp->
next ) {
209 cout <<
"DEBUG model_poly_generate: " << comp->
id <<
tab << i << endl;
212 cout <<
"\tn=" << n << endl;
233 for ( comp = mp->
comp; comp; comp = comp->
next )
237 cout <<
"Polygon normals:\nID\tVert\tx\ty\tz" << endl;
238 for ( n=nc=0, mp =
model; mp; mp = mp->
next )
if ( mp->
sel ) {
239 for ( poly = mp->
poly; poly; poly = poly->
next, n++ ) {
243 if ( i+1 < poly->
number ) comp = poly->
comp[i+1];
244 else comp = poly->
comp[0];
245 if ( i+2 < poly->
number ) comp2 = poly->
comp[i+2];
246 else if ( i+1 < poly->
number ) comp2 = poly->
comp[0];
247 else comp2 = poly->
comp[1];
251 if ( poly->
comp[i]->
link[j] == comp )
256 if ( poly->
number < npm ) {
267 for ( nmod=nmods=0, mp =
model; mp; mp = mp->
next, nmod++ )
if ( mp->
sel ) {
269 for ( comp = mp->
comp; comp; comp = comp->
next ) {
272 for ( j=0; j<i; j++ )
273 if ( comp->
flag[j] > comp->
flag[i] )
277 j += m*comp->
flag[i];
285 cout <<
"Models: " << nmod <<
" (" << nmods <<
")" << endl;
286 if ( np[3] ) cout <<
"Triangles: " << np[3] <<
" (" << npc[3] <<
")" << endl;
287 if ( np[4] ) cout <<
"Tetragons: " << np[4] <<
" (" << npc[4] <<
")" << endl;
288 if ( np[5] ) cout <<
"Pentagons: " << np[5] <<
" (" << npc[5] <<
")" << endl;
289 if ( np[6] ) cout <<
"Hexagons: " << np[6] <<
" (" << npc[6] <<
")" << endl;
290 if ( np[7] ) cout <<
"Heptagons: " << np[7] <<
" (" << npc[7] <<
")" << endl;
291 if ( np[8] ) cout <<
"Octagons: " << np[8] <<
" (" << npc[8] <<
")" << endl;
292 if ( np[8] ) cout <<
"Nonagons: " << np[9] <<
" (" << npc[9] <<
")" << endl;
293 if ( np[10] ) cout <<
"Decagons: " << np[10] <<
" (" << npc[10] <<
")" << endl;
294 cout <<
"Polygons: " << n <<
" (" << nc <<
")" << endl << endl;
295 cout <<
"Vertex types:\nIndex\tCount" << endl;
296 for ( i=0; i<1000000; i++ )
if ( nv[i] > 0 ) cout << i <<
tab << nv[i] << endl;
324 for ( poly = mp->
poly; poly; poly = poly->
next ) {
326 if ( i+1 < poly->
number ) comp = poly->
comp[i+1];
327 else comp = poly->
comp[0];
334 for ( comp = mp->
comp; comp; comp = comp->
next ) {
358 if ( !comp->
link[2] )
return 0;
378 id =
id.canonical(2);
408 for ( comp = mp->
comp; comp; comp = comp->
next )
409 for ( j=0; comp->
link[j]; j++ ) comp->
flag[j] = 0;
410 for ( poly = mp->
poly; poly; poly = poly->
next ) {
411 for ( i=0; poly->
comp[i]; i++ ) {
412 if ( i+1 < poly->
number ) comp = poly->
comp[i+1];
413 else comp = poly->
comp[0];
414 for ( j=0; poly->
comp[i]->
link[j] != comp; j++ ) ;
416 for ( j=0; poly->
comp[i] != comp->
link[j]; j++ ) ;
420 for ( poly = mp->
poly; poly; poly = poly->
next ) {
421 for ( i=0; poly->
comp[i]; i++ ) {
422 if ( i+1 < poly->
number ) comp = poly->
comp[i+1];
423 else comp = poly->
comp[0];
424 if ( i+2 < poly->
number ) comp2 = poly->
comp[i+2];
425 else if ( i+1 < poly->
number ) comp2 = poly->
comp[0];
426 else comp2 = poly->
comp[1];
427 for ( j=0; poly->
comp[i]->
link[j] != comp; j++ ) ;
428 for ( k=0; comp->
link[k] == poly->
comp[i] || comp->
link[k] == comp2; k++ ) ;
434 for ( comp = mp->
comp; comp; comp = comp->
next ) {
457 double side, rad,
length(0);
478 cout <<
"Generating a polyhedron dual" << endl << endl;
482 if ( !model_new ) model_new = mp_new;
487 for ( n=0, poly = mp->
poly; poly; poly = poly->
next )
488 if ( poly->
closed && ( order < 3 || poly->number == order ) ) {
491 if ( !mp_new->
comp ) mp_new->
comp = comp;
505 for ( i=0, comp->
loc=0; i<MAXLINK && poly->comp[i]; i++ )
512 for ( i=1; poly->
comp[i]; i++ ) {
518 length += sqrt(4*rad*rad - side*side);
542 cout <<
"Analyzing a model:" << endl;
548 int nn[10], np[10], nt[10];
550 cout <<
"Polygon neighbours:\nID\tVert\tTet\tPent\tHex\tHept" << endl;
551 for ( j=0; j<10; j++ ) np[j] = nt[j] = 0;
552 for ( n=0, mp =
model; mp; mp = mp->
next ) {
553 for ( poly = mp->
poly; poly; poly = poly->
next, n++ ) {
554 for ( j=0; j<10; j++ ) nn[j] = 0;
560 if ( nn[i] < 0 ) nn[i] = 0;
561 for ( j=0; j<10; j++ ) nn[j] /= 2;
562 if ( i == 4 ) nt[nn[5]]++;
563 if ( i == 5 ) np[nn[5]]++;
564 cout << n <<
tab << i <<
tab << nn[4] <<
tab << nn[5] <<
tab << nn[6] <<
tab << nn[7] << endl;
600 double d, da, ds, dat(0), dst(0);
605 cout <<
"\nLink lengths:\nID\tAvg\tStd" << endl;
606 for ( n=0, mp =
model; mp; mp = mp->
next )
if ( mp->
sel ) {
608 for ( nlink=0, link = mp->
link; link; link = link->
next, n++, nlink++ ) {
618 ds = sqrt(ds/nlink - da*da);
621 cout << mp->
id <<
tab << da <<
tab << ds << endl;
626 dst = dst/n - dat*dat;
627 if ( dst > 0 ) dst = sqrt(dst);
632 cout << endl <<
"Overall link length: " << dat <<
" (" << dst <<
")" << endl << endl;
648 int i, n, nc, na[10], mna;
649 double a, a2, pavg, pstd, avg[10], std[10], mavg, mstd, aavg(0), astd(0);
657 for ( i=0; i<10; i++ ) {
663 cout << endl <<
"Angles:\nID\tVert\tAvg\tStd" << endl;
664 for ( n=0, mp =
model; mp; mp = mp->
next )
if ( mp->
sel ) {
665 for ( comp = mp->
comp; comp; comp = comp->
next ) comp->
fom = 0;
668 for ( poly = mp->
poly; poly; poly = poly->
next, n++ ) {
669 for ( i=0, pavg=pstd=0; i<
MAXLINK && poly->
comp[i]; i++ ) {
670 if ( i+1 < poly->
number ) comp = poly->
comp[i+1];
671 else comp = poly->
comp[0];
672 if ( i+2 < poly->
number ) comp2 = poly->
comp[i+2];
673 else if ( i+1 < poly->
number ) comp2 = poly->
comp[0];
674 else comp2 = poly->
comp[1];
676 v2 = comp2->
loc - comp->
loc;
692 pstd = pstd/poly->
number - pavg*pavg;
693 if ( pstd > 0 ) pstd = sqrt(pstd);
701 mstd = mstd/mna - mavg*mavg;
702 if ( mstd > 0 ) mstd = sqrt(mstd);
705 for ( nc=0, comp = mp->
comp; comp; comp = comp->
next, nc++ ) comp->
fom = sqrt(comp->
fom/3);
712 cout << endl <<
"Overall polygon angle average:\nOrder\tNumber\tAvg\tStd" << endl;
713 for ( i=n=0, pavg=pstd=0; i<10; i++ )
if ( na[i] ) {
719 std[i] = std[i]/na[i] - avg[i]*avg[i];
720 if ( std[i] > 0 ) std[i] = sqrt(std[i]);
724 cout << i <<
tab << na[i] <<
tab << avg[i]*180.0/
M_PI <<
tab << std[i]*180.0/
M_PI << endl;
727 if ( pstd ) pstd = sqrt(pstd/n - pavg*pavg);
729 cout <<
"All\t" << n <<
tab << pavg*180.0/
M_PI <<
tab << pstd*180.0/
M_PI << endl << endl;
753 double d, davg, mavg, ds, dc, dr, dr_all(0);
754 double dstd, mstd, dstd_all(0), A, Ap(0), Vp(0);
762 cout <<
"Polygon regularity:" << endl;
764 cout <<
"Model\tDist\tStd" << endl;
766 cout <<
"ID\tVert\tDist\tStd\tRdist\tSpar\tRad" << endl;
767 for ( n=0, mp =
model; mp; mp = mp->
next ) {
770 for ( poly = mp->
poly; poly; poly = poly->
next, n++ ) {
777 dcen += poly->
comp[i]->
loc - com;
784 ds /= i + poly->
closed - 1;
785 A = i*(ds*ds/4)*sqrt((1+cos(
TWOPI/i))/(1-cos(
TWOPI/i)));
797 dstd = dstd/i - davg*davg;
799 dr = davg*2*sin(
M_PI/i);
806 cout << n <<
tab << i <<
tab << davg <<
tab << dstd <<
tab << dr <<
tab << ds <<
tab << dc << endl;
808 if ( mn ) mavg /= mn;
809 if ( mstd ) mstd = sqrt(mstd/mn - mavg*mavg);
811 cout << mp->
id <<
tab << mavg <<
tab << mstd << endl;
814 dstd_all = sqrt(dstd_all/n);
816 cout <<
"Regularity deviation: " << dstd_all <<
" A (" << n <<
")" << endl;
817 cout <<
"Overall spar length: " << dr_all <<
" A" << endl;
818 cout <<
"Polyhedral volume: " << Vp <<
" A3" << endl << endl;
838 double offset, d, dstd, dstd_all(0);
845 cout <<
"Polygon planarity:\nID\tVert\tStd" << endl;
847 for ( n=0, mp =
model; mp; mp = mp->
next ) {
848 for ( poly = mp->
poly; poly; poly = poly->
next, n++ ) {
849 for ( i=0; i<3; i++ ) b[i] = 0;
857 for ( i=0; i<3; i++ ) {
858 for ( j=0; j<=i; j++ )
859 a[j][i] += loc[i]*loc[j];
864 for ( i=1; i<3; i++ )
865 for ( j=0; j<i; j++ )
868 if ( a[0][0] == 0 ) {
870 }
else if ( a[1][1] == 0 ) {
872 }
else if ( a[2][2] == 0 ) {
878 offset = polycen.
scalar(normal);
887 cout << n <<
tab << m <<
tab << dstd << endl;
890 dstd_all = sqrt(dstd_all/n);
891 cout <<
"Planarity deviation: " << dstd_all <<
" A (" << n <<
")" << endl << endl;
917 int i, j, m, n, nmod, ncomp;
919 double El, Ea, Er, Ep;
920 double Elt(0), Eat(0), Ert(0), Ept(0);
932 cout <<
"Model ID\t#vert\tElink \tEangle \tEpolyreg\tEpolyplan" << endl;
933 for ( nmod = 0, mp =
model; mp; mp = mp->
next )
if ( mp->
sel ) {
934 El = Ea = Er = Ep = 0;
935 for ( ncomp=0, comp = mp->
comp; comp; comp = comp->
next ) ncomp++;
936 for ( n=0, link = mp->
link; link; link = link->
next ) {
941 if ( El ) El = sqrt(El/n);
942 for ( n=0, poly = mp->
poly; poly; poly = poly->
next ) {
944 if ( i+1 < poly->
number ) comp = poly->
comp[i+1];
945 else comp = poly->
comp[0];
946 if ( i+2 < poly->
number ) comp2 = poly->
comp[i+2];
947 else if ( i+1 < poly->
number ) comp2 = poly->
comp[0];
948 else comp2 = poly->
comp[1];
950 v2 = comp2->
loc - comp->
loc;
951 if ( angle_ref > 0 ) d = angle_ref - v1.
angle(v2);
957 if ( Ea ) Ea = sqrt(Ea/n);
958 for ( n=0, poly = mp->
poly; poly; poly = poly->
next ) {
967 ds /= i + poly->
closed - 1;
968 dr = ds/(2*sin(
M_PI/i));
975 if ( Er ) Er = sqrt(Er/n);
976 for ( n=0, poly = mp->
poly; poly; poly = poly->
next ) {
977 for ( i=0; i<3; i++ ) b[i] = 0;
984 for ( i=0; i<3; i++ ) {
985 for ( j=0; j<=i; j++ )
986 a[j][i] += loc[i]*loc[j];
991 for ( i=1; i<3; i++ )
992 for ( j=0; j<i; j++ )
995 if ( a[0][0] == 0 ) {
997 }
else if ( a[1][1] == 0 ) {
999 }
else if ( a[2][2] == 0 ) {
1005 offset = polycen.
scalar(normal);
1013 if ( Ep ) Ep = sqrt(Ep/n);
1015 cout << mp->
id <<
tab << ncomp <<
tab << El <<
tab << Ea <<
tab << Er <<
tab << Ep << endl;
1031 cout <<
"Average \t \t" << Elt <<
tab << Eat <<
tab << Ert <<
tab << Ept << endl << endl;
1045 int i, n(0), n3, nn;
1052 cout <<
"Pentagon adjacency:\nModel\tNp\tN3\tNN" << endl;
1055 for ( comp = mp->
comp; comp; comp = comp->
next ) comp->
sel = 0;
1056 for ( poly = mp->
poly; poly; poly = poly->
next )
if ( poly->
number == 5 ) {
1060 for ( nn=0, link = mp->
link; link; link = link->
next )
1062 for ( n=n3=0, comp = mp->
comp; comp; comp = comp->
next ) {
1063 if ( comp->
sel > 2 ) {
1066 }
else if ( comp->
sel == 2 ) n++;
1071 cout << mp->
id <<
tab << n <<
tab << n3 <<
tab << nn << endl;
1098 if ( !
model )
return sym_label;
1102 long i, j, n, ns(0), npf, order;
1120 cout <<
"Link\tOrder\tSym\tR" << endl;
1121 for ( n=1, link =
model->
link; link; link = link->
next, n++ ) {
1125 if ( R < threshold ) {
1127 cout << n <<
"\t1\t1\t" << R << endl;
1135 if ( R < threshold ) {
1137 cout << n <<
"\t1\t1\t" << R << endl;
1145 for ( n=1, link =
model->
link; link; link = link->
next, n++ ) {
1149 if ( R < threshold ) {
1151 cout << n <<
"\t2\t2\t" << R << endl;
1160 cout <<
"Vertex\tOrder\tSym\tR" << endl;
1161 for ( n=1, comp =
model->
comp; comp; comp = comp->
next, n++ ) {
1165 cerr <<
"No links for component " << comp->
id << endl;
1171 for ( j=0; j<npf; j++ ) {
1175 if ( R < threshold ) {
1177 cout << n <<
tab << i <<
tab << pf[j] <<
tab << R << endl;
1178 if ( order < pf[j] ) order = pf[j];
1181 if ( npf && ( pf[0] != i ) ) {
1185 if ( R < threshold ) {
1187 cout << n <<
tab << i <<
tab << i <<
tab << R << endl;
1194 op[ns].
order = order;
1202 cout <<
"Polygon\tOrder\tSym\tR" << endl;
1203 for ( n=1, poly =
model->
poly; poly; poly = poly->
next, n++ ) {
1205 for ( i=0; poly->
comp[i]; i++ )
1206 polycen += poly->
comp[i]->
loc;
1212 for ( j=0; j<npf; j++ ) {
1216 if ( R < threshold ) {
1218 cout << n <<
tab << i <<
tab << pf[j] <<
tab << R << endl;
1219 if ( order < pf[j] ) order = pf[j];
1226 if ( R < threshold ) {
1228 cout << n <<
tab << i <<
tab << i <<
tab << R << endl;
1235 op[ns].
order = order;
1244 for ( i=0; i<ns; i++ ) op[i].axis.normalize();
1246 double a, maxang =
M_PI/18.0;
1247 int na(0), nord[
NSMAX];
1248 memset(nord, 0,
NSMAX*
sizeof(
int));
1251 for ( i=1; i<ns; i++ ) {
1252 for ( j=0; j<i; j++ ) {
1253 if ( op[i].order == op[j].order ) {
1255 if ( a < maxang ) op[i].
order = 0;
1256 else if ( fabs(
M_PI - a) < maxang ) op[i].
order = 0;
1261 for ( i=0; i<ns; i++ )
if ( op[i].order ) nord[op[i].
order]++;
1264 cout <<
"Order\tx\ty\tz" << endl;
1265 for ( i=0; i<ns; i++ )
if ( op[i].order )
1266 cout << op[i].order <<
tab << op[i].axis[0] <<
tab << op[i].axis[1] <<
tab << op[i].axis[2] << endl;
1271 cout <<
"Order\tAxes" << endl;
1272 for ( i=1; i<
NSMAX; i++ )
1273 if ( nord[i] ) cout << i <<
tab << nord[i] << endl;
1277 for ( i=1; i<
NSMAX; i++ )
1278 if ( nord[i] ) na += nord[i];
1282 if ( nord[5] > 3 && nord[3] > 5 && nord[2] > 7 ) {
1284 if ( nord[1] ) sym_label =
"Ih";
1285 for ( i=0; i<ns && op[i].order != 2; i++ ) ;
1286 if ( op[i].order == 2 ) {
1288 for ( j=0; j<ns; j++ )
if ( op[j].order == 5 )
1289 if ( op[i].axis.angle(op[j].axis) <
M_PI/5.0 )
1290 vecx = vecz.
cross(op[j].axis);
1292 }
else if ( nord[4] > 1 && nord[3] > 2 && nord[2] > 3 ) {
1294 if ( nord[1] ) sym_label =
"Oh";
1295 for ( i=0; i<ns && op[i].order != 4; i++ ) ;
1296 if ( op[i].order == 4 ) {
1298 for ( j=0; j<ns; j++ )
if ( op[j].order == 4 )
1299 if ( fabs(
M_PI_2 - op[i].axis.angle(op[j].axis)) < maxang )
1302 }
else if ( nord[3] > 2 && nord[2] > 1 ) {
1304 for ( i=0; i<ns && op[i].order != 2; i++ ) ;
1305 if ( op[i].order == 2 ) {
1307 for ( j=0; j<ns; j++ )
if ( op[j].order == 2 )
1308 if ( fabs(
M_PI_2 - op[i].axis.angle(op[j].axis)) < maxang )
1312 for ( j=0; j<ns; j++ )
if ( op[j].order == 1 )
1313 if ( fabs(
M_PI_2 - vecz.angle(op[j].axis)) < maxang )
1315 for ( j=0; j<ns; j++ )
if ( op[j].order == 1 ) {
1316 a = fabs(vecz.angle(op[j].axis));
1317 if ( a < maxang || fabs(
M_PI - a) < maxang )
1321 }
else if ( nord[2] > 1 ) {
1322 for ( order=0, i=2; i<
NSMAX; i++ )
if ( nord[i] ) order = i;
1323 sym_label =
Bstring(order,
"D%d");
1325 if ( order == 2 && nord[1] ) {
1326 for ( j=0; j<ns && op[j].order != 1; j++ ) ;
1327 for ( i=0; i<ns; i++ )
if ( op[i].order == 2 )
1328 if ( fabs(op[i].axis.angle(op[j].axis)) < maxang ||
1329 fabs(
M_PI_2 - op[i].axis.angle(op[j].axis)) < maxang )
1332 for ( i=0; i<ns && op[i].order != order; i++ ) ;
1334 if ( op[i].order == order ) {
1336 for ( j=0; j<ns; j++ )
if ( op[j].order == 2 )
1337 if ( fabs(
M_PI_2 - op[i].axis.angle(op[j].axis)) < maxang )
1341 for ( j=0; j<ns; j++ )
if ( op[j].order == 1 )
1342 if ( fabs(
M_PI_2 - vecz.angle(op[j].axis)) < maxang )
1343 sym_label =
Bstring(order,
"D%dd");
1344 for ( j=0; j<ns; j++ )
if ( op[j].order == 1 ) {
1345 a = fabs(vecz.angle(op[j].axis));
1346 if ( a < maxang || fabs(
M_PI - a) < maxang )
1347 sym_label =
Bstring(order,
"D%dh");
1352 for ( order=0, i=1; i<
NSMAX; i++ )
if ( nord[i] ) order = i;
1354 if ( order == 1 ) sym_label =
"Cs";
1355 else sym_label =
Bstring(order,
"C%d");
1356 for ( i=0; i<ns && op[i].order != order; i++ ) ;
1357 if ( op[i].order ) {
1358 vecx = op[i].axis.
cross(vecz);
1362 if ( order>1 && nord[1] ) {
1363 for ( j=0; j<ns; j++ )
if ( op[j].order == 1 ) {
1364 if ( fabs(
M_PI_2 - vecz.angle(op[j].axis)) < maxang ) {
1366 sym_label =
Bstring(order,
"C%dv");
1369 for ( j=0; j<ns; j++ )
if ( op[j].order == 1 ) {
1370 a = fabs(vecz.angle(op[j].axis));
1371 if ( a < maxang || fabs(
M_PI - a) < maxang )
1372 sym_label =
Bstring(order,
"C%dh");
1381 t.
angle = acos(vecz[2]);
1387 t.
angle = atan2(-vecx[1], vecx[0]);
1402 cout <<
"Point group: " << sym_label << endl;
1403 cout <<
"Hand: " <<
model->
hand << endl;
1404 cout <<
"Z-axis: " << vecz << endl;
1405 cout <<
"X-axis: " << vecx << endl << endl;
1441 for ( ncomp = 0, comp =
model->
comp; comp; comp = comp->
next ) ncomp++;
1443 if ( ncomp < 2 )
return 0;
1456 for ( i=0, comp =
model->
comp; comp; comp = comp->
next, i++ ) {
1457 coor[i] = comp->
loc;
1461 for ( i=j=0, v1=v2=0; i<ncomp; i++, j+=ncomp ) {
1462 v1 += coor[i]*(a[i][0]*a[i][1]);
1463 for ( k=0; k<ncomp; k++ )
1465 v2 += coor[i].
cross(coor[k])*(a[i][0]*a[k][1]);
1497 int i, j, nref, n, d, nmod(0), ntot(0);
1503 for ( nref=0, mp_ref = refmodel; mp_ref; mp_ref = mp_ref->
next )
1504 if ( mp_ref->
sel ) nref++;
1507 cout <<
"Comparing models with " << nref <<
" references" << nref << endl << endl;
1511 vector<int> nr(nref);
1512 vector<vector<double>> vr(nref);
1514 for ( i = 0, mp_ref = refmodel; mp_ref; mp_ref = mp_ref->
next )
if ( mp_ref->
sel ) {
1527 for ( i = 0, mp_ref = refmodel; mp_ref && mp_pick == NULL; mp_ref = mp_ref->
next )
if ( mp_ref->
sel ) {
1529 for ( j = 0, d = 0; j<n; j++ )
1530 if ( fabs(v[j] - vr[i][j]) > 1e-6 ) d++;
1534 cout <<
"Test: " << mp->
id <<
tab << mp_ref->
id <<
tab <<
1557 cout <<
"Models identified: " << nmod <<
"/" << ntot <<
" (" << nmod*100.0/ntot <<
")" << endl << endl;
1586 for ( ncomp = 0, comp =
model->
comp; comp; comp = comp->
next ) ncomp++;
1588 if ( ncomp < 1 )
return d;
1596 for ( k=i=0; i<ncomp; i++ ) {
1598 for ( j=0; j<ncomp; j++, k++ )
1599 cout <<
" " << a[i][j];
1600 cout <<
": " << d[i] << endl;
1605 cout <<
"Eigenvalues:";
1606 for ( i=0; i<ncomp; i++ ) cout <<
tab << d[i];
1632 cout <<
"Connected clusters:" << endl;
1637 cout << c <<
tab << i << endl;
1661 int i, j, k, m, ncomp;
1662 double len, s[3] = {1,1,1};
1666 for ( ncomp = 0, comp =
model->
comp; comp; comp = comp->
next ) ncomp++;
1676 for ( i=1, m=0; i<ncomp && m<3; i++ ) {
1677 for ( j=0, comp =
model->
comp; j<ncomp && comp; j++, comp = comp->next ) {
1678 if ( a[j][i] > 0 ) comp->
sel = 1;
1679 else comp->
sel = -1;
1682 if ( k == 2 ) p[m++] = i;
1684 cout <<
"Eigenvector " << i <<
": clusters =" << k << endl;
1689 cout <<
"Eigenvectors used:";
1690 for ( i=0; i<3; i++ ) cout <<
tab << p[i];
1694 for ( i=0; i<3; i++ ) s[i] = 1/sqrt(d[0] - d[p[i]]);
1696 for ( i=0, comp =
model->
comp; comp; comp = comp->
next, i++ )
1699 for ( i=0, len=0, link =
model->
link; link; link = link->
next, i++ )