typedef struct {
  int            x,y,nxt;
  unsigned char  v;
} Point;
typedef Point * pPoint;
  
typedef struct {
  int    v[3],nxt,mark;
  int    adj[3];
} Tria;
typedef Tria * pTria;


/* get new point address */
int newPt(pMesh mesh,int x,int y,char tag) {
  pPoint  ppt;
  int     curpt;

  if ( !mesh->npnil )  return(0);

  curpt = mesh->npnil;
  if ( mesh->npnil > mesh->np )  mesh->np = mesh->npnil;
  ppt   = &mesh->point[curpt];
  ppt->x = x;
  ppt->y = y;
  mesh->npnil = ppt->nxt;
  ppt->nxt    = 0;

  return(curpt);
}

void delPt(pMesh mesh,int ip) {
  pPoint   ppt;

  ppt = &mesh->point[ip];
  memset(ppt,0,sizeof(Point));
  ppt->nxt    = mesh->npnil;
  mesh->npnil = ip;
  if ( ip == mesh->np )  mesh->np--;
}

/* get new triangle address */
int newElt(pMesh mesh) {
  int     curiel;

  if ( !mesh->ntnil )  return(0);

  curiel = mesh->ntnil;
  if ( mesh->ntnil > mesh->nt )  mesh->nt = mesh->ntnil;
  mesh->ntnil = mesh->tria[curiel].nxt;
  mesh->tetra[curiel].nxt = 0;

  return(curiel);
}

void delElt(pMesh mesh,int iel) {
  pTria    pt;
  int      iadr;

  pt = &mesh->tria[iel];
  memset(pt,0,sizeof(Tria));
  pt->nxt = mesh->ntnil;
  mesh->ntnil = iel;
  if ( iel == mesh->nt )  mesh->nt--;
}


/* a inserer dans main  */

    mesh->npnil = mesh->np + 1;
    mesh->ntnil = mesh->nt + 1;
    for (k=mesh->npnil; k<mesh->npmax; k++)
      mesh->point[k].nxt  = k+1;
    for (k=mesh->ntnil; k<mesh->ntmax; k++)
      mesh->tria[k].nxt = k+1;
  }
