45 #include <OpenMesh/Core/Mesh/PolyConnectivity.hh> 62 if (to_vertex_handle(*voh_it) == _end_vh)
94 for (++vh_it; vh_it.is_valid(); ++vh_it)
108 set_halfedge_handle(_vh, *vh_it);
120 size_t i, ii, n(_vhs_size);
122 outer_next, outer_prev,
123 boundary_next, boundary_prev,
124 patch_start, patch_end;
128 if (edgeData_.size() < n)
131 next_cache_.resize(6*n);
134 size_t next_cache_count = 0;
140 for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
144 omerr() <<
"PolyMeshT::add_face: complex vertex\n";
149 edgeData_[i].halfedge_handle =
find_halfedge(_vertex_handles[i],
150 _vertex_handles[ii]);
151 edgeData_[i].is_new = !edgeData_[i].halfedge_handle.is_valid();
152 edgeData_[i].needs_adjust =
false;
156 omerr() <<
"PolyMeshT::add_face: complex edge\n";
162 for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
164 if (!edgeData_[i].is_new && !edgeData_[ii].is_new)
166 inner_prev = edgeData_[i].halfedge_handle;
167 inner_next = edgeData_[ii].halfedge_handle;
178 boundary_prev = outer_prev;
186 if (boundary_prev == inner_prev)
188 omerr() <<
"PolyMeshT::add_face: patch re-linking failed\n";
207 next_cache_[next_cache_count++] = std::make_pair(boundary_prev, patch_start);
208 next_cache_[next_cache_count++] = std::make_pair(patch_end, boundary_next);
209 next_cache_[next_cache_count++] = std::make_pair(inner_prev, inner_next);
215 for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
216 if (edgeData_[i].is_new)
217 edgeData_[i].halfedge_handle = new_edge(_vertex_handles[i], _vertex_handles[ii]);
224 for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
226 vh = _vertex_handles[ii];
228 inner_prev = edgeData_[i].halfedge_handle;
229 inner_next = edgeData_[ii].halfedge_handle;
234 if (edgeData_[i].is_new)
id |= 1;
235 if (edgeData_[ii].is_new)
id |= 2;
251 next_cache_[next_cache_count++] = std::make_pair(boundary_prev, outer_next);
252 set_halfedge_handle(vh, outer_next);
258 next_cache_[next_cache_count++] = std::make_pair(outer_prev, boundary_next);
259 set_halfedge_handle(vh, boundary_next);
265 set_halfedge_handle(vh, outer_next);
266 next_cache_[next_cache_count++] = std::make_pair(outer_prev, outer_next);
274 next_cache_[next_cache_count++] = std::make_pair(boundary_prev, outer_next);
275 next_cache_[next_cache_count++] = std::make_pair(outer_prev, boundary_next);
281 next_cache_[next_cache_count++] = std::make_pair(inner_prev, inner_next);
291 for (i = 0; i < next_cache_count; ++i)
292 set_next_halfedge_handle(next_cache_[i].first, next_cache_[i].second);
297 if (edgeData_[i].needs_adjust)
335 {
return add_face(&_vhandles.front(), _vhandles.size()); }
341 std::vector<VertexHandle> vhandles(_vhandles.begin(), _vhandles.end());
342 return add_face(&vhandles.front(), vhandles.size());
359 bool v0v1_triangle =
false;
360 bool v1v0_triangle =
false;
391 vl = to_vertex_handle(h1);
408 vr = to_vertex_handle(h1);
416 if ( vl.
is_valid() && (vl == vr))
return false;
424 for (vv_it =
vv_iter(v0); vv_it.is_valid(); ++vv_it)
429 for (vv_it =
vv_iter(v1); vv_it.is_valid(); ++vv_it)
434 for (vv_it =
vv_iter(v0); vv_it.is_valid(); ++vv_it)
437 !(*vv_it == v_01_n && v0v1_triangle) &&
438 !(*vv_it == v_10_n && v1v0_triangle)
476 if (
status(*vv_it).
tagged() && v_01_n == v_10_n && v0v1_triangle && v1v0_triangle)
490 std::vector<FaceHandle> face_handles;
491 face_handles.reserve(8);
493 face_handles.push_back(*vf_it);
497 std::vector<FaceHandle>::iterator fh_it(face_handles.begin()),
498 fh_end(face_handles.end());
500 for (; fh_it!=
fh_end; ++fh_it)
520 if ( has_edge_status() )
526 if ( has_halfedge_status() ) {
545 std::vector<EdgeHandle> deleted_edges;
546 deleted_edges.reserve(3);
551 std::vector<VertexHandle> vhandles;
569 vhandles.push_back(to_vertex_handle(hh));
576 if (!deleted_edges.empty())
578 std::vector<EdgeHandle>::iterator del_it(deleted_edges.begin()),
579 del_end(deleted_edges.end());
583 for (; del_it!=del_end; ++del_it)
586 v0 = to_vertex_handle(h0);
591 v1 = to_vertex_handle(h1);
596 set_next_halfedge_handle(prev0, next1);
597 set_next_halfedge_handle(prev1, next0);
600 if ( has_edge_status() )
607 if ( has_halfedge_status() ) {
618 if (_delete_isolated_vertices)
622 else set_halfedge_handle(v0, next0);
631 if (_delete_isolated_vertices)
635 else set_halfedge_handle(v1, next1);
641 std::vector<VertexHandle>::iterator v_it(vhandles.begin()),
642 v_end(vhandles.end());
643 for (; v_it!=v_end; ++v_it)
687 set_vertex_handle(*vih_it, vh);
691 set_next_halfedge_handle(hp, hn);
692 set_next_halfedge_handle(op, on);
696 if (fh.
is_valid()) set_halfedge_handle(fh, hn);
697 if (fo.
is_valid()) set_halfedge_handle(fo, on);
708 if (has_halfedge_status())
742 set_face_handle(h1, fo);
753 set_halfedge_handle(fo, h1);
763 if (has_halfedge_status())
780 while (next_heh != heh0)
794 std::set<FaceHandle> nb_fhs;
797 if (nb_fhs.find(*cff_it) == nb_fhs.end())
799 nb_fhs.insert(*cff_it);
821 if (!del_fh.is_valid())
823 std::swap(del_fh, rem_fh);
825 assert(del_fh.is_valid());
837 set_next_halfedge_handle(prev_heh0, next_heh1);
838 set_next_halfedge_handle(prev_heh1, next_heh0);
845 set_halfedge_handle(vh0, next_heh0);
849 set_halfedge_handle(vh1, next_heh1);
855 set_halfedge_handle(rem_fh, prev_heh1);
859 set_halfedge_handle(rem_fh, prev_heh0);
863 set_face_handle(*fh_it, rem_fh);
875 assert_compile(
sizeof(Halfedge) ==
sizeof(Halfedge_with_prev));
877 assert(
status(_eh).deleted());
883 if (!del_fh.is_valid())
885 std::swap(del_fh, rem_fh);
887 assert(
status(del_fh).deleted());
897 set_next_halfedge_handle(prev_heh0, heh0);
898 set_prev_halfedge_handle(next_heh0, heh0);
900 set_next_halfedge_handle(prev_heh1, heh1);
901 set_prev_halfedge_handle(next_heh1, heh1);
905 set_face_handle(*fh_it, del_fh);
912 set_halfedge_handle(rem_fh, heh1);
917 set_halfedge_handle(rem_fh, heh0);
935 set_next_halfedge_handle(_prev_heh, heh0);
936 set_next_halfedge_handle(heh0, _next_heh);
937 set_next_halfedge_handle(prev_next_heh, heh1);
938 set_next_halfedge_handle(heh1, next_prev_heh);
942 set_halfedge_handle(new_fh, heh0);
945 set_face_handle(*fh_it, new_fh);
948 set_face_handle(heh1, old_fh);
951 set_halfedge_handle(old_fh, heh1);
981 set_halfedge_handle(new_fh, base_heh);
983 HalfedgeHandle new_heh = new_edge(to_vertex_handle(next_heh), start_vh);
985 set_next_halfedge_handle(base_heh, next_heh);
986 set_next_halfedge_handle(next_heh, new_heh);
987 set_next_halfedge_handle(new_heh, base_heh);
989 set_face_handle(base_heh, new_fh);
990 set_face_handle(next_heh, new_fh);
991 set_face_handle(new_heh, new_fh);
998 next_heh = next_next_heh;
1000 set_halfedge_handle(_fh, base_heh);
1002 set_next_halfedge_handle(base_heh, next_heh);
1005 set_face_handle(base_heh, _fh);
1016 for (; f_it!=f_end; ++f_it)
1028 set_next_halfedge_handle(hend, hold);
1029 set_face_handle(hold, fh);
1033 while (hh != hend) {
1038 set_halfedge_handle(fnew, hh);
1042 set_next_halfedge_handle(hnew, hold);
1043 set_next_halfedge_handle(hold, hh);
1044 set_next_halfedge_handle(hh, hnew);
1046 set_face_handle(hnew, fnew);
1047 set_face_handle(hold, fnew);
1048 set_face_handle(hh, fnew);
1055 set_next_halfedge_handle(hold, hend);
1058 set_face_handle(hold, fh);
1060 set_halfedge_handle(vh, hold);
1113 set_vertex_handle(h1, _vh);
1116 set_next_halfedge_handle(new_e, h0);
1119 set_next_halfedge_handle(ph0, new_e);
1134 set_boundary(new_e);
1146 set_halfedge_handle( _vh, h0 );
1151 set_halfedge_handle(vfrom, new_e);
Handle for a edge entity.
Handle for a face entity.
bool tagged() const
is tagged ?
bool is_manifold(VertexHandle _vh) const
Is (the mesh at) vertex _vh two-manifold ?
void split_copy(FaceHandle _fh, VertexHandle _vh)
Face split (= 1-to-n split).
SmartHalfedgeHandle next_halfedge_handle(SmartHalfedgeHandle _heh) const
returns the face handle of the opposite halfedge
void set_tagged(bool _b)
set tagged
void collapse(HalfedgeHandle _heh)
void adjust_outgoing_halfedge(VertexHandle _vh)
void delete_vertex(VertexHandle _vh, bool _delete_isolated_vertices=true)
SmartHalfedgeHandle prev_halfedge_handle(SmartHalfedgeHandle _heh) const
returns the face handle of the opposite halfedge
Handle for a halfedge entity.
void split_edge(EdgeHandle _eh, VertexHandle _vh)
FaceHandle remove_edge(EdgeHandle _eh)
VertexVertexIter vv_iter(VertexHandle _vh)
vertex - vertex circulator
FaceIter faces_begin()
Begin iterator for faces.
FaceHalfedgeIter fh_iter(FaceHandle _fh)
face - halfedge circulator
ConstVertexOHalfedgeIter cvoh_iter(VertexHandle _vh) const
const vertex - outgoing halfedge circulator
VertexFaceIter vf_iter(VertexHandle _vh)
vertex - face circulator
void collapse_loop(HalfedgeHandle _hh)
Helper for halfedge collapse.
FaceIter faces_end()
End iterator for faces.
VertexIHalfedgeIter vih_iter(VertexHandle _vh)
vertex - incoming halfedge circulator
bool is_simple_link(EdgeHandle _eh) const
Handle for a vertex entity.
ConstVertexVertexIter cvv_iter(VertexHandle _vh) const
const vertex circulator
const StatusInfo & status(VertexHandle _vh) const
Status Query API.
SmartEdgeHandle edge_handle(SmartHalfedgeHandle _heh) const
returns the face handle of the opposite halfedge
bool is_valid() const
The handle is valid iff the index is not negative.
void split(FaceHandle _fh, VertexHandle _vh)
Face split (= 1-to-n split).
void delete_edge(EdgeHandle _eh, bool _delete_isolated_vertices=true)
HalfedgeHandle insert_edge(HalfedgeHandle _prev_heh, HalfedgeHandle _next_heh)
SmartHalfedgeHandle opposite_halfedge_handle(SmartHalfedgeHandle _heh) const
returns the face handle of the opposite halfedge
SmartHalfedgeHandle find_halfedge(VertexHandle _start_vh, VertexHandle _end_vh) const
Find halfedge from _vh0 to _vh1. Returns invalid handle if not found.
SmartVertexHandle make_smart(VertexHandle _vh, const PolyConnectivity *_mesh)
Creats a SmartVertexHandle from a VertexHandle and a Mesh.
void delete_face(FaceHandle _fh, bool _delete_isolated_vertices=true)
void reinsert_edge(EdgeHandle _eh)
ConstFaceFaceIter cff_iter(FaceHandle _fh) const
const face - face circulator
SmartFaceHandle opposite_face_handle(HalfedgeHandle _heh) const
returns the face handle of the opposite halfedge
void set_deleted(bool _b)
set deleted
bool is_boundary(HalfedgeHandle _heh) const
Check if the halfedge is at the boundary.
void triangulate()
triangulate the entire mesh
bool is_collapse_ok(HalfedgeHandle _he)
FaceHalfedgeIter fh_end(FaceHandle _fh)
face - halfedge circulator
static const VertexHandle InvalidVertexHandle
Invalid handle.
void collapse_edge(HalfedgeHandle _hh)
Helper for halfedge collapse.
SmartFaceHandle face_handle(SmartHalfedgeHandle _heh) const
returns the face handle of the opposite halfedge
uint valence(VertexHandle _vh) const
Vertex valence.
void split_edge_copy(EdgeHandle _eh, VertexHandle _vh)
SmartFaceHandle add_face(const std::vector< VertexHandle > &_vhandles)
Add and connect a new face.
static const HalfedgeHandle InvalidHalfedgeHandle
Invalid handle.
static const EdgeHandle InvalidEdgeHandle
Invalid handle.
bool deleted() const
is deleted ?
void copy_all_properties(VertexHandle _vh_from, VertexHandle _vh_to, bool _copyBuildIn=false)
static const FaceHandle InvalidFaceHandle
Invalid handle.
ConstFaceEdgeIter cfe_iter(FaceHandle _fh) const
const face - edge circulator
ConstFaceVertexIter cfv_iter(FaceHandle _fh) const
const face - vertex circulator
bool is_simply_connected(FaceHandle _fh) const
SmartHalfedgeHandle halfedge_handle(SmartEdgeHandle _eh, unsigned int _i) const
returns the face handle of the opposite halfedge