Pipeline.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/componentmodel/collision/Pipeline.h>
00028 //#include <sofa/component/collision/DiscreteIntersection.h>
00029 //#include <sofa/simulation/tree/GNode.h>
00030 
00031 namespace sofa
00032 {
00033 
00034 namespace core
00035 {
00036 
00037 namespace componentmodel
00038 {
00039 
00040 namespace collision
00041 {
00042 //using namespace core::objectmodel;
00043 //using namespace core::componentmodel::behavior;
00044 
00045 Pipeline::Pipeline()
00046 : intersectionMethod(NULL),
00047   broadPhaseDetection(NULL),
00048   narrowPhaseDetection(NULL),
00049   contactManager(NULL),
00050   groupManager(NULL)
00051 {
00052 }
00053 
00054 Pipeline::~Pipeline()
00055 {
00056 }
00057 
00058 #if 0
00059 
00060 void Pipeline::init()
00061 {
00062     simulation::tree::GNode* root = dynamic_cast<simulation::tree::GNode*>(getContext());
00063     if(root == NULL) return;
00064     intersectionMethods.clear();
00065     root->getTreeObjects<Intersection>(&intersectionMethods);
00066     intersectionMethod = (intersectionMethods.empty() ? NULL : intersectionMethods[0]);
00067     broadPhaseDetections.clear();
00068     root->getTreeObjects<BroadPhaseDetection>(&broadPhaseDetections);
00069     broadPhaseDetection = (broadPhaseDetections.empty() ? NULL : broadPhaseDetections[0]);
00070     narrowPhaseDetections.clear();
00071     root->getTreeObjects<NarrowPhaseDetection>(&narrowPhaseDetections);
00072     narrowPhaseDetection = (narrowPhaseDetections.empty() ? NULL : narrowPhaseDetections[0]);
00073     contactManagers.clear();
00074     root->getTreeObjects<ContactManager>(&contactManagers);
00075     contactManager = (contactManagers.empty() ? NULL : contactManagers[0]);
00076     groupManagers.clear();
00077     root->getTreeObjects<CollisionGroupManager>(&groupManagers);
00078     groupManager = (groupManagers.empty() ? NULL : groupManagers[0]);
00079 
00080     if (intersectionMethod==NULL)
00081         intersectionMethod = new sofa::component::collision::DiscreteIntersection;
00082 }
00083 
00084 void Pipeline::reset()
00085 {
00086     computeCollisionReset();
00087 }
00088 
00089 void Pipeline::computeCollisionReset()
00090 {
00091     simulation::tree::GNode* root = dynamic_cast<simulation::tree::GNode*>(getContext());
00092     if(root == NULL) return;
00093     if (broadPhaseDetection!=NULL && broadPhaseDetection->getIntersectionMethod()!=intersectionMethod)
00094         broadPhaseDetection->setIntersectionMethod(intersectionMethod);
00095     if (narrowPhaseDetection!=NULL && narrowPhaseDetection->getIntersectionMethod()!=intersectionMethod)
00096         narrowPhaseDetection->setIntersectionMethod(intersectionMethod);
00097     if (contactManager!=NULL && contactManager->getIntersectionMethod()!=intersectionMethod)
00098         contactManager->setIntersectionMethod(intersectionMethod);
00099     doCollisionReset();
00100 }
00101 
00102 void Pipeline::computeCollisionDetection()
00103 {
00104     simulation::tree::GNode* root = dynamic_cast<simulation::tree::GNode*>(getContext());
00105     if(root == NULL) return;
00106     sofa::helper::vector<CollisionModel*> collisionModels;
00107     root->getTreeObjects<CollisionModel>(&collisionModels);
00108     doCollisionDetection(collisionModels);
00109 }
00110 
00111 void Pipeline::computeCollisionResponse()
00112 {
00113     simulation::tree::GNode* root = dynamic_cast<simulation::tree::GNode*>(getContext());
00114     if(root == NULL) return;
00115     doCollisionResponse();
00116 }
00117 
00118 #endif
00119 
00120 } // namespace collision
00121 
00122 } // namespace componentmodel
00123 
00124 } // namespace core
00125 
00126 } // namespace sofa
00127 

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