// FICHIER : Enum_type_geom.cp


// This file is part of the Herezh++ application.
//
// The finite element software Herezh++ is dedicated to the field
// of mechanics for large transformations of solid structures.
// It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600)
// INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) <https://www.irdl.fr/>.
//
// Herezh++ is distributed under GPL 3 license ou ultérieure.
//
// Copyright (C) 1997-2021 Université Bretagne Sud (France)
// AUTHOR : Gérard Rio
// E-MAIL  : gerardrio56@free.fr
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// For more information, please consult: <https://herezh.irdl.fr/>.


#include "Enum_type_geom.h"


# include <iostream>
using namespace std;  //introduces namespace std
#include <stdlib.h>
#include "Sortie.h"
//#ifdef SYSTEM_MAC_OS_X
//  #include <stringfwd.h> // a priori ce n'est pas portable
//#el
#if defined  SYSTEM_MAC_OS_CARBON
  #include <stringfwd.h> // a priori ce n'est pas portable
#else  
  #include <string.h> // pour le flot en memoire centrale
#endif
#include <string>



string Nom_type_geom (const Enum_type_geom id_type_geom)
// Retourne le nom de la geometrie correspondant a l'identificateur 
// de type enumere id_type_geom
{
	
	string result;
	switch (id_type_geom)
	{   case RIEN_TYPE_GEOM : result="RIEN_TYPE_GEOM"; break;
		case POINT_G : result="POINT_G"; break;
		case LIGNE : result="LIGNE"; break;
		case SURFACE : result="SURFACE"; break;
		case VOLUME : result="VOLUME"; break;
		default :
			cout << "\nErreur : valeur incorrecte du type Enum_type_geom !\n";
			cout << "Nom_type_geom(Enum_type_geom ) \n";
			Sortie(1);
	};
	return result;
	
};
						
Enum_type_geom Id_nom_type_geom (const string& nom_type_geom)
// Retourne la variable de type enumere associe au nom
// de geometrie nom_type_geom
{
	
	Enum_type_geom result;
	if ( nom_type_geom == "RIEN_TYPE_GEOM" ) result=RIEN_TYPE_GEOM;
	else if ( nom_type_geom == "POINT_G" ) result=POINT_G;
	else if ( nom_type_geom == "LIGNE" ) result=LIGNE;
	else if ( nom_type_geom == "SURFACE" ) result=SURFACE;
	else if ( nom_type_geom == "VOLUME" ) result=VOLUME;
	else
	{   cout << "\nErreur : nom de geometrie '" <<nom_type_geom <<  " 'inconnu !\n";
		cout << "Id_nom_type_geom(string ) \n";
		Sortie(1);
	};
	return result;
	
};
	
// surcharge de la lecture
istream & operator >> (istream & entree, Enum_type_geom & result)
 { string nom_type_geom;
   entree >> nom_type_geom;
   result = Id_nom_type_geom ( nom_type_geom);
   return entree;
 };  

   	   
   // surcharge de l'operator d'ecriture
ostream & operator << (ostream & sort, const Enum_type_geom& a)
    { // on ecrit la forme caractère
       sort << Nom_type_geom(a) << " ";
       return sort;      
     }; 

