// GenTextile - A composite textile generator
// Copyright (C) 2011-2026 Eric Bechet, Frederic Duboeuf
//
// See the LICENSE file for license information and contributions.
// Please report all bugs and problems to <bechet@cadxfem.org> or <duboeuf@outlook.com>.


#include <cstring>
#include <cstdio>
#include <fstream>

#include "genTextile.h"


TSolver::~TSolver()
{
  if (tisse) delete tisse;
}

void TSolver::CheckProperties()
{
  tisse = new Tisse(DataT->T->Scalars["Epaisseur"], DataT->T->Scalars["DimChaine"], DataT->T->Scalars["DimTrame"], DataT->T->Vectors["AxeChaine"], DataT->T->Vectors["AxeTrame"]);
  tisse->analyseStructure(DataT->T->Integers["Layer"], DataT->T->Tensors["Structure"], DataT->T->Vectors["MultipChaine"]);
  tisse->genereTisse(DataT->T->Integers["Nbdx"], DataT->T->Integers["Nbdyz"]);

//   fils.resize(tisse->getNbBuckets());
//   for (int i=0; i<fils.size(); i++)
//     fils[i] = new gLevelsetFils(this, i, tag+i);
}

void TSolver::readInputFile ( const std::string &fileName )
{
  modelname = fileName;
  std::cout<<"model name : " << modelname << std::endl;
  DataT->readInputFile(fileName);
  CheckProperties();
  printf("--> %s Textile \n", DataT->T->name.c_str());
}

void TSolver::exportT( const std::string &fileName  )
{
  std::string name = fileName.substr(0,fileName.size()-4);
  tisse->printTisseGeo(name);
  tisse->printTisseGeoSurf(name);
  tisse->printLsNodes(name);
  tisse->printLsNodesByFils(name);
}
