Пример #1
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_cont_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)
{
	long n=a->GetNx(),m=a->GetNy();
	if(n<2 || m<2)	{	gr->SetWarn(mglWarnLow,"ContZ");	return;	}
	gr->SaveState(opt);
	if(mgl_isnan(sv))	sv = gr->GetOrgZ('z');
	if(sv<gr->Min.z || sv>gr->Max.z)	{	gr->SetWarn(mglWarnSlc,"ContZ");	gr->LoadState();	return;	}
	static int cgid=1;	gr->StartGroup("ContZ",cgid++);
	mglDataV xx,yy,zz;	mglData aa;

	int text=0;
	if(mglchr(sch,'t'))	text=1;
	if(mglchr(sch,'T'))	text=2;
	long ss=gr->AddTexture(sch);
	gr->SetPenPal(sch);

	a = fill_slice_z(gr,sv,a,xx,yy,zz,aa);
#pragma omp parallel for
	for(long i=0;i<v->GetNx();i++)
	{
		mreal v0 = v->v(i);
		mgl_cont_gen(gr,v0,a,&xx,&yy,&zz,gr->GetC(ss,v0),text,0);
	}
	gr->EndGroup();
}
Пример #2
0
void MGL_EXPORT mgl_set_range_dat(HMGL gr, char dir, HCDT a, int add)
{
	if(dir=='c' || dir=='a')	gr->CRange(a,add);
	else if(dir=='x')	gr->XRange(a,add);
	else if(dir=='y')	gr->YRange(a,add);
	else if(dir=='z')	gr->ZRange(a,add);
}
Пример #3
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_triplot_xy(HMGL gr, HCDT nums, HCDT x, HCDT y, const char *sch, const char *opt)
{
	gr->SaveState(opt);
	mglData z(x->GetNx());
	mreal zm = gr->AdjustZMin();	z.Fill(zm,zm);
	mgl_triplot_xyzc(gr,nums,x,y,&z,&z,sch,0);
}
Пример #4
0
void MGL_EXPORT mgl_add_range_val(HMGL gr, char dir, double v1,double v2)
{
	if(dir=='c' || dir=='a')	gr->CRange(v1,v2,true);
	else if(dir=='x')	gr->XRange(v1,v2,true);
	else if(dir=='y')	gr->YRange(v1,v2,true);
	else if(dir=='z')	gr->ZRange(v1,v2,true);
}
Пример #5
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_dens_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt)
{
	long n=a->GetNx(),m=a->GetNy();
	if(n<2 || m<2)	{	gr->SetWarn(mglWarnLow,"DensZ");	return;	}
	gr->SaveState(opt);
	if(mgl_isnan(sv))	sv = gr->GetOrgZ('z');
	if(sv<gr->Min.z || sv>gr->Max.z)	{	gr->SetWarn(mglWarnSlc,"DensZ");	gr->LoadState();	return;	}
	mglDataV xx,yy,zz;	mglData aa;
	a = fill_slice_z(gr,sv,a,xx,yy,zz,aa);
	mgl_surf_gen(gr, &xx,&yy,&zz,a, 0, sch);
}
Пример #6
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_datac_refill_gr(HMGL gr, HADT dat, HCDT xdat, HCDT ydat, HCDT zdat, HCDT vdat, long sl, const char *opt)
{
	if(!vdat)	return;
	gr->SaveState(opt);
	if(!ydat && !zdat)	mgl_datac_refill_x(dat,xdat,vdat,gr->Min.x,gr->Max.x,sl);
//	else if(!xdat && !zdat)	mgl_datac_refill_x(dat,ydat,vdat,gr->Min.y,gr->Max.y,sl);
//	else if(!xdat && !ydat)	mgl_datac_refill_x(dat,zdat,vdat,gr->Min.z,gr->Max.z,sl);
	else if(!zdat)	mgl_datac_refill_xy(dat,xdat,ydat,vdat,gr->Min.x,gr->Max.x,gr->Min.y,gr->Max.y,sl);
//	else if(!ydat)	mgl_datac_refill_xy(dat,xdat,zdat,vdat,gr->Min.x,gr->Max.x,gr->Min.z,gr->Max.z,sl);
//	else if(!xdat)	mgl_datac_refill_xy(dat,ydat,zdat,vdat,gr->Min.y,gr->Max.y,gr->Min.z,gr->Max.z,sl);
	else	mgl_datac_refill_xyz(dat,xdat,ydat,zdat,vdat,gr->Min.x,gr->Max.x,gr->Min.y,gr->Max.y,gr->Min.z,gr->Max.z);
	gr->LoadState();
}
Пример #7
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_contf_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt)
{
	mreal r = gr->SaveState(opt);
	long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5);
	mglData v(Num);	v.Fill(gr->Min.c, gr->Max.c);
	mgl_contf_z_val(gr,&v,a,sch,sv,0);
}
Пример #8
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_cont_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt)
{
	mreal r = gr->SaveState(opt);
	long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5);
	mglData v(Num);
	for(long i=0;i<Num;i++)	v.a[i] = gr->Min.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1);
	mgl_cont_z_val(gr,&v,a,sch,sv,0);
}
Пример #9
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_tricontv_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt)
{
	mreal r = gr->SaveState(opt);
	long n = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5);
	mglData v(n);
	for(long i=0;i<n;i++)	v.a[i] = gr->Min.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(n+1);
	mgl_tricontv_xyzcv(gr,&v,nums,x,y,z,a,sch,0);
}
Пример #10
0
//-----------------------------------------------------------------------------
//
//	Crust series
//
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_crust(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt)
{
	if(y->GetNx()!=x->GetNx() || z->GetNx()!=x->GetNx())
	{	gr->SetWarn(mglWarnDim,"Crust");	return;	}
	HMDT nums = mgl_triangulation_3d(x, y, z);
	mgl_triplot_xyzc(gr,nums,x,y,z,z,sch,opt);
	mgl_delete_data(nums);
}
Пример #11
0
//-----------------------------------------------------------------------------
//
//	TriContV series
//
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_tricontv_xyzcv(HMGL gr, HCDT v, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt)
{
	mglDataV zz(x->GetNx(),x->GetNy());
	if(!z)	z = &zz;
	if(mgl_check_trig(gr,nums,x,y,z,a,"TriContV"))	return;

	gr->SaveState(opt);
	static int cgid=1;	gr->StartGroup("TriContV",cgid++);
	bool fixed=(mglchr(sch,'_')) || (gr->Min.z==gr->Max.z);
	long s=gr->AddTexture(sch);
	gr->SetPenPal(sch);

	for(long k=0;k<v->GetNx();k++)
	{
		mreal v0 = v->v(k);		zz.Fill(fixed ? gr->Min.z : v0);
		mreal dv = (gr->Max.c-gr->Min.c)/8, c = gr->GetC(s,v0);
		if(k>0)	dv = v->v(k-1)-v->v(k);
		else if(k<v->GetNx()-1)	dv = v->v(k)-v->v(k+1);
		if(fixed)	dv=-dv;

		const std::vector<mglSegment> curvs = mgl_get_curvs(gr,mgl_tri_lines(v0,nums,a,x,y,fixed?&zz:z));
		for(size_t i=0;i<curvs.size();i++)
		{
			const std::list<mglPoint> &pp=curvs[i].pp;
			long f2=-1,g2=-1;
			for(std::list<mglPoint>::const_iterator it=pp.begin(); it != pp.end(); ++it)
			{
				mglPoint p=*it,q(p.y,-p.x);
				long f1 = f2;	f2 = gr->AddPnt(p,c,q);	p.z+=dv;
				long g1 = g2;	g2 = gr->AddPnt(p,c,q);
				gr->quad_plot(f1,g1,f2,g2);
			}
		}
	}
}
Пример #12
0
//-----------------------------------------------------------------------------
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();
}
Пример #13
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_subplot_d(HMGL gr, int nx,int ny,int m,const char *style,double dx,double dy)
{
	double x1,x2,y1,y2;
	int mx = m%nx, my = m/nx;
	if(gr->get(MGL_AUTO_FACTOR))	{	dx /= 1.55;	dy /= 1.55;	}
	else	{	dx /= 2;	dy /= 2;	}
	x1 = (mx+dx)/nx;		x2 = (mx+1+dx)/nx;
	y2 = 1.f-(my+dy)/ny;	y1 = 1.f-(my+1+dy)/ny;
	mglCanvas *g = dynamic_cast<mglCanvas *>(gr);
	if(g)	g->InPlot(x1,x2,y1,y2,style);
}
Пример #14
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_tricont_xyzcv(HMGL gr, HCDT v, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt)
{
	mglDataV zz(x->GetNx(),x->GetNy());
	if(!z)	z = &zz;
	if(mgl_check_trig(gr,nums,x,y,z,a,"TriCont"))	return;

	gr->SaveState(opt);
	static int cgid=1;	gr->StartGroup("TriCont",cgid++);
	int text=0;
	if(mglchr(sch,'t'))	text=1;
	if(mglchr(sch,'T'))	text=2;
	bool fixed=(mglchr(sch,'_')) || (gr->Min.z==gr->Max.z);
	long s=gr->AddTexture(sch);
	gr->SetPenPal(sch);

	for(long k=0;k<v->GetNx();k++)
	{
		mreal v0 = v->v(k);		zz.Fill(fixed ? gr->Min.z : v0);
		mgl_draw_curvs(gr,v0,gr->GetC(s,v0),text,mgl_get_curvs(gr,mgl_tri_lines(v0,nums,a,x,y,fixed?&zz:z)));
	}
}
Пример #15
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_contf_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)
{
	long n=a->GetNx(),m=a->GetNy();
	if(n<2 || m<2)	{	gr->SetWarn(mglWarnLow,"ContFY");	return;	}
	gr->SaveState(opt);
	if(mgl_isnan(sv))	sv = gr->GetOrgY('y');
	if(sv<gr->Min.y || sv>gr->Max.y)	{	gr->SetWarn(mglWarnSlc,"ContFY");	gr->LoadState();	return;	}
	static int cgid=1;	gr->StartGroup("ContFY",cgid++);
	mglDataV xx,yy,zz;	mglData aa;
	long ss=gr->AddTexture(sch);

	a = fill_slice_y(gr,sv,a,xx,yy,zz,aa);
#pragma omp parallel for
	for(long i=0;i<v->GetNx()-1;i++)
	{
		mreal v0 = v->v(i);
		mgl_contf_gen(gr,v0,v->v(i+1),a,&xx,&yy,&zz,gr->GetC(ss,v0),0);
	}
	gr->EndGroup();
}
Пример #16
0
/// Draw a semi-transparent cloud for 3d data specified parametrically
void mgl_cloud_xyz(HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a,
			const char *sch, mreal alpha)
{	if(gr && a && x && y && z)	gr->Cloud(*x, *y, *z, *a, sch, alpha);	}
Пример #17
0
/// Draw several isosurface for 3d data
void mgl_surf3(HMGL gr, const HMDT a, const char *sch, int num)
{	if(gr && a)	gr->Surf3(*a, sch, num);	}
Пример #18
0
/// Draw several isosurface for 3d data specified parametrically
void mgl_surf3_xyz(HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *sch, int num)
{	if(gr && a && x && y && z)	gr->Surf3(*x, *y, *z, *a, sch, num);	}
Пример #19
0
/// Draw isosurface for 3d data
void mgl_surf3_val(HMGL gr, mreal Val, const HMDT a, const char *sch)
{	if(gr && a)	gr->Surf3(Val, *a, sch);	}
Пример #20
0
//-----------------------------------------------------------------------------
//		3D plotting functions
//-----------------------------------------------------------------------------
/// Draw isosurface for 3d data specified parametrically
void mgl_surf3_xyz_val(HMGL gr, mreal Val, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *sch)
{	if(gr && a && x && y && z)	gr->Surf3(Val, *x, *y, *z, *a, sch);	}
Пример #21
0
/// Draw several isosurface for 3d data \a a with color proportional to \a b
void mgl_surf3c(HMGL gr, const HMDT a, const HMDT b, const char *sch, int num)
{	if(gr && a && b)	gr->Surf3C(*a, *b, sch, num);	}
Пример #22
0
/// Draw isosurface for 3d data \a a with color proportional to \a b
void mgl_surf3c_val(HMGL gr, mreal Val, const HMDT a, const HMDT b, const char *sch)
{	if(gr && a && b)	gr->Surf3C(Val, *a, *b, sch);	}
Пример #23
0
//-----------------------------------------------------------------------------
//
//	TriPlot series
//
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_triplot_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt)
{
	long n = x->GetNx(), m = nums->GetNy();
	if(mgl_check_trig(gr,nums,x,y,z,a,"TriPlot"))	return;

	long ss=gr->AddTexture(sch);
	gr->SaveState(opt);	gr->SetPenPal("-");
	static int cgid=1;	gr->StartGroup("TriPlot",cgid++);

	bool wire = mglchr(sch,'#');
	long nc = a->GetNx();
	if(nc!=n && nc>=m)	// colors per triangle
	{
		mglPoint p1,p2,p3,q;
		gr->Reserve(m*3);
		for(long i=0;i<m;i++)
		{
			register long k1 = long(nums->v(0,i)+0.5);
			p1 = mglPoint(x->v(k1), y->v(k1), z->v(k1));
			register long k2 = long(nums->v(1,i)+0.5);
			p2 = mglPoint(x->v(k2), y->v(k2), z->v(k2));
			register long k3 = long(nums->v(2,i)+0.5);
			p3 = mglPoint(x->v(k3), y->v(k3), z->v(k3));
			q = wire ? mglPoint(NAN,NAN) : (p2-p1) ^ (p3-p1);
			k1 = gr->AddPnt(p1,gr->GetC(ss,a->v(k1)),q);
			k2 = gr->AddPnt(p2,gr->GetC(ss,a->v(k2)),q);
			k3 = gr->AddPnt(p3,gr->GetC(ss,a->v(k3)),q);
			gr->trig_plot(k1,k2,k3);
		}
	}
	else if(nc>=n)		// colors per point
	{
		gr->Reserve(n);
		long *kk = new long[n];
		mglPoint *pp = new mglPoint[n];
		for(long i=0;i<m;i++)	// add averaged normales
		{
			register long k1 = long(nums->v(0,i)+0.5);
			register long k2 = long(nums->v(1,i)+0.5);
			register long k3 = long(nums->v(2,i)+0.5);
			if(!wire)
			{
				mglPoint q = mglPoint(x->v(k2)-x->v(k1), y->v(k2)-y->v(k1), z->v(k2)-z->v(k1)) ^
					mglPoint(x->v(k3)-x->v(k1), y->v(k3)-y->v(k1), z->v(k3)-z->v(k1));
				q.Normalize();
				// try be sure that in the same direction ...
				if(q.z<0)	q *= -1;
				pp[k1] += q;	pp[k2] += q;	pp[k3] += q;
			}
			else	pp[k1]=pp[k2]=pp[k3]=mglPoint(NAN,NAN);
		}
		for(long i=0;i<n;i++)	// add points
			kk[i] = gr->AddPnt(mglPoint(x->v(i), y->v(i), z->v(i)), gr->GetC(ss,a->v(i)), pp[i]);
		for(long i=0;i<m;i++)	// draw triangles
		{
			register long k1 = long(nums->v(0,i)+0.5);
			register long k2 = long(nums->v(1,i)+0.5);
			register long k3 = long(nums->v(2,i)+0.5);
			if(wire)
			{
				gr->line_plot(kk[k1],kk[k2]);	gr->line_plot(kk[k1],kk[k3]);
				gr->line_plot(kk[k3],kk[k2]);
			}
			else	gr->trig_plot(kk[k1],kk[k2],kk[k3]);
		}
		delete []kk;	delete []pp;
	}
	gr->EndGroup();
}
Пример #24
0
/// Draw a semi-transparent cloud for 3d data
void mgl_cloud(HMGL gr, const HMDT a, const char *sch, mreal alpha)
{	if(gr && a)	gr->Cloud(*a, sch, alpha);	}
Пример #25
0
/// Draw isosurface for 3d data \a a specified parametrically with color proportional to \a b
void mgl_surf3c_xyz_val(HMGL gr, mreal Val, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT b, const char *sch)
{	if(gr && a && b && z && x && y)	gr->Surf3C(Val, *x, *y, *z, *a, *b, sch);	}
Пример #26
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_quadplot_xy(HMGL gr, HCDT nums, HCDT x, HCDT y, const char *sch, const char *opt)
{
	gr->SaveState(opt);
	mglData z(x->GetNx());	z.Fill(gr->Min.z,gr->Min.z);
	mgl_quadplot_xyzc(gr,nums,x,y,&z,&z,sch,0);
}
Пример #27
0
/// Draw several isosurface for 3d data \a a specified parametrically with color proportional to \a b
void mgl_surf3c_xyz(HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT b, const char *sch, int num)
{	if(gr && a && b && z && x && y)	gr->Surf3C(*x, *y, *z, *a, *b, sch, num);	}
Пример #28
0
//-----------------------------------------------------------------------------
//
//	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();
}
Пример #29
0
/// Draw several isosurfaces for 3d beam in curvilinear coordinates
void mgl_beam(HMGL gr, const HMDT tr, const HMDT g1, const HMDT g2, const HMDT a, mreal r,
		const char *stl, int norm, int num)
{	if(gr && tr && g1 && g2 && a)	gr->Beam(*tr,*g1,*g2,*a,r,stl,norm,num);	}
Пример #30
0
//-----------------------------------------------------------------------------
void MGL_EXPORT mgl_data_grid(HMGL gr, HMDT d, HCDT xdat, HCDT ydat, HCDT zdat, const char *opt)
{
	gr->SaveState(opt);
	mgl_data_grid_xy(d,xdat,ydat,zdat,gr->Min.x,gr->Max.x,gr->Min.y,gr->Max.y);
	gr->LoadState();
}