Main.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This program is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU General Public License as published by the Free  *
00007 * Software Foundation; either version 2 of the License, or (at your option)   *
00008 * any later version.                                                          *
00009 *                                                                             *
00010 * This program is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    *
00013 * more details.                                                               *
00014 *                                                                             *
00015 * You should have received a copy of the GNU General Public License along     *
00016 * with this program; if not, write to the Free Software Foundation, Inc., 51  *
00017 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.                   *
00018 *******************************************************************************
00019 *                            SOFA :: Applications                             *
00020 *                                                                             *
00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
00024 *                                                                             *
00025 * Contact information: contact@sofa-framework.org                             *
00026 ******************************************************************************/
00027 #include <sofa/helper/ArgumentParser.h>
00028 #include <sofa/simulation/tree/Simulation.h>
00029 #include <sofa/component/contextobject/Gravity.h>
00030 #include <sofa/component/contextobject/CoordinateSystem.h>
00031 #include <sofa/component/odesolver/EulerSolver.h>
00032 #include <sofa/core/objectmodel/Context.h>
00033 #include <sofa/gui/SofaGUI.h>
00034 
00035 #include <sofa/helper/system/glut.h>
00036 using namespace sofa::simulation::tree;
00037 using sofa::component::odesolver::EulerSolver;
00038 
00039 
00040 //Using double by default, if you have SOFA_FLOAT in use in you sofa-default.cfg, then it will be FLOAT.
00041 #include <sofa/component/typedef/Sofa_typedef.h>
00042 // ---------------------------------------------------------------------
00043 // ---
00044 // ---------------------------------------------------------------------
00045 int main(int argc, char** argv)
00046 {
00047 
00048     glutInit(&argc,argv);
00049     sofa::helper::parse("This is a SOFA application.")
00050         (argc,argv);
00051     sofa::gui::SofaGUI::Init(argv[0]);
00052 
00053     // The graph root node
00054     GNode* groot = new GNode;
00055     groot->setName( "root" );
00056     groot->setGravityInWorld( Coord3(0,-10,0) );
00057     
00058     // One solver for all the graph
00059     EulerSolver* solver = new EulerSolver;
00060     solver->setName("solver");
00061     solver->f_printLog.setValue(false);
00062     groot->addObject(solver);
00063 
00064     // One node to define the particle
00065     GNode* particule_node = new GNode;
00066     particule_node->setName("particle_node");
00067     groot->addChild( particule_node );
00068 
00069     // The particule, i.e, its degrees of freedom : a point with a velocity
00070     MechanicalObject3* particle = new MechanicalObject3;
00071     particle->setName("particle");
00072     particule_node->addObject(particle);
00073     particle->resize(1);
00074     // The point
00075     (*particle->getX())[0] = Coord3(0,0,0);
00076     // The velocity
00077     (*particle->getV())[0] = Coord3(0,0,0);
00078     
00079     // Its properties, i.e, a simple mass node
00080     UniformMass3* mass = new UniformMass3;
00081     mass->setName("mass");
00082     particule_node->addObject(mass);
00083     mass->setMass( 1 );
00084 
00085     getSimulation()->init(groot);
00086     groot->setAnimate(false);
00087 
00088     //=======================================
00089     // Run the main loop
00090     sofa::gui::SofaGUI::MainLoop(groot);
00091 
00092     return 0;
00093 }

Generated on Sun Nov 23 02:28:34 2008 for Sofa by  doxygen 1.5.7.1