1#ifndef __JBXL_CPP_MEMORY_SIMPLE_GRAPH_H_
2#define __JBXL_CPP_MEMORY_SIMPLE_GRAPH_H_
17void rotate_point (
int& x,
int& y,
double sxc,
double syc,
double dxc,
double dyc,
double cst,
double snt);
18void rotate_point_angle(
int& x,
int& y,
double sxc,
double syc,
double dxc,
double dyc,
double th);
89 double fac = 1.113757;
104 if (vt.
y!=0) vt.
z = (vt.
x*vt.
x)/(4.*
PI*vt.
y)/fac;
134 for (
int i=0; i<pp.
xs*pp.
ys*pp.
zs; i++) pp.
gp[i] = vp.
gp[i];
138 for (
int j=0; j<pp.
ys; j++) {
140 for (
int i=0; i<pp.
xs; i++) {
150 vt = dgree_circle_MSGraph<T>(pp);
152 for (
int j=0; j<pp.
ys; j++) {
154 for (
int i=0; i<pp.
xs; i++) {
156 if (pp.
gp[nx]>=mn && pp.
gp[nx]<=mx) {
185 const double qs = 0.70710678118654752440084436210;
189 if (xp.
isNull())
return -1.0;
192 for (j=1; j<xp.
ys-1; j+=2) {
193 for (i=1; i<xp.
xs-1; i+=2) {
196 for (n=0; n<2; n++) {
197 for (m=0; m<2; m++) {
200 if (n>0)
if (xp.
point(i+(1-m), j)!=vp.
zero) sflg =
true;
205 if (cc==1 || cc==3) cnt += qs;
207 if (sflg==
false) cnt += 1;
227 for (
int i=0; i<xp.
xs*xp.
ys*xp.
zs; i++) {
228 if (xp.
gp[i]!=xp.
zero) ss++;
241 for (
int i=0; i<pp.
xs*pp.
ys*pp.
zs; i++) pp.
gp[i] = xp.
gp[i];
245 for (
int j=0; j<pp.
ys; j++) {
247 for (
int i=0; i<pp.
xs; i++) {
257 for (
int j=0; j<pp.
ys; j++) {
259 for (
int i=0; i<pp.
xs; i++) {
261 if (pp.
gp[nx]>=mn && pp.
gp[nx]<=mx) {
297 int i, j, sp, cp, w, ll, ss;
298 int xx, yy, vx, vy, ix;
301 int r8[8]={-1, 1, -1, -1, 1, -1, 1, 1};
302 int r4[8]={ 0, 1, -1, 0, 0, -1, 1, 0};
307 for (j=y; j<vp.
ys-1; j++) {
308 for (i=x; i<vp.
xs-1; i++) {
339 xx = (vx*cc[0]+vy*cc[1])/w;
340 yy = (vx*cc[2]+vy*cc[3])/w;
341 for (j=1; j<=ix; j++) {
342 if (vp.
gp[cp+yy*vp.
xs+xx]!=vp.
zero) {
345 cp = cp + yy*vp.
xs + xx;
355 if(sp==cp && xx==-1 && yy==vp.
zero) {
360 vx = (xx*cc[4]+yy*cc[5])/w;
361 vy = (xx*cc[6]+yy*cc[7])/w;
367 if (abs(vx)+abs(vy)==2) ss++;
394 for (
int k=0; k<vp.
zs; k++) {
396 for (
int j=0; j<vp.
ys; j++) {
398 for (
int i=0; i<vp.
xs; i++) {
400 if (vp.
gp[nx]>=mn && vp.
gp[nx]<=mx) {
401 rb.
fusion((T)i, (T)j, (T)k);
423 if ((
void*)src.
gp==(
void*)dst.
gp)
return;
437 if (vp.
gp==NULL)
return;
442 for (i=0; i<dst.
xs*dst.
ys*dst.
zs; i++) {
443 if (dst.
gp[i]!=dst.
zero) {
447 vp.
gp[z*vp.
xs*vp.
ys + y*vp.
xs + x] = dst.
gp[i];
451 for (i=0; i<src.
xs*src.
ys*src.
zs; i++) {
452 if (src.
gp[i]!=src.
zero) {
456 vp.
gp[z*vp.
xs*vp.
ys + y*vp.
xs + x] = (T)src.
gp[i];
477 if (src==NULL || dst==NULL)
return;
478 if ((
void*)src->
gp==(
void*)dst->
gp)
return;
492 if (vp.
gp==NULL)
return;
497 for (i=0; i<dst->
xs*dst->
ys*dst->
zs; i++) {
498 if (dst->
gp[i]!=dst->
zero) {
502 vp.
gp[z*vp.
xs*vp.
ys + y*vp.
xs + x] = dst->
gp[i];
506 for (i=0; i<src->
xs*src->
ys*src->
zs; i++) {
507 if (src->
gp[i]!=src->
zero) {
511 vp.
gp[z*vp.
xs*vp.
ys + y*vp.
xs + x] = (T)src->
gp[i];
532 if ((
void*)src.
gp==(
void*)dst.
gp)
return;
549 for (
int i=0; i<vp.
xs*vp.
ys*vp.
zs; i++) vp.
gp[i] = (T)src.
gp[i];
568 if (src==NULL || dst==NULL)
return;
569 if ((
void*)src->
gp==(
void*)dst->
gp)
return;
586 for (
int i=0; i<vp.
xs*vp.
ys*vp.
zs; i++) vp.
gp[i] = (T)src->
gp[i];
620 for (
int i=0; i<vp.
xs*vp.
ys*vp.
zs; i++) vp.
gp[i] = src.
gp[i];
636 if (src==NULL)
return NULL;
653 for (
int i=0; i<vp->
xs*vp->
ys*vp->
zs; i++) vp->
gp[i] = src->
gp[i];
674template <
typename T>
void ToPola(
Vector<T> nv,
double& cst,
double& snt,
double& csf,
double& snf,
double pcsf=0.0,
double psnf=1.0)
677 if (nv.
z<-1.0) nv.
z = -1.0;
678 if (nv.
z> 1.0) nv.
z = 1.0;
680 snt = sqrt(1.0-nv.
z*nv.
z);
729template <
typename T,
typename R>
732 int x, y, z, cx, cy, cz;
733 double px, py, pz, xx, yy, zz;
734 double cst, snt, csf=0.0, snf=1.0;
736 if (pcsf!=NULL && psnf!=NULL) {
741 ToPola(ex, cst, snt, csf, snf, csf, snf);
743 for (z=0; z<vp.
zs; z++) {
745 for (y=0; y<vp.
ys; y++) {
747 for (x=0; x<vp.
xs; x++) {
753 xx = px*snt*csf - py*snf - pz*cst*csf + oq.
x;
754 yy = px*snt*snf + py*csf - pz*cst*snf + oq.
y;
755 zz = px*cst + pz*snt + oq.
z;
762 if (pcsf!=NULL && psnf!=NULL) {
771 for (
int i=0; i<vp.
xs*vp.
ys*vp.
zs; i++) {
772 if (vp.
gp[i]==(T)f) vp.
gp[i] = (T)t;
797 if (cc<=mx && cc>=mn) {
802 if (x<0 || x>=vp.
xs || y<0 || y>=vp.
ys)
return 0;
803 if (vp.
gp[y*vp.
xs+x]>(T)mx || vp.
gp[y*vp.
xs+x]<(T)mn)
return 0;
806 if (vp.
gp[y*vp.
xs+x-1]>(T)mx || vp.
gp[y*vp.
xs+x-1]<(T)mn)
break;
813 if (vp.
gp[y*vp.
xs+k]>(T)mx || vp.
gp[y*vp.
xs+k]<(T)mn)
break;
814 vp.
gp[y*vp.
xs+k] = (T)cc;
820 for (i=x; i<=k; i++){
821 if (y-1>=0 && y-1<vp.
ys){
823 if (vp.
gp[j]<=(T)mx && vp.
gp[j]>=(T)mn) {
829 if (vp.
gp[j-1]<=(T)mx && vp.
gp[j-1]>=(T)mn) {
834 if (vp.
gp[j+1]<=(T)mx && vp.
gp[j+1]>=(T)mn) {
841 if (y+1>=0 && y+1<vp.
ys){
843 if (vp.
gp[j]<=(T)mx && vp.
gp[j]>=(T)mn) {
849 if (vp.
gp[j-1]<=(T)mx && vp.
gp[j-1]>=(T)mn) {
854 if (vp.
gp[j+1]<=(T)mx && vp.
gp[j+1]>=(T)mn) {
892 xp.
gp = &(vp.
gp[z*ps]);
894 if (xp.
gp[y*xp.
xs+x]>(T)mx || xp.
gp[y*xp.
xs+x]<(T)mn)
return 0;
900 for (i=0; i<ps; i++) {
901 if (xp.
gp[i]==(T)cc) {
905 j = (z-1)*ps+y*vp.
xs+x;
906 if (vp.
gp[j]<=(T)mx && vp.
gp[j]>=(T)mn) {
911 j = (z+1)*ps+y*vp.
xs+x;
912 if (vp.
gp[j]<=(T)mx && vp.
gp[j]>=(T)mn) {
957 for (index=0; index<xdiff+1; index++) {
958 if (x1>=0 && x1<vp.xs && y1>=0 && y1<vp.
ys) {
959 vp.
point(x1, y1) = (T)cc;
962 thresh = thresh + ydiff;
964 thresh = thresh - xdiff;
970 for (index=0; index<ydiff+1; index++) {
971 if (x1>=0 && x1<vp.xs && y1>=0 && y1<vp.
ys) {
972 vp.
point(x1, y1) = (T)cc;
975 thresh = thresh + xdiff;
977 thresh = thresh - ydiff;
1064 int xx, yy, zz, dx, dy, dz;
1065 int ux=1, uy=1, uz=1;
1066 int sx=0, sy=0, sz=0;
1089 if (xx>=0 && xx<vp.xs && yy>=0 && yy<vp.ys && zz>=0 && zz<vp.
zs) {
1090 vp.
point(xx, yy, zz) = (T)cc;
1092 if (dx>=dy && dx>=dz) {
1093 for (i=1; i<=dx; i++) {
1105 if (xx>=0 && xx<vp.xs && yy>=0 && yy<vp.ys && zz>=0 && zz<vp.
zs) {
1106 vp.
point(xx, yy, zz) = (T)cc;
1110 else if (dy>dx && dy>=dz) {
1111 for (i=1; i<=dy; i++) {
1123 if (xx>=0 && xx<vp.xs && yy>=0 && yy<vp.ys && zz>=0 && zz<vp.
zs) {
1124 vp.
point(xx, yy, zz) = (T)cc;
1129 for (i=1; i<=dz; i++) {
1141 if (xx>=0 && xx<vp.xs && yy>=0 && yy<vp.ys && zz>=0 && zz<vp.
zs) {
1142 vp.
point(xx, yy, zz) = (T)cc;
1169 px = (
int*)malloc(
sizeof(
int)*(r+1));
1170 py = (
int*)malloc(
sizeof(
int)*(r+1));
1171 if (px==NULL || py==NULL) {
1172 if (px!=NULL) free(px);
1173 if (py!=NULL) free(py);
1176 memset(px, 0,
sizeof(
int)*(r+1));
1177 memset(py, 0,
sizeof(
int)*(r+1));
1186 cx = (y+iy)*vp.
xs + (x+ix);
1187 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
gp[cx] = (T)cc;
1195 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1201 for (i=0; i<=nn; i++) {
1204 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1207 for (i=0; i<=nn; i++) {
1210 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1213 for (i=0; i<=nn; i++) {
1216 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1219 for (i=0; i<=nn; i++) {
1222 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1225 for (i=0; i<=nn; i++) {
1228 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1231 for (i=0; i<=nn; i++) {
1234 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1237 for (i=0; i<=nn; i++) {
1240 if (x+ix>=0 && x+ix<vp.xs && y+iy>=0 && y+iy<vp.
ys) vp.
point(x+ix, y+iy) = (T)cc;
1266 if (xp.
gp==NULL)
return;
1296 xp.
set(2*rr+3, 2*rr+3, (
int)(ox.
n + 0.5));
1297 if (xp.
gp==NULL)
return;
1300 for (i=0; i<xp.
zs; i++) {
1302 pp.
gp = &(xp.
gp[cz]);
1306 oz.
set((xp.
xs-1)/2.0, (xp.
ys-1)/2.0, (xp.
zs-1)/2.0);
1326template <
typename T>
1330 double dt, th, xx, yy, zz, sn, cs;
1334 xp.
set(2*(rr+ra)+3, 2*(rr+ra)+3, 2*ra+3);
1335 if (xp.
gp==NULL)
return;
1336 nn = (int)(2.0*
PI*(rr+ra)*2 + 0.5);
1340 for (i=0; i<nn; i++) {
1344 xx = (xp.
xs-1)/2.0 + rr*cs;
1345 yy = (xp.
ys-1)/2.0 - rr*sn;
1347 ve.
set(sn, cs, 0.0);
1350 vz.
set((xp.
xs-1)/2., (xp.
ys-1)/2., (xp.
zs-1)/2.);
1375 int i, j, k, rx, nn, s=1;
1376 double th, fi, cs, sn, cf, sf, dt;
1382 for (k=(
int)(a.
z-r+0.5); k<=(int)(a.
z+r+0.5); k++) {
1383 if (k>=0 && k<vp.
zs) {
1385 rx = (int)(sqrt(r*r-(a.
z-k)*(a.
z-k))+0.5);
1391 nn = (int)(2*
PI*r + 0.5)*2;
1393 for (i=0; i<=nn; i++) {
1400 if (zz>vp.
zs-s-1) zz = vp.
zs - s - 1;
1402 for (j=0; j<=2*nn; j++) {
1411 if (xx>vp.
xs-s-1) xx = vp.
xs - s - 1;
1412 if (yy>vp.
ys-s-1) yy = vp.
ys - s - 1;
1448 if (counter!=NULL) {
1458 for (k=0; k<vp.
zs; k++) {
1460 for (j=0; j<vp.
ys; j++) {
1462 for (i=0; i<vp.
xs; i++) {
1464 if (vp.
gp[ax]>=(T)mn && vp.
gp[ax]<=(T)mx) {
1472 if (counter!=NULL) {
1486 if (blank>0) rb.
enlarge(blank);
1500 for (k=0; k<xp.
zs; k++) {
1502 az = ap*(k+rb.
zmin);
1503 for (j=0; j<xp.
ys; j++) {
1505 ay = az + vp.
xs*(j+rb.
ymin);
1506 for (i=0; i<xp.
xs; i++) {
1508 ax = ay + (i+rb.
xmin);
1509 if (vp.
gp[ax]>=(T)mn && vp.
gp[ax]<=(T)mx) {
1510 xp.
gp[cx] = vp.
gp[ax];
1518 if (counter!=NULL) {
1560 if (counter!=NULL) {
1571 for (k=rbound.
zmin; k<=rbound.
zmax; k++) {
1573 for (j=rbound.
ymin; j<=rbound.
ymax; j++) {
1575 for (i=rbound.
xmin; i<=rbound.
xmax; i++) {
1577 if (vp.
gp[ax]>=(T)mn && vp.
gp[ax]<=(T)mx) {
1585 if (counter!=NULL) {
1599 if (blank>0) rb.
enlarge(blank);
1613 for (k=0; k<xp.
zs; k++) {
1615 az = ap*(k+rb.
zmin);
1616 for (j=0; j<xp.
ys; j++) {
1618 ay = az + vp.
xs*(j+rb.
ymin);
1619 for (i=0; i<xp.
xs; i++) {
1621 ax = ay + i + rb.
xmin;
1622 if (vp.
gp[ax]>=(T)mn && vp.
gp[ax]<=(T)mx) {
1623 xp.
gp[cx] = vp.
gp[ax];
1631 if (counter!=NULL) {
1668 if (counter!=NULL) {
1688 for (k=0; k<xp.
zs; k++) {
1690 az = ap*(k+rb.
zmin);
1691 for (j=0; j<xp.
ys; j++) {
1693 ay = az + vp.
xs*(j+rb.
ymin);
1694 for (i=0; i<xp.
xs; i++) {
1696 ax = ay + i + rb.
xmin;
1697 xp.
gp[cx] = vp.
gp[ax];
1699 if (cx==0) xp.
max = xp.
min = xp.
gp[cx];
1708 if (counter!=NULL) {
1735 int xss, yss, ps, pz, py;
1748 else if (zm<0.0) zm = -zm;
1750 xss = (int)(vp.
xs*zm) + 1;
1751 yss = (int)(vp.
ys*zm) + 1;
1753 vx.
set(xss, yss, vp.
zs);
1754 if (vx.
isNull())
return vx;
1761 double xx, yy, al, bt;
1763 for(
int k=0; k<vx.
zs; k++) {
1765 for(
int j=0; j<yss; j++) {
1767 for(
int i=0; i<xss; i++) {
1772 if (ii>=vp.
xs) ii = vp.
xs - 1;
1773 if (jj>=vp.
ys) jj = vp.
ys - 1;
1777 if (kk>=vp.
xs) kk = vp.
xs - 1;
1778 if (ll>=vp.
ys) ll = vp.
ys - 1;
1780 if (xx>=0.) al = xx - ii;
1782 if (yy>=0.) bt = yy - jj;
1785 vx.
gp[py+i] = (T)((1.-al)*(1.-bt)*vp.
point(ii, jj, k) + al*(1.-bt)*vp.
point(kk, jj, k)
1786 + (1.-al)*bt*vp.
point(ii, ll, k) + al*bt*vp.
point(kk, ll, k) + 0.5);
1795 for(
int k=0; k<vx.
zs; k++) {
1797 for(
int j=0; j<yss; j++) {
1799 for(
int i=0; i<xss; i++) {
1802 vx.
gp[py+i] = vp.
point(ii, jj, k);
1816 int xss, yss, ps, pz, py;
1829 else if (rc<0.0) rc = -rc;
1831 xss = (int)(vp.
xs/rc);
1832 yss = (int)(vp.
ys/rc);
1834 vx.
set(xss, yss, vp.
zs);
1835 if (vx.
isNull())
return vx;
1841 int ii, jj, kk, ll, ss, nn;
1843 for(
int z=0; z<vx.
zs; z++) {
1845 for(
int j=0; j<yss; j++) {
1847 for(
int i=0; i<xss; i++) {
1850 if (ii>=vp.
xs) ii = vp.
xs - 1;
1851 if (jj>=vp.
ys) jj = vp.
ys - 1;
1854 for(
int l=jj; l<jj+(int)rc; l++) {
1856 if (ll>=vp.
ys) ll = vp.
ys - 1;
1857 for(
int k=ii; k<ii+(int)rc; k++) {
1859 if (kk>=vp.
xs) kk = vp.
xs - 1;
1860 ss += vp.
point(kk, ll, z);
1864 vx.
gp[py+i] = ss/nn;
1873 for(
int k=0; k<vx.
zs; k++) {
1875 for(
int j=0; j<yss; j++) {
1877 for(
int i=0; i<xss; i++) {
1880 if (ii>=vp.
xs) ii = vp.
xs - 1;
1881 if (jj>=vp.
ys) jj = vp.
ys - 1;
1882 vx.
gp[py+i] = vp.
point(ii, jj, k);
1903 double u, t, x, y, a, b;
1906 if (vs.
isNull())
return vs;
1911 for (
int k=0; k<vs.
zs; k++) {
1913 for (
int jj=0; jj<vs.
ys; jj++) {
1915 for (
int ii=0; ii<vs.
xs; ii++) {
1916 u = ii - (vs.
xs-1)/2.;
1917 t = (vs.
ys-1)/2. - jj;
1919 y = - u*snt + t*cst;
1920 a = x + (vp.
xs-1)/2.;
1921 b = (vp.
ys-1)/2. - y;
1925 if (i<0 || i>=vp.
xs || j<0 || j>=vp.
ys) {
1930 if (a>=0.) a = a - i;
1932 if (b>=0.) b = b - j;
1937 if (m>=vp.
xs) m = vp.
xs - 1;
1938 if (n>=vp.
ys) n = vp.
ys - 1;
1939 pt = (T)((1.-a)*(1.-b)*vp.
point(i, j, k) + (1.-a)*b*vp.
point(i, n, k)
1940 + a*(1.-b)*vp.
point(m, j, k) + a*b*vp.
point(m, n, k) + 0.5);
1943 pt = vp.
point(i, j, k);
1959 double cst = cos(th);
1960 double snt = cos(th);
1961 int xys = (int)sqrt(vp.
xs*vp.
xs+vp.
ys*vp.
ys) + 1;
1963 vs = rotate_MSGraph<T>(vp, xys, xys, cst, snt, mode);
1980 int i, j, k, cy, cz;
1987 if (counter!=NULL) {
1996 if (wp.
isNull())
return wp;
1999 for (k=0; k<vp.
zs; k++) {
2001 for (j=0; j<vp.
ys; j++) {
2003 for (i=0; i<vp.
xs; i++) {
2004 wp.
gp[cy + i] = vp.
gp[cy + vp.
xs - 1 - i];
2009 if (counter!=NULL) {
2048 for(j=0; j<vp.
ys; j++) {
2050 px2 = (j+1)*vp.
xs-size;
2051 for(i=0; i<size; i++) {
2052 vp.
gp[i+px1] = (T)cc;
2053 vp.
gp[i+px2] = (T)cc;
2057 for(j=0; j<size; j++) {
2059 px2 = (j+vp.
ys-size)*vp.
xs;
2060 for(i=0; i<vp.
xs; i++) vp.
gp[i+px1] = (T)cc;
2061 for(i=0; i<vp.
xs; i++) vp.
gp[i+px2] = (T)cc;
2083 int xsize, ysize, zsize;
2090 xe =
Min(xe, vp.
xs-1);
2094 ye =
Min(ye, vp.
ys-1);
2096 ze =
Min(ze, vp.
zs-1);
2098 xsize = xe - xs + 1;
2099 ysize = ye - ys + 1;
2100 zsize = ze - zs + 1;
2103 if (xp.
isNull())
return xp;
2109 for (k=0; k<zsize; k++) {
2110 for (j=0; j<ysize; j++) {
2111 for (i=0; i<xsize; i++) {
2112 T point = vp.
point(xs+i, ys+j, zs+k);
2113 xp.
point(i, j, k) = point;
2114 if (point>xp.
max) xp.
max = point;
2115 else if (point<xp.
min) xp.
min = point;
2147 int xsize, ysize, zsize;
2154 xe =
Min(xe, vp->
xs-1);
2158 ye =
Min(ye, vp->
ys-1);
2160 ze =
Min(ze, vp->
zs-1);
2162 xsize = xe - xs + 1;
2163 ysize = ye - ys + 1;
2164 zsize = ze - zs + 1;
2172 for (k=0; k<zsize; k++) {
2173 for (j=0; j<ysize; j++) {
2174 for (i=0; i<xsize; i++) {
2175 T point = vp->
point(xs+i, ys+j, zs+k);
2176 xp->
point(i, j, k) = point;
2177 if (point>xp->
max) xp->
max = point;
2178 else if (point<xp->min) xp->
min = point;
2214 int i, k, cc, cx, st, ed, num=0;
2216 if (x<0 || x>=xp.
xs || y<0 || y>=xp.
ys)
return 0;
2219 cc = (int)xp.
point(x, y);
2221 cx = (int)xp.
point(x-1, y);
2222 if (cx>mx || cx<mn)
break;
2230 cx = (int)xp.
point(k, y);
2231 if (cx>mx || cx<mn)
break;
2232 xp.
point(k, y) += add;
2240 for (i=st; i<=ed; i++){
2241 cc = (int)xp.
point(i, y) - add;
2244 if (y-1>=0 && y-1<xp.
ys){
2245 cx = (int)xp.
point(i, y-1);
2246 if (cx<=mx && cx>=mn) {
2251 cx = (int)xp.
point(i-1, y-1);
2252 if (cx<=mx && cx>=mn) {
2257 cx = (int)xp.
point(i+1, y-1);
2258 if (cx<=mx && cx>=mn) {
2266 if (y+1>=0 && y+1<xp.
ys){
2267 cx = (int)xp.
point(i, y+1);
2268 if (cx<=mx && cx>=mn) {
2273 cx = (int)xp.
point(i-1, y+1);
2274 if (cx<=mx && cx>=mn) {
2279 cx = (int)xp.
point(i+1, y+1);
2280 if (cx<=mx && cx>=mn) {
2310 int ps = vp.
xs*vp.
ys;
2312 if (work_color==0) {
2314 work_color = vp.
max + 1;
2318 if ((
int)(ps*rate+0.5)==ps) {
2320 for (
int i=0; i<ps; i++) {
2328 for (
int i=0; i<ps; i++) pp.
gp[i] = vp.
gp[i];
2338 for (
int j=0; j<vp.
ys; j++) {
2339 for (
int i=0; i<vp.
xs; i++) {
2340 xp.
gp[(j+1)*xp.
xs+i+1] = vp.
gp[j*vp.
xs+i];
2347 for (
int j=0; j<vp.
ys; j++) {
2348 for (
int i=0; i<vp.
xs; i++) {
2349 if (xp.
gp[(j+1)*xp.
xs+i+1]==work_color) {
2350 pp.
gp[j*pp.
xs+i] = vp.
gp[j*vp.
xs+i];
2357 if ((
int)(ps*rate+0.5)>nn) {
2386 if (work_color==0) {
2388 work_color = vp.
max + 1;
2391 if (hsize==0) hsize = 1;
2396 for (
int j=hsize; j<vp.
ys-hsize; j++) {
2397 for (
int i=hsize; i<vp.
xs-hsize; i++) {
2399 for (
int m=-hsize; m<=hsize; m++) {
2400 int vx = (m+j)*vp.
xs + i;
2401 int px = (m+hsize)*pp.
xs + hsize;
2403 for (
int n=-hsize; n<=hsize; n++) {
2404 pp.
gp[px+n] = vp.
gp[vx+n];
2408 xp = Density_Mask<T>(pp, rate, mode, work_color);
2411 for (
int m=-hsize; m<=hsize; m++) {
2412 int wx = (m+j)*wp.
xs + i;
2413 int xx = (m+hsize)*xp.
xs + hsize;
2415 for (
int n=-hsize; n<=hsize; n++) {
2416 if (xp.
gp[xx+n]!=vp.
zero) {
2417 wp.
gp[wx+n] = xp.
gp[xx+n];
2443 if (work_color==0) {
2445 work_color = vp.
max + 1;
2448 for(j=0; j<vp.
ys; j++) {
2450 for(i=0; i<vp.
xs; i++) {
2451 if (vp.
gp[i+pp]>vp.
zero && vp.
gp[i+pp]<work_color) {
2455 for (k=i+pp; k<ps; k++) {
2456 if (vp.
gp[k]>=work_color) {
2465 for (k=i+pp; k<ps; k++) {
2466 if (vp.
gp[k]>=work_color) {
2467 vp.
gp[k] = -vp.
gp[k];
2477 for (i=0; i<ps; i++) {
2478 if (vp.
gp[i]<vp.
zero) vp.
gp[i] = - vp.
gp[i] - work_color;
#define BOUNDARY_BLANK
境界 RBound<T> の余白
virtual void StepIt(int n=1)
カウンタのメモリを増やす
virtual void SetMax(int m)
カウンタの最大値(最終目標)を設定
virtual bool isCanceled()
カウンタがオペレータにより,キャンセルされたか
void clear(T v)
全空間を画素値 v にする
T & point(int x, int y=0, int z=0)
座標(x,y,z)の画素値の参照
void init(void)
グラフィックデータは解放しない
int zs
zサイズ. 4Byte. 2Dの場合は 1.
void get_minmax(void)
min, max を獲得
double RZxy
Z軸の歪.Z軸の間隔を 1とした XY軸の間隔.(X or Y)/Z.
void free(void)
グラフィックデータを開放する
void set(RBound< int > rb, T v=(T) 0, T b=(T) 0, double rz=1.0)
bool isNull(void)
グラフィックデータを持っていないか?
void set_vPoint(double x, double y=0., double z=0., T cc=(T) 0, int mode=OFF)
void mimicry(MSGraph< R > s)
RBound< int > rbound
画像の境界情報
void getm(int x, int y, int z=1, T v=(T) 0)
グラフィックメモリを獲得する
void set(T XMin=(T) 0, T XMax=(T) 0, T YMin=(T) 0, T YMax=(T) 0, T ZMin=(T) 0, T ZMax=(T) 0, T TMin=(T) 0, T TMax=(T) 0)
void enlarge(T f)
境界構造体 bound を広げる
void fusion(RBound< T > bound)
境界構造体 bound と融合させる
void cutdown(RBound< T > bound)
切り出した場合の境界
void commonarea(RBound< T > bound)
境界構造体 bound との共通領域 共通領域がない場合は,min>max になる
Vector< T > normalize(void)
void set(T X, T Y=0, T Z=0, double N=0.0, double C=1.0, int D=0)
#define JBXL_GRAPH_IVDARG_ERROR
無効な引数
#define JBXL_GRAPH_NODATA_ERROR
データが無い
#define JBXL_GRAPH_CANCEL
処理がキャンセルされた
#define JBXL_GRAPH_MEMORY_ERROR
メモリエラー
void MSGraph_Sphere(MSGraph< T > vp, Vector<> a, int r, int cc, int mode=1)
int MSGraph_Paint(MSGraph< T > vp, int x, int y, int mn, int mx, int cc, int mode=8)
void set_around_MSGraph(MSGraph< T > vp, int cc=0, int size=1)
void rotate_point_angle(int &x, int &y, double sxc, double syc, double dxc, double dyc, double th)
CVCounter * GetUsableGlobalCounter()
現在有効なグローバルカウンタを得る.(子カウンタを得るかもしれない)
void MSGraph_Box(MSGraph< T > vp, int x1, int y1, int x2, int y2, int cc, int mode=OFF)
void Local2World(MSGraph< T > gd, MSGraph< T > vp, Vector< R > oq, Vector< R > op, Vector< R > ex, double *pcsf=NULL, double *psnf=NULL)
void ToPola(Vector< T > nv, double &cst, double &snt, double &csf, double &snf, double pcsf=0.0, double psnf=1.0)
void copy_MSGraph(MSGraph< R > src, MSGraph< T > &dst)
int addPaint_MSGraph(MSGraph< T > xp, int x, int y, int mn, int mx, int add, int mode=8)
void delete_noise_MSGraph(MSGraph< T > vp, int size, int mode=8, int work_color=0)
void MSGraph_Line3D(MSGraph< T > vp, int x1, int y1, int z1, int x2, int y2, int z2, int cc)
double Sin_Tolerance
sinθ==0
MSGraph< T > cut_object_MSGraph(MSGraph< T > vp, int mn, int mx, int blank=BOUNDARY_BLANK, bool ecnt=false)
MSGraph< T > Density_Mask(MSGraph< T > vp, double rate, int mode=8, int work_color=0)
int count_object_MSGraph(MSGraph< T > xp, int mn, int mx)
RBound< int > out_around_MSGraph(MSGraph< T > vp, int x, int y, int mode=8)
MSGraph< T > Density_Filter(MSGraph< T > vp, int size, double rate, int mode=8, int work_color=0)
void MSGraph_changeColor(MSGraph< T > vp, int f, int t)
MSGraph< T > grab_MSGraph(MSGraph< T > vp, int x1, int y1, int x2, int y2, int zs=0, int ze=0)
Vector< double > dgree_circle_MSGraph(MSGraph< T > vp)
int MSGraph_Paint3D(MSGraph< T > vp, int x, int y, int z, int mn, int mx, int cc, int mode=8)
void MSGraph_Torus(MSGraph< T > vp, Vector<> ox, Vector<> ex, int rr, int ra, int cc)
MSGraph< T > x_reverse_MSGraph(MSGraph< T > vp, bool ecnt=false)
MSGraph< T > rotate_MSGraph(MSGraph< T > vp, int xs, int ys, double cst, double snt, int mode=ON)
void rotate_point(int &x, int &y, double sxc, double syc, double dxc, double dyc, double cst, double snt)
void MSGraph_Pool(MSGraph< T > vp, Vector<> a, Vector<> b, int rr, int cc)
MSGraph< T > dup_MSGraph(MSGraph< T > src)
Vector< double > object_feature_MSGraph(MSGraph< T > vp, int mn, int mx)
void cat_MSGraph(MSGraph< R > src, MSGraph< T > &dst)
MSGraph< T > reduce_MSGraph(MSGraph< T > vp, double rc, int mode=ON)
void MSGraph_Line(MSGraph< T > vp, int x1, int y1, int x2, int y2, int cc)
RBound< int > get_boundary_MSGraph(MSGraph< T > vp, T mn, T mx)
MSGraph< T > zoom_MSGraph(MSGraph< T > vp, double zm, int mode=ON)
double count_around_MSGraph(MSGraph< T > vp)
void MSGraph_Circle(MSGraph< T > vp, int x, int y, int r, int cc, int mode=OFF)
void MSGraph_Circle3D(MSGraph< T > vp, Vector<> ox, Vector<> ex, int rr, int cc, int mode=OFF)
int count_area_MSGraph(MSGraph< T > xp)
void MSGraph_Triangle(MSGraph< T > vp, int x1, int y1, int x2, int y2, int x3, int y3, int cc, int mode=OFF)