3D cube with 1D-Line in the middle

Sebastian,
you can also define the curve as a parametric curve instead of using an external file:

load "msh3"
load "tetgen"

mesh3 Th=cube(2,2,2);// Define the mesh without the curve

real[int] xc(Th.nv),yc(Th.nv),zc(Th.nv);
for (int i=0;i<Th.nv;i++){//save the coordinates of the vertices of the mesh
 xc(i)=Th(i).x;
 yc(i)=Th(i).y;
 zc(i)=Th(i).z;
}


border curv(t=0.,1.){x=t+0.1*cos(2.*pi*t);y=t+0.1*sin(2.*pi*t);z=t;}//define a parametric curve
int nbpts=5;//number of points on the curve
meshL ThL=buildmeshL(curv(nbpts-1));// build the 1d mesh of the curve
//plot(ThL,wait=1);

real[int] ptsx(nbpts);// coordinate x of points on the curve
real[int] ptsy(nbpts);// coordinate y of points on the curve
real[int] ptsz(nbpts);// coordinate z of points on the curve
for (int i=0;i<nbpts;i++){
 ptsx(i)=ThL(i).x;
 ptsy(i)=ThL(i).y;
 ptsz(i)=ThL(i).z;
}
cout << "ptsx " << ptsx << endl << " ptsy " << ptsy << endl << " ptsz " << ptsz << endl;

xc.resize(Th.nv+nbpts);
yc.resize(Th.nv+nbpts);
zc.resize(Th.nv+nbpts);
for (int j=0;j<nbpts;j++){//complete the set of vertices with the points of the curve
 xc(Th.nv+j)=ptsx(j);
 yc(Th.nv+j)=ptsy(j);
 zc(Th.nv+j)=ptsz(j);
}
Th=tetgconvexhull(xc,yc,zc);//rebuild the mesh with this extended set of vertices
plot(Th,wait=1);
//savemesh(Th,"Th.mesh");

int[int] indpts(nbpts);//array giving the indices of the curve points as vertices of the 3d mesh
for (int i=0;i<Th.nv;i++){
 for (int j=0;j<nbpts;j++){
  if ((abs(Th(i).x-ptsx(j))<1.e-8)&&(abs(Th(i).y-ptsy(j))<1.e-8)&&(abs(Th(i).z-ptsz(j))<1.e-8)){
   indpts(j)=Th(i);
  }
 }
}
cout << "indpts " << indpts << endl;