HexahedronSetGeometryAlgorithms.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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 ) const
00042 {
00043
00044
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 ) const
00051 {
00052
00053
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
00062
00063 for(int i=0; i<this->m_topology->getNbHexas(); ++i)
00064 {
00065
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 }
00137
00138 }
00139
00140 }
00141
00142 #endif // SOFA_COMPONENTS_HexahedronSetTOPOLOGY_INL