HexahedronSetGeometryAlgorithms.inl

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 :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 #ifndef SOFA_COMPONENT_TOPOLOGY_HEXAHEDRONSETGEOMETRYALGORITHMS_INL
00026 #define SOFA_COMPONENT_TOPOLOGY_HEXAHEDRONSETGEOMETRYALGORITHMS_INL
00027 
00028 #include <sofa/component/topology/HexahedronSetGeometryAlgorithms.h>
00029 
00030 namespace sofa
00031 {
00032 
00033 namespace component
00034 {
00035 
00036 namespace topology
00037 {
00038     using namespace sofa::defaulttype;
00039 
00040     template< class DataTypes>
00041     typename DataTypes::Real HexahedronSetGeometryAlgorithms< DataTypes >::computeHexahedronVolume( const unsigned int /*i*/) const 
00042     {
00043         //const Hexahedron &t = this->m_topology->getHexa(i);
00044         //const VecCoord& p = *(this->object->getX());
00045         Real volume=(Real)(0.0); 
00046         return volume;
00047     }
00048 
00049     template< class DataTypes>
00050     typename DataTypes::Real HexahedronSetGeometryAlgorithms< DataTypes >::computeRestHexahedronVolume( const unsigned int /*i*/) const 
00051     {
00052         //const Hexahedron &t = this->m_topology->getHexa(i);
00053         //const VecCoord& p = *(this->object->getX0());
00054         Real volume=(Real)(0.0); 
00055         return volume;
00056     }
00057 
00058     template<class DataTypes>
00059     void HexahedronSetGeometryAlgorithms<DataTypes>::computeHexahedronVolume( BasicArrayInterface<Real> &ai) const
00060     {
00061         //const sofa::helper::vector<Hexahedron> &ta=this->m_topology->getHexas();
00062         //const typename DataTypes::VecCoord& p = *(this->object->getX());
00063         for(int i=0; i<this->m_topology->getNbHexas(); ++i)
00064         {
00065             //const Hexahedron &t=this->m_topology->getHexa(i); //ta[i];
00066             ai[i]=(Real)(0.0); 
00067         }
00068     }
00069 
00071     template <typename DataTypes>
00072     void HexahedronSetGeometryAlgorithms<DataTypes>::writeMSHfile(const char *filename)                    
00073     {
00074         std::ofstream myfile;                    
00075         myfile.open (filename);      
00076 
00077         const typename DataTypes::VecCoord& vect_c = *(this->object->getX());    
00078 
00079         const unsigned int numVertices = vect_c.size();      
00080 
00081         myfile << "$NOD\n";      
00082         myfile << numVertices <<"\n";    
00083 
00084         for(unsigned int i=0; i<numVertices; ++i)    
00085         {    
00086              double x = (double) vect_c[i][0];   
00087              double y = (double) vect_c[i][1];   
00088              double z = (double) vect_c[i][2];   
00089 
00090              myfile << i+1 << " " << x << " " << y << " " << z <<"\n";   
00091         }    
00092 
00093         myfile << "$ENDNOD\n";   
00094         myfile << "$ELM\n";      
00095 
00096         const sofa::helper::vector<Hexahedron> hea = this->m_topology->getHexas();   
00097 
00098         myfile << hea.size() <<"\n";     
00099 
00100         for(unsigned int i=0; i<hea.size(); ++i)     
00101         {    
00102              myfile << i+1 << " 5 1 1 8 " << hea[i][4]+1 << " " << hea[i][5]+1 << " "    
00103                                                                       << hea[i][1]+1 << " " << hea[i][0]+1 << " "    
00104                                                                       << hea[i][7]+1 << " " << hea[i][6]+1 << " "    
00105                                                                       << hea[i][2]+1 << " " << hea[i][3]+1 << "\n";      
00106         }    
00107 
00108         myfile << "$ENDELM\n";   
00109 
00110         myfile.close();      
00111     }
00112 
00114     template<typename real>
00115     inline real tripleProduct(const Vec<3,real>& a, const Vec<3,real>& b,const Vec<3,real> &c)
00116     {
00117         return dot(a,cross(b,c));
00118     }
00119 
00121     template <typename real>
00122     inline real tripleProduct(const Vec<2,real>& , const Vec<2,real>& , const Vec<2,real> &)
00123     {
00124         assert(false);
00125         return (real)0;
00126     }
00127 
00129     template <typename real>
00130     inline real tripleProduct(const Vec<1,real>& , const Vec<1,real>& , const Vec<1,real> &)
00131     {
00132         assert(false);
00133         return (real)0;
00134     }
00135 
00136 } // namespace topology
00137 
00138 } // namespace component
00139 
00140 } // namespace sofa
00141 
00142 #endif // SOFA_COMPONENTS_HexahedronSetTOPOLOGY_INL

Generated on Sun Nov 23 03:44:02 2008 for Sofa by  doxygen 1.5.7.1