MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/geomtype.h
Go to the documentation of this file.
00001 /************************************************************************
00002  * MechSys - Open Library for Mechanical Systems                        *
00003  * Copyright (C) 2005 Dorival M. Pedroso, Raul Durand                   *
00004  * Copyright (C) 2009 Sergio Galindo                                    *
00005  *                                                                      *
00006  * This program is free software: you can redistribute it and/or modify *
00007  * it under the terms of the GNU General Public License as published by *
00008  * the Free Software Foundation, either version 3 of the License, or    *
00009  * any later version.                                                   *
00010  *                                                                      *
00011  * This program is distributed in the hope that it will be useful,      *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
00014  * GNU General Public License for more details.                         *
00015  *                                                                      *
00016  * You should have received a copy of the GNU General Public License    *
00017  * along with this program. If not, see <http://www.gnu.org/licenses/>  *
00018  ************************************************************************/
00019 
00020 #ifndef MECHSYS_GEOMTYPE_H
00021 #define MECHSYS_GEOMTYPE_H
00022 
00023 // Std Lib
00024 #include <cstring> // for strcmp
00025 
00026 // MechSys
00027 #include <mechsys/util/string.h>
00028 #include <mechsys/util/maps.h>
00029 #include <mechsys/util/fatal.h>
00030 
00031 enum GeomType { fra_t,   
00032                 psa_t,   
00033                 pse_t,   
00034                 axs_t,   
00035                 d2d_t,   
00036                 d3d_t }; 
00037 
00038 String GTypeToStr (GeomType Type)
00039 {
00040     String info;
00041          if (Type==fra_t) info = "fra";
00042     else if (Type==psa_t) info = "psa";
00043     else if (Type==pse_t) info = "pse";
00044     else if (Type==axs_t) info = "axs";
00045     else if (Type==d2d_t) info = "d2d";
00046     else if (Type==d3d_t) info = "d3d";
00047     return info;
00048 }
00049 
00050 GeomType StrToGType (const char * Str)
00051 {
00052     GeomType gty;
00053          if (strcmp(Str,"fra")==0) gty = fra_t;
00054     else if (strcmp(Str,"psa")==0) gty = psa_t;
00055     else if (strcmp(Str,"pse")==0) gty = pse_t;
00056     else if (strcmp(Str,"axs")==0) gty = axs_t;
00057     else if (strcmp(Str,"d2d")==0) gty = d2d_t;
00058     else if (strcmp(Str,"d3d")==0) gty = d3d_t;
00059     else throw new Fatal("StrToGType: GeomType key %s is invalid",Str);
00060     return gty;
00061 }
00062 
00063 GeomType SDPairToGType (SDPair const & D, const char * Default)
00064 {
00065     GeomType gty;
00066          if (D.HasKey("fra")) gty = fra_t;
00067     else if (D.HasKey("psa")) gty = psa_t;
00068     else if (D.HasKey("pse")) gty = pse_t;
00069     else if (D.HasKey("axs")) gty = axs_t;
00070     else if (D.HasKey("d2d")) gty = d2d_t;
00071     else if (D.HasKey("d3d")) gty = d3d_t;
00072     else                      gty = StrToGType(Default);
00073     return gty;
00074 }
00075 
00076 #endif // MECHSYS_GEOMTYPE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines