With the attached “myFilename.C” file, try:
root [0] .L myFilename.C++
Try also: [code]#include “TSystem.h”
#include “TCanvas.h”
#include “TPad.h”
#include “TRandom.h”
#include “TGraph2D.h”
#include “TH2.h”
#include “TPolyLine3D.h”
void trial(void) {
Int_t i, j;
Double_t x, y, z;
TCanvas *c1 = new TCanvas(“c1”);
c1 = c1; // get rid of the warning: unused variable ‘c1’
Int_t m = 100;
TGraph2D *g2 = new TGraph2D(m);
g2->SetTitle(“TGraph2D and TPolyLine3D”);
// c1->cd();
g2->Draw(“surf4”);
// gPad->Modified(); gPad->Update();
Int_t n = 2;
TPolyLine3D *l = ((TPolyLine3D *)0);
for (j = 0; j < 100; j++) {
#if 0 /* 0 or 1 /
delete l; // delete the “previous” one
#endif / 0 or 1 */
g2->GetHistogram()->Reset("M"); // full reset of the Delaunay histogram
for (i = 0; i < m; i++) {
gRandom->Rannor(x, y);
z = x*x + y*y;
g2->SetPoint(i, x, y, z);
} // for (i ...
l = new TPolyLine3D(n);
for (i = 0; i < n; i++) {
x = 2.0 * gRandom->Rndm();
y = 2.0 * gRandom->Rndm();
z = 2.0 * gRandom->Rndm();
l->SetPoint(i, x, y, z);
} // for (i ...
// c1->cd();
l->Draw();
gPad->Modified(); gPad->Update();
gSystem->Sleep(100); // 100 ms delay
} // for (j …
} // void trial(void) …[/code]
myFilename.C (5.85 KB)