BaseContext.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 library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library 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 Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                              SOFA :: Framework                              *
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/core/objectmodel/BaseContext.h>
00028 #include <sofa/core/objectmodel/BaseObject.h>
00029 #include <sofa/core/componentmodel/behavior/BaseMechanicalState.h>
00030 #include <sofa/core/componentmodel/behavior/BaseMass.h>
00031 #include <sofa/core/componentmodel/topology/Topology.h>
00032 #include <sofa/core/componentmodel/topology/BaseTopology.h>
00033 #include <sofa/core/componentmodel/topology/BaseMeshTopology.h>
00034 #include <sofa/core/Shader.h>
00035 #include <iostream>
00036 using std::cerr;
00037 using std::endl;
00038 
00039 namespace sofa
00040 {
00041 
00042 namespace core
00043 {
00044 
00045 namespace objectmodel
00046 {
00047 
00048 BaseContext::BaseContext()
00049 {}
00050 
00051 BaseContext::~BaseContext()
00052 {}
00053 
00054 BaseContext* BaseContext::getDefault()
00055 {
00056     static BaseContext defaultContext;
00057     return &defaultContext;
00058 }
00059 
00061 // Parameters //
00063 
00065 bool BaseContext::isActive() const { return true;};
00066 
00068 BaseContext::Vec3 BaseContext::getLocalGravity() const
00069 {
00070     static const Vec3 G((SReal)0,(SReal)-9.81,(SReal)0);
00071     return G;
00072 }
00073 
00075 const BaseContext::Vec3& BaseContext::getGravityInWorld() const
00076 {
00077     static const Vec3 G((SReal)0,(SReal)-9.81,(SReal)0);
00078     return G;
00079 }
00080 
00082 double BaseContext::getDt() const
00083 {
00084     return 0.01;
00085 }
00086 
00088 double BaseContext::getTime() const
00089 {
00090     return 0.0;
00091 }
00092 
00094 bool BaseContext::getAnimate() const
00095 {
00096     return true;
00097 }
00098 
00100 bool BaseContext::getMultiThreadSimulation() const
00101 {
00102     return false;
00103 }
00104 
00106 bool BaseContext::getShowCollisionModels() const
00107 {
00108     return false;
00109 }
00110 
00112 bool BaseContext::getShowBoundingCollisionModels() const
00113 {
00114     return false;
00115 }
00116 
00118 bool BaseContext::getShowBehaviorModels() const
00119 {
00120     return true;
00121 }
00122 
00124 bool BaseContext::getShowVisualModels() const
00125 {
00126     return true;
00127 }
00128 
00130 bool BaseContext::getShowMappings() const
00131 {
00132     return false;
00133 }
00134 
00136 bool BaseContext::getShowMechanicalMappings() const
00137 {
00138     return false;
00139 }
00140 
00142 bool BaseContext::getShowForceFields() const
00143 {
00144     return false;
00145 }
00146 
00148 bool BaseContext::getShowInteractionForceFields() const
00149 {
00150     return false;
00151 }
00152 
00154 bool BaseContext::getShowWireFrame() const
00155 {
00156     return false;
00157 }
00158 
00160 bool BaseContext::getShowNormals() const
00161 {
00162     return false;
00163 }
00164 
00166 int BaseContext::getCurrentLevel() const
00167 {
00168     return 0;
00169 }
00170 int BaseContext::getCoarsestLevel() const
00171 {
00172     return 0;
00173 }
00174 int BaseContext::getFinestLevel() const
00175 {
00176     return 0;
00177 }
00178 // unsigned int BaseContext::nbLevels() const
00179 // {
00180 //  return getCoarsestLevel() - getFinestLevel() + 1;
00181 // }
00182 
00184 // Local Coordinates System //
00186 
00187 
00189 const BaseContext::Frame& BaseContext::getPositionInWorld() const
00190 {
00191     static const Frame f;
00192     return f;
00193 }
00194 
00196 const BaseContext::SpatialVector& BaseContext::getVelocityInWorld() const
00197 {
00198     static const SpatialVector v( Vec3(0,0,0), Vec3(0,0,0) );
00199     return v;
00200 }
00201 
00203 const BaseContext::Vec3& BaseContext::getVelocityBasedLinearAccelerationInWorld() const
00204 {
00205     static const Vec3 a(0,0,0);
00206     return a;
00207 }
00208 
00209 
00211 // Containers //
00213 
00217 void* BaseContext::getObject(const ClassInfo& /*class_info*/, SearchDirection /*dir*/) const
00218 {
00219     return NULL;
00220 }
00221 
00225 void* BaseContext::getObject(const ClassInfo& /*class_info*/, const std::string& /*path*/) const
00226 {
00227     return NULL;
00228 }
00229 
00233 void BaseContext::getObjects(const ClassInfo& /*class_info*/, GetObjectsCallBack& /*container*/, SearchDirection /*dir*/) const
00234 {
00235 }
00236 
00238 BaseObject* BaseContext::getMechanicalState() const
00239 {
00240     return this->get<sofa::core::componentmodel::behavior::BaseMechanicalState>();
00241 }
00242 
00244 BaseObject* BaseContext::getMass() const
00245 {
00246     return this->get<sofa::core::componentmodel::behavior::BaseMass>();
00247 }
00248 
00249 
00251 core::componentmodel::topology::Topology* BaseContext::getTopology() const
00252 {
00253     return this->get<sofa::core::componentmodel::topology::Topology>();
00254 }
00256 core::componentmodel::topology::BaseMeshTopology* BaseContext::getMeshTopology() const
00257 {
00258     return this->get<sofa::core::componentmodel::topology::BaseMeshTopology>();
00259 }
00260 
00262 BaseObject* BaseContext::getShader() const
00263 {
00264     return this->get<sofa::core::Shader>();
00265     return NULL;
00266 }
00267 
00269 void BaseContext::propagateEvent( Event* )
00270 {
00271     cerr<<"WARNING !!! BaseContext::propagateEvent not overloaded, does nothing"<<endl;
00272 }
00273 
00274 void BaseContext::executeVisitor( simulation::Visitor* )
00275 {
00276     cerr<<"WARNING !!! BaseContext::executeVisitor not overloaded, does nothing"<<endl;
00277     //assert(false);
00278 }
00279 
00280 
00281 } // namespace objectmodel
00282 
00283 } // namespace core
00284 
00285 } // namespace sofa
00286 

Generated on Sun Nov 23 02:29:25 2008 for Sofa by  doxygen 1.5.7.1