Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_NAIVE_PATCHER_H
00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_UTIL_POLYMESH_NAIVE_PATCHER_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/geometry/geometry_plane.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace polymesh
00017 {
00018
00019 template< typename mesh_type >
00020 bool naive_patcher( mesh_type & mesh)
00021 {
00022 typedef typename mesh_type::halfedge_iterator halfedge_iterator;
00023 typedef typename mesh_type::halfedge_type halfedge_type;
00024 typedef typename mesh_type::vertex_handle vertex_handle;
00025 typedef typename mesh_type::index_type index_type;
00026
00027 typedef std::list< vertex_handle > ring_type;
00028 typedef std::list< ring_type > ring_container;
00029 typedef typename ring_container::iterator ring_iterator;
00030
00031 ring_container rings;
00032
00033
00034 mesh::clear_halfedge_tags(mesh);
00035
00036 halfedge_iterator h = mesh.halfedge_begin();
00037 halfedge_iterator hend = mesh.halfedge_end();
00038 for(;h!=hend;++h)
00039 {
00040 if(h->m_tag == 1)
00041 continue;
00042
00043 if(is_boundary(*h))
00044 {
00045 rings.push_back(ring_type());
00046 ring_type & ring = rings.back();
00047 halfedge_type * loop = &(*h);
00048 halfedge_type * first = loop;
00049 do
00050 {
00051 assert(loop->m_tag==1 || !"Oh we saw this halfedge before?");
00052 assert(is_boundary(*loop) || !"Oh, this edge must be a boundary, but it was not?");
00053 loop->m_tag=1;
00054 ring.push_back(loop->get_destination_handle());
00055 loop = &(*(loop->get_next_iterator()));
00056 }while(loop!=first);
00057 }
00058 else
00059 {
00060 h->m_tag=1;
00061 }
00062 }
00063
00064
00065 std::size_t N = rings.size();
00066 if(N==0)
00067 return true;
00068
00069 ring_iterator r = rings.begin();
00070 ring_iterator rend = rings.end();
00071
00072 for(;r!=rend;++r)
00073 {
00074 if(r->size()>2)
00075 {
00076 mesh.add_face(r->begin(),r->end());
00077 }
00078 }
00079 return true;
00080 }
00081
00082 }
00083 }
00084
00085
00086 #endif