00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_TRIMESH_UTIL_TRIMESH_COMPUTE_FACE_NORMAL_H 00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_TRIMESH_UTIL_TRIMESH_COMPUTE_FACE_NORMAL_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 #include <OpenTissue/core/containers/mesh/trimesh/trimesh_face.h> 00013 00014 namespace OpenTissue 00015 { 00016 namespace trimesh 00017 { 00018 template<typename mesh_type,typename vector3_type> 00019 void compute_face_normal(TriMeshFace<mesh_type> const & f, vector3_type & normal) 00020 { 00021 typedef typename mesh_type::vertex_iterator vertex_iterator; 00022 vertex_iterator v0 = f.get_vertex0_iterator(); 00023 vertex_iterator v1 = f.get_vertex1_iterator(); 00024 vertex_iterator v2 = f.get_vertex2_iterator(); 00025 vector3_type u1 = v1->m_coord - v0->m_coord; 00026 vector3_type u2 = v2->m_coord - v1->m_coord; 00027 normal = unit( cross(u1, u2) ); 00028 } 00029 00030 } // namespace trimesh 00031 } // namespace OpenTissue 00032 00033 //OPENTISSUE_CORE_CONTAINERS_MESH_TRIMESH_UTIL_TRIMESH_COMPUTE_FACE_NORMAL_H 00034 #endif