Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_T4_GPU_SCAN_T4_GPU_SCAN_COMPUTE_OBB_SHELL_H
00002 #define OPENTISSUE_CORE_GEOMETRY_T4_GPU_SCAN_T4_GPU_SCAN_COMPUTE_OBB_SHELL_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/geometry/geometry_local_triangle_frame.h>
00013 #include <OpenTissue/core/containers/mesh/common/util/mesh_compute_angle_weighted_vertex_normals.h>
00014
00015 #include <cassert>
00016
00017 namespace OpenTissue
00018 {
00019 namespace detail
00020 {
00021
00038 template<typename surface_mesh,typename volume_mesh,typename point_container, typename lut_container>
00039 inline void compute_obb_shell(
00040 surface_mesh & surface
00041 , double const & thickness
00042 , volume_mesh & shell
00043 , point_container & points
00044 , lut_container & lut
00045 )
00046 {
00047 typedef typename volume_mesh::node_iterator node_iterator;
00048 typedef typename volume_mesh::tetrahedron_iterator tetrahedron_iterator;
00049 typedef typename surface_mesh::face_iterator face_iterator;
00050 typedef typename surface_mesh::vertex_iterator vertex_iterator;
00051 typedef typename surface_mesh::face_vertex_circulator face_vertex_circulator;
00052 typedef typename surface_mesh::face_type face_type;
00053
00054 typedef typename surface_mesh::math_types math_types;
00055 typedef typename math_types::vector3_type vector3_type;
00056
00057 shell.clear();
00058 points.clear();
00059 lut.clear();
00060
00061 size_t cnt_max_tetrahedra = 5*surface.size_faces();
00062
00063 lut.resize(cnt_max_tetrahedra);
00064
00065 OpenTissue::geometry::LocalTriangleFrame<vector3_type> local_frame;
00066
00067 face_iterator f_end = surface.face_end();
00068 face_iterator f = surface.face_begin();
00069 for(;f!=f_end;++f)
00070 {
00071 assert(valency( *f )==3 || !"compute_obb_shell(): Only triangular faces are supported!");
00072 face_vertex_circulator v(*f);
00073 vector3_type & p0 = v->m_coord; ++v;
00074 vector3_type & p1 = v->m_coord; ++v;
00075 vector3_type & p2 = v->m_coord;
00076 local_frame.init(p0,p1,p2);
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 vector3_type c0 = local_frame.v0() - local_frame.unit_a()*thickness - local_frame.n()*thickness - local_frame.unit_h()*thickness;
00089 vector3_type c1 = local_frame.v1() + local_frame.unit_a()*thickness - local_frame.n()*thickness - local_frame.unit_h()*thickness;
00090 vector3_type c2 = local_frame.v0() - local_frame.unit_a()*thickness + local_frame.n()*thickness - local_frame.unit_h()*thickness;
00091 vector3_type c3 = local_frame.v1() + local_frame.unit_a()*thickness + local_frame.n()*thickness - local_frame.unit_h()*thickness;
00092 vector3_type c4 = local_frame.v0() - local_frame.unit_a()*thickness - local_frame.n()*thickness + local_frame.unit_h()*(thickness+local_frame.h());
00093 vector3_type c5 = local_frame.v1() + local_frame.unit_a()*thickness - local_frame.n()*thickness + local_frame.unit_h()*(thickness+local_frame.h());
00094 vector3_type c6 = local_frame.v0() - local_frame.unit_a()*thickness + local_frame.n()*thickness + local_frame.unit_h()*(thickness+local_frame.h());
00095 vector3_type c7 = local_frame.v1() + local_frame.unit_a()*thickness + local_frame.n()*thickness + local_frame.unit_h()*(thickness+local_frame.h());
00096
00097 points.push_back( c0 );
00098 points.push_back( c1 );
00099 points.push_back( c2 );
00100 points.push_back( c3 );
00101 points.push_back( c4 );
00102 points.push_back( c5 );
00103 points.push_back( c6 );
00104 points.push_back( c7 );
00105
00106 node_iterator n0 = shell.insert();
00107 node_iterator n1 = shell.insert();
00108 node_iterator n2 = shell.insert();
00109 node_iterator n3 = shell.insert();
00110 node_iterator n4 = shell.insert();
00111 node_iterator n5 = shell.insert();
00112 node_iterator n6 = shell.insert();
00113 node_iterator n7 = shell.insert();
00114
00115 tetrahedron_iterator t0 = shell.insert( n0, n4, n5, n6 );
00116 tetrahedron_iterator t1 = shell.insert( n0, n5, n1, n3 );
00117 tetrahedron_iterator t2 = shell.insert( n6, n2, n3, n0 );
00118 tetrahedron_iterator t3 = shell.insert( n7, n6, n3, n5 );
00119 tetrahedron_iterator t4 = shell.insert( n6, n5, n0, n3 );
00120
00121 lut[t0->idx()] = &(*f);
00122 lut[t1->idx()] = &(*f);
00123 lut[t2->idx()] = &(*f);
00124 lut[t3->idx()] = &(*f);
00125 lut[t4->idx()] = &(*f);
00126 }
00127 }
00128
00129 }
00130
00131 }
00132
00133
00134 #endif