The last common thing which I want to show in this section is how one can cut off points from plot. There are 4 mechanism for that.
SetCut
function. As result all points out of bounding box will be omitted.
SetCutBox
function. All points inside this box will be omitted.
SetCutOff
function. All points for which the value of formula is nonzero will be omitted. Note, that this is the slowest variant.
Below I place the code which demonstrate last 3 possibilities:
int sample(mglGraph *gr) { mglData a,c,v(1); mgls_prepare2d(&a); mgls_prepare3d(&c); v.a[0]=0.5; gr->SubPlot(2,2,0); gr->Title("Cut on (default)"); gr->Rotate(50,60); gr->Light(true); gr->Box(); gr->Surf(a,"","zrange -1 0.5"); gr->SubPlot(2,2,1); gr->Title("Cut off"); gr->Rotate(50,60); gr->Box(); gr->Surf(a,"","zrange -1 0.5; cut off"); gr->SubPlot(2,2,2); gr->Title("Cut in box"); gr->Rotate(50,60); gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); gr->Alpha(true); gr->Box(); gr->Surf3(c); gr->SetCutBox(mglPoint(0), mglPoint(0)); // switch it off gr->SubPlot(2,2,3); gr->Title("Cut by formula"); gr->Rotate(50,60); gr->CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)"); gr->Box(); gr->Surf3(c); gr->CutOff(""); // switch it off return 0; }