Param.cpp

Aller à la documentation de ce fichier.
00001 /*
00002  * Param.cpp : lecture des fichiers de parametres.
00003  * Copyright (C) 2007 Florence Zara, LIRIS
00004  *               florence.zara@liris.univ-lyon1.fr
00005  *               http://liris.cnrs.fr/florence.zara/
00006  *
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published
00010  * by the Free Software Foundation; either version 2.1 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00027 #include <stdlib.h>
00028 #include <stdio.h>
00029 #include <sstream>
00030 #include <string.h> 
00031 
00032 
00034 #include "Properties.h"
00035 #include "Scene.h"
00036 #include "ObjetSimule.h"
00037 
00038 
00042 #define GET_PARAM(str, var)                     \
00043   do {                                          \
00044   std::string s = Prop[str];                    \
00045   std::istringstream iss(s);                    \
00046   iss >> var;                                   \
00047   } while (0);
00048 
00049 
00050 
00051         
00055 void Scene::Param(std::string Fichier_Param)
00056 {
00058         /* Proprietes du fichier */
00059         Properties Prop;
00060         
00061         /* Chargement du fichier */
00062         Prop.load(Fichier_Param);
00063                 
00064         /* Viscosite du milieu */
00065         GET_PARAM("viscosite", _visco);
00066         
00067         /* Coordonnee de la gravite */
00068         float vargx, vargy, vargz;
00069         
00070         /* Coordonnee en x de la gravite */
00071         GET_PARAM("gx", vargx); 
00072         _g.setX(vargx);
00073         
00074         /* Coordonnee en y de la gravite */
00075         GET_PARAM("gy", vargy);
00076         _g.setY(vargy);
00077         
00078         /* Coordonnee en z de la gravite */
00079         GET_PARAM("gz", vargz);
00080         _g.setZ(vargz);
00081         
00082         /* Nombre d iterations de la boucle de simulation */
00083         GET_PARAM("nbiter", _nb_iter);
00084         
00085 }
00086 
00087 
00091 void ObjetSimule::Param_mesh(std::string Fichier_Param)
00092 {
00094         /* Proprietes du fichier */
00095         Properties Prop;
00096         
00097         /* Chargement du fichier */
00098         Prop.load(Fichier_Param);
00099         
00100         /* Fichier contenant les positions des particules */
00101         GET_PARAM("points", _Fich_Points);
00102         
00103         /* Fichier contenant les facettes du maillage */
00104         GET_PARAM("faceset", _Fich_FaceSet);
00105         
00106         /* Fichier contenant les masses du maillage */
00107         GET_PARAM("masses", _Fich_Masses);
00108         
00109         /* Intervalle de temps */
00110         GET_PARAM("dt", _delta_t);
00111         
00112         /* Raideur */
00113         GET_PARAM("k", _RessOS._Raideur);
00114         
00115         /* Amortissement */
00116         GET_PARAM("nu", _RessOS._Nu);
00117         
00118         
00119 }//void

Généré le Thu Jan 24 19:11:42 2008 pour Animation 3D par  doxygen 1.5.1