load "ppm2rnm" load "isoline" string leman="garda.pgm"; real AreaLac = 368; // Km^2 real[int,int] Curves(3,1); int[int] be(1); int nc; { // build the curve file xy.txt ... real[int,int] ff1(leman); // read image and set to an rect. array // remark (0,0) is the upper, left corner. int nx = ff1.n, ny=ff1.m; // build a cartesain mesh such that the origne is qt the right place. mesh Th=square(nx-1,ny-1,[(nx-1)*(x),(ny-1)*(1-y)]); mesh Tf=Th; // warning the numbering is of the vertices (x,y) is // given by $ i = x/nx + nx* y/ny $ fespace Vh(Th,P1); Vh f1,f2; f1[]=ff1; // transforme array in finite element function. f2= min(f1, 0.25); verbosity=3; /* Usage of isoline the named parameter : iso=0.25 // value of iso close=1, // to force to have closing curve ... beginend=be, // begin and end of curve smoothing=.01, // nb of smoothing process = size^ratio * 0.01 where size is the size of the curve ... ratio=0.5 file="filename" ouptut: xx, yy the array of point of the iso value a closed curve number n is in fortran notation the point of the curve are: (xx[i],yy[i], i = i0, i1) with : i0=be[2*n], i1=be[2*n+1]; */ nc=isoline(Th,f1,iso=0.25,close=1,Curves,beginend=be,smoothing=.1,ratio=0.5); verbosity=1; } int ic0=be(0), ic1=be(1)-1; plot([Curves(0,ic0:ic1),Curves(1,ic0:ic1)],wait=1); // end smoothing the curve .... border G(t=0,1) { P=Curve(Curves,ic0,ic1,t); label=1; } //cout << " .. "<