/* This file is part of the Neper software package. */
/* Copyright (C) 2003-2014, Romain Quey. */
/* See the COPYING file in the top-level directory. */

#include "net_tess2d_.h"

int
net_tess2d (struct TESS PTess, int cell,
            struct SEEDSET SeedSet, int TessId,
	    struct TESS *pTess, int verbosity)
{
  int id, status;
  struct TESS T2;

  neut_tess_set_zero (&T2);

  net_tess3d (PTess, cell, SeedSet, TessId, pTess, verbosity);

  neut_tess_init_domain_poly (pTess, PTess, cell, NULL, NULL, NULL);

  status = neut_tess_domface_label_id (*pTess, "z0", &id);

  if (status != 0)
    ut_error_reportbug ();

  neut_tess_domface_tess (*pTess, id, &T2);
  neut_tess_tess (T2, pTess);
  neut_tess_free (&T2);

#ifdef HAVE_DEBUGGING
  if (neut_tess_test (*pTess, 0) != 0 || neut_tess_test_dom (*pTess, 0) != 0)
    ut_print_message (2, 2, "The tessellation is not valid.\n");
#endif

  return 0;
}
