Hi !
Yes, if you have an ordered array of vertex coordinates, namely
(vx_0,vy_0),(vx_1,vy_1),...,(vx_n,vy_n)
where (vx_0,vy_0)==(vx_n,vy_n)
in order to ensure that the loop is closed, you can reconstruct the loop (the border) as piecewise linear plane curve which has these vertices and in that order using border(...)
and buildmesh(...)
.
I cannot really find this in the documentation but I am sure I saw it somewhere (maybe somewhere in the examples
in installation). Anyway, minimal working example might be something like
int nn=10;
real[int,int] vtxCoords(nn,nn); // double array of (x,y) vertex coordinates
// e.g., equidisntant points on circle (note, positive orientation)
for(int k=0; k<nn-1; ++k){
vtxCoords(0,k) = cos(k*2*pi/(nn-1));
vtxCoords(1,k) = sin(k*2*pi/(nn-1));
}
// to ensure loop is closed
vtxCoords(0,nn-1)=vtxCoords(0,0);
vtxCoords(1,nn-1)=vtxCoords(1,0);
border bdry(t=0,vtxCoords.n-1){ P.x=vtxCoords(0,t); P.y=vtxCoords(1,t); label=1; };
plot(bdry(vtxCoords.n-1),dim=2,wait=1,cmm="boundary");
mesh Th = buildmesh(bdry(vtxCoords.n-1),fixedborder=true);
plot(Th,wait=1,cmm="mesh");
Note that you have to ensure positive orientation. FYI, in border(...){...}
, you can also add P.z=...
if dealing with space curves, otherwise, P.z=0
is assumed.
if