本文整理汇总了C++中HCDT::GetNN方法的典型用法代码示例。如果您正苦于以下问题:C++ HCDT::GetNN方法的具体用法?C++ HCDT::GetNN怎么用?C++ HCDT::GetNN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HCDT
的用法示例。
在下文中一共展示了HCDT::GetNN方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mgl_data_grid_xy
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_data_grid_xy(HMDT d, HCDT xdat, HCDT ydat, HCDT zdat, mreal x1, mreal x2, mreal y1, mreal y2)
{ // NOTE: only for mglData
const mglData *x = dynamic_cast<const mglData *>(xdat);
const mglData *y = dynamic_cast<const mglData *>(ydat);
long n=xdat->GetNN();
if((n<3) || (ydat->GetNN()!=n) || (zdat->GetNN()!=n)) return;
mglData *nums = mgl_triangulation_2d(xdat,ydat);
if(nums->nx<3) { delete nums; return; }
long nn = nums->ny, par[3]={d->nx,d->ny,d->nz};
mreal xx[4]={x1,(d->nx-1.)/(x2-x1), y1,(d->ny-1.)/(y2-y1)};
mreal *xc=new mreal[n], *yc=new mreal[n];
if(x && y)
#pragma omp parallel for
for(long i=0;i<n;i++)
{ xc[i]=xx[1]*(x->a[i]-xx[0]); yc[i]=xx[3]*(y->a[i]-xx[2]); }
else
#pragma omp parallel for
for(long i=0;i<n;i++)
{ xc[i]=xx[1]*(xdat->vthr(i)-xx[0]); yc[i]=xx[3]*(ydat->vthr(i)-xx[2]); }
long tmp = d->nx*d->ny*d->nz;
#pragma omp parallel for
for(long i=0;i<tmp;i++) d->a[i] = NAN;
mglStartThread(mgl_grid_t,0,nn,d->a,xc,yc,par,zdat,nums->a);
delete nums; delete []xc; delete []yc;
}
示例2: mgl_dots_ca
//-----------------------------------------------------------------------------
//
// Dots series
//
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_dots_ca(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT c, HCDT a, const char *sch, const char *opt)
{
long n = x->GetNN(), d, k=1;
if(x->GetNz()>1) k=3; else if(x->GetNy()>1) k=2;
if(y->GetNN()!=n || z->GetNN()!=n || c->GetNN()!=n || (a && a->GetNN()!=n))
{ gr->SetWarn(mglWarnDim,"Dots"); return; }
gr->SaveState(opt);
d = gr->MeshNum>0 ? mgl_ipow(gr->MeshNum+1,k) : n;
d = n>d ? n/d:1;
static int cgid=1; gr->StartGroup("Dots",cgid++);
char mk=gr->SetPenPal(sch);
long ss=gr->AddTexture(sch);
if(mk==0) mk='.';
gr->Reserve(n);
for(long i=0;i<n;i+=d)
{
mglPoint p = mglPoint(x->vthr(i),y->vthr(i),z->vthr(i));
long pp = gr->AddPnt(p,gr->GetC(ss,c->vthr(i)),mglPoint(NAN),a?gr->GetA(a->vthr(i)):-1);
gr->mark_plot(pp, mk);
}
gr->EndGroup();
}
示例3: mgl_datac_modify_vw
void MGL_EXPORT mgl_datac_modify_vw(HADT d, const char *eq,HCDT vdat,HCDT wdat)
{
const mglDataC *v = dynamic_cast<const mglDataC *>(vdat);
const mglDataC *w = dynamic_cast<const mglDataC *>(wdat);
long nn = d->nx*d->ny*d->nz, par[3]={d->nx,d->ny,d->nz};
if(vdat && vdat->GetNN()!=nn) return;
if(wdat && wdat->GetNN()!=nn) return;
mglFormulaC f(eq);
if(v && w) mglStartThreadC(mgl_cmodify,0,nn,d->a,v->a,w->a,par,&f);
else if(vdat && wdat) mglStartThreadV(mgl_cmodify_gen,nn,d->a,vdat,wdat,par,&f);
else if(v) mglStartThreadC(mgl_cmodify,0,nn,d->a,v->a,0,par,&f);
else if(vdat) mglStartThreadV(mgl_cmodify_gen,nn,d->a,vdat,0,par,&f);
else mglStartThreadC(mgl_cmodify,0,nn,d->a,0,0,par,&f);
}
示例4: mgl_datac_evaluate
//-----------------------------------------------------------------------------
HADT MGL_EXPORT mgl_datac_evaluate(HCDT dat, HCDT idat, HCDT jdat, HCDT kdat, int norm)
{
if(!idat || (jdat && jdat->GetNN()!=idat->GetNN()) || (kdat && kdat->GetNN()!=idat->GetNN())) return 0;
const mglData *dd=dynamic_cast<const mglData *>(dat);
const mglDataC *dc=dynamic_cast<const mglDataC *>(dat);
long nx=dat->GetNx(), ny=dat->GetNy(), nz=dat->GetNz();
mglDataC *r=new mglDataC(idat->GetNx(),idat->GetNy(),idat->GetNz());
if(dd)
#pragma omp parallel for
for(long i=0;i<idat->GetNN();i++)
{
mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;
r->a[i] = mgl_isnum(x*y*z)?mglSpline3st<mreal>(dd->a,nx,ny,nz, x,y,z):NAN;
}
else if(dc)
#pragma omp parallel for
for(long i=0;i<idat->GetNN();i++)
{
mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;
r->a[i] = mgl_isnum(x*y*z)?mglSpline3st<dual>(dc->a,nx,ny,nz, x,y,z):NAN;
}
else
#pragma omp parallel for
for(long i=0;i<idat->GetNN();i++)
{
mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;
r->a[i] = mgl_isnum(x*y*z)?mgl_data_linear(dat, x,y,z):NAN;;
}
return r;
}
示例5: mgl_data_fill_eq
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_data_fill_eq(HMGL gr, HMDT d, const char *eq, HCDT vdat, HCDT wdat, const char *opt)
{
if(vdat && vdat->GetNN()!=d->GetNN()) return; // incompatible dimensions
if(wdat && wdat->GetNN()!=d->GetNN()) return;
gr->SaveState(opt);
std::wstring s = d->Name(); d->Name(L"u");
mglDataV x(d->nx,d->ny,d->nz, gr->Min.x,gr->Max.x,'x'); x.Name(L"x");
mglDataV y(d->nx,d->ny,d->nz, gr->Min.y,gr->Max.y,'y'); y.Name(L"y");
mglDataV z(d->nx,d->ny,d->nz, gr->Min.z,gr->Max.z,'z'); z.Name(L"z");
mglDataV i(d->nx,d->ny,d->nz, 0,d->nx-1,'x'); i.Name(L"i");
mglDataV j(d->nx,d->ny,d->nz, 0,d->ny-1,'y'); j.Name(L"j");
mglDataV k(d->nx,d->ny,d->nz, 0,d->nz-1,'z'); k.Name(L"k");
mglDataV r(d->nx,d->ny,d->nz); r.Name(L"#$mgl");
mglData v(vdat), w(wdat); v.Name(L"v"); w.Name(L"w");
std::vector<mglDataA*> list;
list.push_back(&x); list.push_back(&y); list.push_back(&z); list.push_back(&r);
list.push_back(d); list.push_back(&v); list.push_back(&w);
list.push_back(&i); list.push_back(&j); list.push_back(&k);
d->Move(mglFormulaCalc(eq,list)); d->Name(s.c_str()); gr->LoadState();
}
示例6: fabs
HMDT MGL_EXPORT mgl_triangulation_2d(HCDT x, HCDT y)
{
mglData *nums=0;
long n = x->GetNN();
if(y->GetNN()!=n) return nums;
// use s-hull here
std::vector<Shx> pts;
std::vector<long> out;
Shx pt;
double mx = 0, my = 0;
for(long i=0;i<n;i++)
{
register double t;
t = fabs(x->vthr(i)); if(t>mx) mx=t;
t = fabs(y->vthr(i)); if(t>my) my=t;
}
mx *= 1e-15; my *= 1e-15;
for(long i=0;i<n;i++)
{
pt.r = x->vthr(i); pt.c = y->vthr(i);
if(mgl_isbad(pt.r) || mgl_isbad(pt.c)) continue;
if(fabs(pt.r)<mx) pt.r=0;
if(fabs(pt.c)<my) pt.c=0;
pt.id = i; pts.push_back(pt);
}
std::vector<Triad> triads;
if(de_duplicate(pts, out))
mgl_set_global_warn("There are duplicated points for triangulation.");
s_hull_pro(pts, triads);
long m = triads.size();
nums=new mglData(3,m);
for(long i=0;i<m;i++)
{
nums->a[3*i] = triads[i].a;
nums->a[3*i+1] = triads[i].b;
nums->a[3*i+2] = triads[i].c;
}
return nums;
}
示例7: mgl_datac_subdata_ext
//-----------------------------------------------------------------------------
HADT MGL_EXPORT mgl_datac_subdata_ext(HCDT d, HCDT xx, HCDT yy, HCDT zz)
{
if(!xx || !yy || !zz)
{
mglData tmp; tmp.a[0]=-1;
return mgl_datac_subdata_ext(d,xx?xx:&tmp,yy?yy:&tmp,zz?zz:&tmp);
}
long n=0,m=0,l=0,j,k;
bool ix=false, iy=false, iz=false;
if(xx->GetNz()>1) // 3d data
{
n = xx->GetNx(); m = xx->GetNy(); l = xx->GetNz();
j = yy->GetNN(); if(j>1 && j!=n*m*l) return 0; // wrong sizes
k = zz->GetNN(); if(k>1 && k!=n*m*l) return 0; // wrong sizes
ix = true; iy = j>1; iz = k>1;
}
else if(yy->GetNz()>1)
{
n = yy->GetNx(); m = yy->GetNy(); l = yy->GetNz();
j = xx->GetNN(); if(j>1 && j!=n*m*l) return 0; // wrong sizes
k = zz->GetNN(); if(k>1 && k!=n*m*l) return 0; // wrong sizes
iy = true; ix = j>1; iz = k>1;
}
else if(zz->GetNz()>1)
{
n = zz->GetNx(); m = zz->GetNy(); l = zz->GetNz();
j = yy->GetNN(); if(j>1 && j!=n*m*l) return 0; // wrong sizes
k = xx->GetNN(); if(k>1 && k!=n*m*l) return 0; // wrong sizes
iz = true; iy = j>1; ix = k>1;
}
else if(xx->GetNy()>1) // 2d data
{
n = xx->GetNx(); m = xx->GetNy(); l = 1;
j = yy->GetNx()*yy->GetNy(); if(j>1 && j!=n*m) return 0; // wrong sizes
k = zz->GetNx()*zz->GetNy(); if(k>1 && k!=n*m) return 0; // wrong sizes
ix = true; iy = j>1; iz = k>1;
}
else if(yy->GetNy()>1)
{
n = yy->GetNx(); m = yy->GetNy(); l = 1;
j = xx->GetNx()*xx->GetNy(); if(j>1 && j!=n*m) return 0; // wrong sizes
k = zz->GetNx()*zz->GetNy(); if(k>1 && k!=n*m) return 0; // wrong sizes
iy = true; ix = j>1; iz = k>1;
}
else if(zz->GetNy()>1)
{
n = zz->GetNx(); m = zz->GetNy(); l = 1;
j = yy->GetNx()*yy->GetNy(); if(j>1 && j!=n*m) return 0; // wrong sizes
k = xx->GetNx()*xx->GetNy(); if(k>1 && k!=n*m) return 0; // wrong sizes
iz = true; iy = j>1; ix = k>1;
}
long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz();
long vx=long(xx->v(0)), vy=long(yy->v(0)), vz=long(zz->v(0));
const mglDataC *dd = dynamic_cast<const mglDataC *>(d);
if(n*m*l>1) // this is 2d or 3d data
{
mglDataV tx(n,m,l),ty(n,m,l),tz(n,m,l);
if(!ix) { xx = &tx; if(vx>=0) tx.Fill(vx); else tx.All(); }
if(!iy) { yy = &ty; if(vy>=0) ty.Fill(vy); else ty.All(); }
if(!iz) { zz = &tz; if(vz>=0) tz.Fill(vz); else tz.All(); }
mglDataC *r=new mglDataC(n,m,l);
if(dd)
#pragma omp parallel for
for(long i0=0;i0<n*m*l;i0++)
{
register long x=long(0.5+xx->vthr(i0)), y=long(0.5+yy->vthr(i0)), z=long(0.5+zz->vthr(i0));
r->a[i0] = (x>=0 && x<nx && y>=0 && y<ny && z>=0 && z<nz)?dd->a[x+nx*(y+ny*z)]:NAN;
}
else
#pragma omp parallel for
for(long i0=0;i0<n*m*l;i0++)
{
register long x=long(0.5+xx->vthr(i0)), y=long(0.5+yy->vthr(i0)), z=long(0.5+zz->vthr(i0));
r->a[i0] = (x>=0 && x<nx && y>=0 && y<ny && z>=0 && z<nz)?d->v(x,y,z):NAN;
}
return r;
}
// this is 1d data -> try as normal SubData()
mglDataV tx(nx),ty(ny),tz(nz); tx.Fill(0,nx-1); ty.Fill(0,ny-1); tz.Fill(0,nz-1);
if(xx->GetNx()>1 || vx>=0) n=xx->GetNx(); else { n=nx; xx = &tx; }
if(yy->GetNx()>1 || vy>=0) m=yy->GetNx(); else { m=ny; yy = &ty; }
if(zz->GetNx()>1 || vz>=0) l=zz->GetNx(); else { l=nz; zz = &tz; }
mglDataC *r=new mglDataC(n,m,l);
if(dd)
#pragma omp parallel for collapse(3)
for(long k=0;k<l;k++) for(long j=0;j<m;j++) for(long i=0;i<n;i++)
{
register long x=long(0.5+xx->v(i)), y=long(0.5+yy->v(j)), z=long(0.5+zz->v(k));
r->a[i+n*(j+m*k)] = (x>=0 && x<nx && y>=0 && y<ny && z>=0 && z<nz)?dd->a[x+nx*(y+ny*z)]:NAN;
}
else
#pragma omp parallel for collapse(3)
for(long k=0;k<l;k++) for(long j=0;j<m;j++) for(long i=0;i<n;i++)
{
register long x=long(0.5+xx->v(i)), y=long(0.5+yy->v(j)), z=long(0.5+zz->v(k));
r->a[i+n*(j+m*k)] = (x>=0 && x<nx && y>=0 && y<ny && z>=0 && z<nz)?d->v(x,y,z):NAN;
}
if(m==1) { r->ny=r->nz; r->nz=1; }// "squeeze" dimensions
//.........这里部分代码省略.........