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 #ifndef SOFA_CORE_COMPONENTMODEL_COLLISION_DETECTIONOUTPUT_H 00028 #define SOFA_CORE_COMPONENTMODEL_COLLISION_DETECTIONOUTPUT_H 00029 00030 #include <sofa/helper/system/config.h> 00031 #include <sofa/core/CollisionElement.h> 00032 #include <sofa/defaulttype/Vec.h> 00033 #include <sofa/helper/vector.h> 00034 #include <iostream> 00035 00036 namespace sofa 00037 { 00038 00039 namespace core 00040 { 00041 00042 namespace componentmodel 00043 { 00044 00045 namespace collision 00046 { 00047 00048 using sofa::defaulttype::Vector3; 00049 00050 // uncomment if you want to use the freePoint information 00051 #define DETECTIONOUTPUT_FREEMOTION 00052 00053 00054 00059 class DetectionOutputVector 00060 { 00061 public: 00062 virtual ~DetectionOutputVector() {} 00064 virtual void clear() = 0; 00066 virtual unsigned int size() const = 0; 00068 bool empty() const { return size()==0; } 00069 }; 00070 00071 00090 class DetectionOutput 00091 { 00092 public: 00094 std::pair<core::CollisionElementIterator, core::CollisionElementIterator> elem; 00095 typedef int64_t ContactId; 00097 ContactId id; 00099 Vector3 point[2]; 00100 #ifdef DETECTIONOUTPUT_FREEMOTION 00101 Vector3 freePoint[2]; 00102 #endif 00104 Vector3 normal; 00105 /* 00107 */ 00109 double value; 00111 double deltaT; 00112 DetectionOutput() 00113 : elem(NULL, NULL), id(0), value(0.0), deltaT(0.0) 00114 { 00115 } 00116 }; 00117 00118 00119 00124 template<class CM1, class CM2> 00125 class TDetectionOutputVector : public DetectionOutputVector, public sofa::helper::vector<DetectionOutput> 00126 { 00127 public: 00128 typedef sofa::helper::vector<DetectionOutput> Vector; 00129 virtual ~TDetectionOutputVector() {} 00131 virtual void clear() 00132 { 00133 return this->Vector::clear(); 00134 } 00136 virtual unsigned int size() const 00137 { 00138 return this->Vector::size(); 00139 } 00140 }; 00141 00142 } // namespace collision 00143 00144 } // namespace componentmodel 00145 00146 } // namespace core 00147 00148 } // namespace sofa 00149 00150 #endif
1.5.7.1