/* 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"neut_tess_tess_.h"

void
neut_tess_tess_gen (struct TESS TessA, struct TESS *pTessB)
{
  (*pTessB).Dim = TessA.Dim;
  (*pTessB).Level = TessA.Level;
  (*pTessB).TessId = TessA.TessId;

  if (TessA.Type)
    ut_string_string (TessA.Type, &((*pTessB).Type));

  return;
}

void
neut_tess_tess_cell (struct TESS TessA, struct TESS *pTessB)
{
  (*pTessB).CellQty = TessA.CellQty;

  if (TessA.Type)
    ut_string_string (TessA.Type, &((*pTessB).Type));

  if (TessA.CellId)
  {
    (*pTessB).CellId = ut_alloc_1d_int (TessA.CellQty + 1);
    ut_array_1d_int_memcpy ((*pTessB).CellId + 1, TessA.CellQty,
			    TessA.CellId + 1);
  }

  if (TessA.CellOri)
  {
    (*pTessB).CellOri = ut_alloc_2d (TessA.CellQty + 1, 4);
    ut_array_2d_memcpy ((*pTessB).CellOri + 1, TessA.CellQty, 4,
			    TessA.CellOri + 1);
  }

  neut_tess_tess_seedcoo (TessA, pTessB);
  neut_tess_tess_seedweight (TessA, pTessB);

  (*pTessB).ScaleQty = TessA.ScaleQty;

  if (TessA.ScaleQty > 0)
  {
    (*pTessB).ScaleQty = TessA.ScaleQty;
    (*pTessB).ScaleCell = ut_alloc_2d_int (TessA.ScaleQty,
				       TessA.CellQty + 1);
    ut_array_2d_int_memcpy ((*pTessB).ScaleCell + 1, TessA.ScaleQty - 1,
			    TessA.CellQty + 1, TessA.ScaleCell + 1);
  }

  neut_tess_tess_celltrue (TessA, pTessB);
  neut_tess_tess_cellbody (TessA, pTessB);

  return;
}

/* neut_tess_tesstializing the properties of the vertices */
void
neut_tess_tess_ver (struct TESS TessA, struct TESS *pTessB)
{
  neut_tess_tess_verqty (TessA, pTessB);
  neut_tess_tess_vercoo (TessA, pTessB);
  neut_tess_tess_veredge (TessA, pTessB);
  neut_tess_tess_verbound (TessA, pTessB);
  neut_tess_tess_verstate (TessA, pTessB);

  return;
}

/* neut_tess_tesstializing the properties of the edges */
void
neut_tess_tess_edge (struct TESS TessA, struct TESS *pTessB)
{
  neut_tess_tess_edgeqty (TessA, pTessB);
  neut_tess_tess_edgevernb (TessA, pTessB);
  if (TessA.Dim >= 2)
    neut_tess_tess_edgeface (TessA, pTessB);
  neut_tess_tess_edgelength (TessA, pTessB);
  neut_tess_tess_edgedel (TessA, pTessB);
  neut_tess_tess_edgebound (TessA, pTessB);
  neut_tess_tess_edgestate (TessA, pTessB);

  return;
}

/* neut_tess_tess initializing the properties of the faces */
void
neut_tess_tess_face (struct TESS TessA, struct TESS *pTessB)
{
  neut_tess_tess_faceqty (TessA, pTessB);
  if (TessA.Dim == 3)
    neut_tess_tess_facepoly (TessA, pTessB);
  neut_tess_tess_facever (TessA, pTessB);
  neut_tess_tess_faceedge (TessA, pTessB);
  neut_tess_tess_faceeq (TessA, pTessB);
  neut_tess_tess_facebound (TessA, pTessB);
  neut_tess_tess_facestate (TessA, pTessB);
  neut_tess_tess_facept (TessA, pTessB);

  return;
}

/* neut_tess_tess initializing the properties of the polyhedra */
void
neut_tess_tess_poly (struct TESS TessA, struct TESS *pTessB)
{
  neut_tess_tess_polyqty (TessA, pTessB);
  neut_tess_tess_polyface (TessA, pTessB);

  return;
}

/* neut_tess_tess initializing the properties of the domain */
void
neut_tess_tess_domain (struct TESS TessA, struct TESS *pTessB)
{
  neut_tess_tess_domaindata (TessA, pTessB);

  return;
}
