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

void
neut_tesl_tess_general (struct TESL Tesl, int level, int tessid, struct TESS *pTess)
{
  (*pTess).CellQty = Tesl.PolyQty;

  (*pTess).Type = ut_alloc_1d_char (strlen (Tesl.Type) + 1);
  strcpy ((*pTess).Type, Tesl.Type);

  (*pTess).Dim = 3;

  (*pTess).Level = level;
  (*pTess).TessId = tessid;

  return;
}

/* neut_tesl_tesstializing the properties of the vertices */
void
neut_tesl_tess_ver (struct TESL Tesl, struct TESS *pTess)
{
  (*pTess).VerQty = Tesl.VerQty;

  neut_tesl_tessVerCoo (Tesl, pTess);
  neut_tesl_tessVerEdge (Tesl, pTess);
  neut_tesl_tessVerState (pTess);

  return;
}

/* neut_tesl_tesstializing the properties of the edges */
void
neut_tesl_tess_edge (struct TESL Tesl, struct TESS *pTess)
{
  (*pTess).EdgeQty = Tesl.EdgeQty;

  neut_tesl_tessEdgeVerNb (Tesl, pTess);
  neut_tesl_tessEdgeFace (Tesl, pTess);
  neut_tess_init_edgelength (pTess);
  neut_tesl_tessEdgeState (pTess);
  neut_tesl_tessEdgeDel (pTess);

  return;
}

/* neut_tesl_tesstializing the properties of the faces */
void
neut_tesl_tess_face (struct TESL Tesl, struct TESS *pTess)
{
  (*pTess).FaceQty = Tesl.FaceQty;

  neut_tesl_tessFacePoly (Tesl, pTess);
  neut_tesl_tessFaceVer (Tesl, pTess);
  neut_tesl_tessFaceEdge (Tesl, pTess);
  neut_tesl_tessFaceState (pTess);
  neut_tesl_tessFacePt (pTess);
  neut_tesl_tessFaceEq (Tesl, pTess);

  return;
}

/* neut_tesl_tesstializing the properties of the polyhedra */
void
neut_tesl_tess_poly (struct TESL Tesl, struct TESS *pTess)
{
  (*pTess).PolyQty = Tesl.PolyQty;

  (*pTess).SeedCoo = ut_alloc_2d (Tesl.PolyQty + 1, 3);
  (*pTess).SeedWeight = ut_alloc_1d (Tesl.PolyQty + 1);
  (*pTess).CellTrue = ut_alloc_1d_int (Tesl.PolyQty + 1);
  (*pTess).CellBody = ut_alloc_1d_int (Tesl.PolyQty + 1);

  ut_array_2d_memcpy ((*pTess).SeedCoo, Tesl.PolyQty + 1, 3,
		      Tesl.SeedCoo);
  ut_array_1d_memcpy ((*pTess).SeedWeight, Tesl.PolyQty + 1,
		      Tesl.SeedWeight);

  neut_tesl_tessPolyFace (Tesl, pTess);

  return;
}
