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

void
net_flatten_edge (struct MTESS MTess, struct TESS *Tess,
		  struct TESS *pFTess, struct TESSE *TessE,
		  struct FLATTEN *pFlatten)
{
  int i;

  (*pFTess).EdgeQty = 0;
  (*pFTess).EdgeVerNb = ut_alloc_1d_pint (1);

  for (i = 1; i <= MTess.TessQty; i++)
  {
    TessE[i].EdgeFEdgeQty = ut_alloc_1d_int (Tess[i].EdgeQty + 1);
    TessE[i].EdgeFEdgeNb = ut_alloc_1d_pint (Tess[i].EdgeQty + 1);
    TessE[i].EdgeFEdgeOri = ut_alloc_1d_pint (Tess[i].EdgeQty + 1);
  }

  // Body of the tessellation
  net_flatten_edge_body (MTess, Tess, pFTess, TessE, pFlatten);

  // Dom face edges: looking at the faces of the parent tessellation
  net_flatten_edge_domface (MTess, Tess, 1, pFTess, TessE, pFlatten);

  // Dom edge edges: looking at the edges of the parent tessellation
  net_flatten_edge_domedge (MTess, Tess, 1, pFTess, TessE, pFlatten);

  neut_tess_init_veredge (pFTess);
  neut_tess_init_edgelength (pFTess);

  net_flatten_edge_init_fedgetessedge (MTess, Tess, pFTess, TessE, pFlatten);

  return;
}
