OpenMesh
|
00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenMesh. * 00009 * * 00010 * OpenMesh is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenMesh is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenMesh. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 /*===========================================================================*\ 00036 * * 00037 * $Revision: 362 $ * 00038 * $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ * 00039 * * 00040 \*===========================================================================*/ 00041 00042 #ifndef OPENMESH_POLYCONNECTIVITY_HH 00043 #define OPENMESH_POLYCONNECTIVITY_HH 00044 00045 #include <OpenMesh/Core/Mesh/ArrayKernel.hh> 00046 #include <OpenMesh/Core/Mesh/IteratorsT.hh> 00047 #include <OpenMesh/Core/Mesh/CirculatorsT.hh> 00048 00049 namespace OpenMesh 00050 { 00051 00054 class PolyConnectivity : public ArrayKernel 00055 { 00056 public: 00058 00059 00060 static const VertexHandle InvalidVertexHandle; 00062 static const HalfedgeHandle InvalidHalfedgeHandle; 00064 static const EdgeHandle InvalidEdgeHandle; 00066 static const FaceHandle InvalidFaceHandle; 00068 00069 typedef PolyConnectivity This; 00070 00071 //--- iterators --- 00072 00078 00079 typedef Iterators::VertexIterT<This> VertexIter; 00080 typedef Iterators::HalfedgeIterT<This> HalfedgeIter; 00081 typedef Iterators::EdgeIterT<This> EdgeIter; 00082 typedef Iterators::FaceIterT<This> FaceIter; 00083 00084 typedef Iterators::ConstVertexIterT<This> ConstVertexIter; 00085 typedef Iterators::ConstHalfedgeIterT<This> ConstHalfedgeIter; 00086 typedef Iterators::ConstEdgeIterT<This> ConstEdgeIter; 00087 typedef Iterators::ConstFaceIterT<This> ConstFaceIter; 00089 00090 //--- circulators --- 00091 00097 00098 typedef Iterators::VertexVertexIterT<This> VertexVertexIter; 00099 typedef Iterators::VertexOHalfedgeIterT<This> VertexOHalfedgeIter; 00100 typedef Iterators::VertexIHalfedgeIterT<This> VertexIHalfedgeIter; 00101 typedef Iterators::VertexEdgeIterT<This> VertexEdgeIter; 00102 typedef Iterators::VertexFaceIterT<This> VertexFaceIter; 00103 typedef Iterators::FaceVertexIterT<This> FaceVertexIter; 00104 typedef Iterators::FaceHalfedgeIterT<This> FaceHalfedgeIter; 00105 typedef Iterators::FaceEdgeIterT<This> FaceEdgeIter; 00106 typedef Iterators::FaceFaceIterT<This> FaceFaceIter; 00107 00108 typedef Iterators::ConstVertexVertexIterT<This> ConstVertexVertexIter; 00109 typedef Iterators::ConstVertexOHalfedgeIterT<This> ConstVertexOHalfedgeIter; 00110 typedef Iterators::ConstVertexIHalfedgeIterT<This> ConstVertexIHalfedgeIter; 00111 typedef Iterators::ConstVertexEdgeIterT<This> ConstVertexEdgeIter; 00112 typedef Iterators::ConstVertexFaceIterT<This> ConstVertexFaceIter; 00113 typedef Iterators::ConstFaceVertexIterT<This> ConstFaceVertexIter; 00114 typedef Iterators::ConstFaceHalfedgeIterT<This> ConstFaceHalfedgeIter; 00115 typedef Iterators::ConstFaceEdgeIterT<This> ConstFaceEdgeIter; 00116 typedef Iterators::ConstFaceFaceIterT<This> ConstFaceFaceIter; 00118 00119 // --- shortcuts 00120 00125 00126 typedef VertexHandle VHandle; 00127 typedef HalfedgeHandle HHandle; 00128 typedef EdgeHandle EHandle; 00129 typedef FaceHandle FHandle; 00130 00131 typedef VertexIter VIter; 00132 typedef HalfedgeIter HIter; 00133 typedef EdgeIter EIter; 00134 typedef FaceIter FIter; 00135 00136 typedef ConstVertexIter CVIter; 00137 typedef ConstHalfedgeIter CHIter; 00138 typedef ConstEdgeIter CEIter; 00139 typedef ConstFaceIter CFIter; 00140 00141 typedef VertexVertexIter VVIter; 00142 typedef VertexOHalfedgeIter VOHIter; 00143 typedef VertexIHalfedgeIter VIHIter; 00144 typedef VertexEdgeIter VEIter; 00145 typedef VertexFaceIter VFIter; 00146 typedef FaceVertexIter FVIter; 00147 typedef FaceHalfedgeIter FHIter; 00148 typedef FaceEdgeIter FEIter; 00149 typedef FaceFaceIter FFIter; 00150 00151 typedef ConstVertexVertexIter CVVIter; 00152 typedef ConstVertexOHalfedgeIter CVOHIter; 00153 typedef ConstVertexIHalfedgeIter CVIHIter; 00154 typedef ConstVertexEdgeIter CVEIter; 00155 typedef ConstVertexFaceIter CVFIter; 00156 typedef ConstFaceVertexIter CFVIter; 00157 typedef ConstFaceHalfedgeIter CFHIter; 00158 typedef ConstFaceEdgeIter CFEIter; 00159 typedef ConstFaceFaceIter CFFIter; 00161 00162 public: 00163 00164 PolyConnectivity() {} 00165 virtual ~PolyConnectivity() {} 00166 00167 inline static bool is_triangles() 00168 { return false; } 00169 00172 inline void assign_connectivity(const PolyConnectivity& _other) 00173 { ArrayKernel::assign_connectivity(_other); } 00174 00178 00180 inline VertexHandle add_vertex() 00181 { return new_vertex(); } 00182 00190 FaceHandle add_face(const std::vector<VertexHandle>& _vhandles) 00191 { return add_face(&_vhandles.front(), _vhandles.size()); } 00192 00193 00203 FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2) 00204 { 00205 VertexHandle vhs[3] = { _vh0, _vh1, _vh2 }; 00206 return add_face(vhs, 3); 00207 } 00208 00219 FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3) 00220 { 00221 VertexHandle vhs[4] = { _vh0, _vh1, _vh2, _vh3 }; 00222 return add_face(vhs, 4); 00223 } 00224 00233 FaceHandle add_face(const VertexHandle* _vhandles, uint _vhs_size); 00235 00237 00238 00244 void delete_vertex(VertexHandle _vh, bool _delete_isolated_vertices = true); 00245 00254 void delete_edge(EdgeHandle _eh, bool _delete_isolated_vertices=true); 00255 00266 void delete_face(FaceHandle _fh, bool _delete_isolated_vertices=true); 00267 00269 00273 00275 VertexIter vertices_begin() 00276 { return VertexIter(*this, VertexHandle(0)); } 00278 ConstVertexIter vertices_begin() const 00279 { return ConstVertexIter(*this, VertexHandle(0)); } 00281 VertexIter vertices_end() 00282 { return VertexIter(*this, VertexHandle(n_vertices())); } 00284 ConstVertexIter vertices_end() const 00285 { return ConstVertexIter(*this, VertexHandle(n_vertices())); } 00286 00288 HalfedgeIter halfedges_begin() 00289 { return HalfedgeIter(*this, HalfedgeHandle(0)); } 00291 ConstHalfedgeIter halfedges_begin() const 00292 { return ConstHalfedgeIter(*this, HalfedgeHandle(0)); } 00294 HalfedgeIter halfedges_end() 00295 { return HalfedgeIter(*this, HalfedgeHandle(n_halfedges())); } 00297 ConstHalfedgeIter halfedges_end() const 00298 { return ConstHalfedgeIter(*this, HalfedgeHandle(n_halfedges())); } 00299 00301 EdgeIter edges_begin() 00302 { return EdgeIter(*this, EdgeHandle(0)); } 00304 ConstEdgeIter edges_begin() const 00305 { return ConstEdgeIter(*this, EdgeHandle(0)); } 00307 EdgeIter edges_end() 00308 { return EdgeIter(*this, EdgeHandle(n_edges())); } 00310 ConstEdgeIter edges_end() const 00311 { return ConstEdgeIter(*this, EdgeHandle(n_edges())); } 00312 00314 FaceIter faces_begin() 00315 { return FaceIter(*this, FaceHandle(0)); } 00317 ConstFaceIter faces_begin() const 00318 { return ConstFaceIter(*this, FaceHandle(0)); } 00320 FaceIter faces_end() 00321 { return FaceIter(*this, FaceHandle(n_faces())); } 00323 ConstFaceIter faces_end() const 00324 { return ConstFaceIter(*this, FaceHandle(n_faces())); } 00325 00327 00328 00329 00333 00335 VertexIter vertices_sbegin() 00336 { return VertexIter(*this, VertexHandle(0), true); } 00338 ConstVertexIter vertices_sbegin() const 00339 { return ConstVertexIter(*this, VertexHandle(0), true); } 00340 00342 HalfedgeIter halfedges_sbegin() 00343 { return HalfedgeIter(*this, HalfedgeHandle(0), true); } 00345 ConstHalfedgeIter halfedges_sbegin() const 00346 { return ConstHalfedgeIter(*this, HalfedgeHandle(0), true); } 00347 00349 EdgeIter edges_sbegin() 00350 { return EdgeIter(*this, EdgeHandle(0), true); } 00352 ConstEdgeIter edges_sbegin() const 00353 { return ConstEdgeIter(*this, EdgeHandle(0), true); } 00354 00356 FaceIter faces_sbegin() 00357 { return FaceIter(*this, FaceHandle(0), true); } 00359 ConstFaceIter faces_sbegin() const 00360 { return ConstFaceIter(*this, FaceHandle(0), true); } 00361 00363 00364 //--- circulators --- 00365 00369 00371 VertexVertexIter vv_iter(VertexHandle _vh) 00372 { return VertexVertexIter(*this, _vh); } 00374 VertexIHalfedgeIter vih_iter(VertexHandle _vh) 00375 { return VertexIHalfedgeIter(*this, _vh); } 00377 VertexOHalfedgeIter voh_iter(VertexHandle _vh) 00378 { return VertexOHalfedgeIter(*this, _vh); } 00380 VertexEdgeIter ve_iter(VertexHandle _vh) 00381 { return VertexEdgeIter(*this, _vh); } 00383 VertexFaceIter vf_iter(VertexHandle _vh) 00384 { return VertexFaceIter(*this, _vh); } 00385 00387 ConstVertexVertexIter cvv_iter(VertexHandle _vh) const 00388 { return ConstVertexVertexIter(*this, _vh); } 00390 ConstVertexIHalfedgeIter cvih_iter(VertexHandle _vh) const 00391 { return ConstVertexIHalfedgeIter(*this, _vh); } 00393 ConstVertexOHalfedgeIter cvoh_iter(VertexHandle _vh) const 00394 { return ConstVertexOHalfedgeIter(*this, _vh); } 00396 ConstVertexEdgeIter cve_iter(VertexHandle _vh) const 00397 { return ConstVertexEdgeIter(*this, _vh); } 00399 ConstVertexFaceIter cvf_iter(VertexHandle _vh) const 00400 { return ConstVertexFaceIter(*this, _vh); } 00401 00403 FaceVertexIter fv_iter(FaceHandle _fh) 00404 { return FaceVertexIter(*this, _fh); } 00406 FaceHalfedgeIter fh_iter(FaceHandle _fh) 00407 { return FaceHalfedgeIter(*this, _fh); } 00409 FaceEdgeIter fe_iter(FaceHandle _fh) 00410 { return FaceEdgeIter(*this, _fh); } 00412 FaceFaceIter ff_iter(FaceHandle _fh) 00413 { return FaceFaceIter(*this, _fh); } 00414 00416 ConstFaceVertexIter cfv_iter(FaceHandle _fh) const 00417 { return ConstFaceVertexIter(*this, _fh); } 00419 ConstFaceHalfedgeIter cfh_iter(FaceHandle _fh) const 00420 { return ConstFaceHalfedgeIter(*this, _fh); } 00422 ConstFaceEdgeIter cfe_iter(FaceHandle _fh) const 00423 { return ConstFaceEdgeIter(*this, _fh); } 00425 ConstFaceFaceIter cff_iter(FaceHandle _fh) const 00426 { return ConstFaceFaceIter(*this, _fh); } 00427 00428 // 'begin' circulators 00429 00431 VertexVertexIter vv_begin(VertexHandle _vh) 00432 { return VertexVertexIter(*this, _vh); } 00434 VertexIHalfedgeIter vih_begin(VertexHandle _vh) 00435 { return VertexIHalfedgeIter(*this, _vh); } 00437 VertexOHalfedgeIter voh_begin(VertexHandle _vh) 00438 { return VertexOHalfedgeIter(*this, _vh); } 00440 VertexEdgeIter ve_begin(VertexHandle _vh) 00441 { return VertexEdgeIter(*this, _vh); } 00443 VertexFaceIter vf_begin(VertexHandle _vh) 00444 { return VertexFaceIter(*this, _vh); } 00445 00447 ConstVertexVertexIter cvv_begin(VertexHandle _vh) const 00448 { return ConstVertexVertexIter(*this, _vh); } 00450 ConstVertexIHalfedgeIter cvih_begin(VertexHandle _vh) const 00451 { return ConstVertexIHalfedgeIter(*this, _vh); } 00453 ConstVertexOHalfedgeIter cvoh_begin(VertexHandle _vh) const 00454 { return ConstVertexOHalfedgeIter(*this, _vh); } 00456 ConstVertexEdgeIter cve_begin(VertexHandle _vh) const 00457 { return ConstVertexEdgeIter(*this, _vh); } 00459 ConstVertexFaceIter cvf_begin(VertexHandle _vh) const 00460 { return ConstVertexFaceIter(*this, _vh); } 00461 00463 FaceVertexIter fv_begin(FaceHandle _fh) 00464 { return FaceVertexIter(*this, _fh); } 00466 FaceHalfedgeIter fh_begin(FaceHandle _fh) 00467 { return FaceHalfedgeIter(*this, _fh); } 00469 FaceEdgeIter fe_begin(FaceHandle _fh) 00470 { return FaceEdgeIter(*this, _fh); } 00472 FaceFaceIter ff_begin(FaceHandle _fh) 00473 { return FaceFaceIter(*this, _fh); } 00474 00476 ConstFaceVertexIter cfv_begin(FaceHandle _fh) const 00477 { return ConstFaceVertexIter(*this, _fh); } 00479 ConstFaceHalfedgeIter cfh_begin(FaceHandle _fh) const 00480 { return ConstFaceHalfedgeIter(*this, _fh); } 00482 ConstFaceEdgeIter cfe_begin(FaceHandle _fh) const 00483 { return ConstFaceEdgeIter(*this, _fh); } 00485 ConstFaceFaceIter cff_begin(FaceHandle _fh) const 00486 { return ConstFaceFaceIter(*this, _fh); } 00487 00488 // 'end' circulators 00489 00491 VertexVertexIter vv_end(VertexHandle _vh) 00492 { return VertexVertexIter(*this, _vh, true); } 00494 VertexIHalfedgeIter vih_end(VertexHandle _vh) 00495 { return VertexIHalfedgeIter(*this, _vh, true); } 00497 VertexOHalfedgeIter voh_end(VertexHandle _vh) 00498 { return VertexOHalfedgeIter(*this, _vh, true); } 00500 VertexEdgeIter ve_end(VertexHandle _vh) 00501 { return VertexEdgeIter(*this, _vh, true); } 00503 VertexFaceIter vf_end(VertexHandle _vh) 00504 { return VertexFaceIter(*this, _vh, true); } 00505 00507 ConstVertexVertexIter cvv_end(VertexHandle _vh) const 00508 { return ConstVertexVertexIter(*this, _vh, true); } 00510 ConstVertexIHalfedgeIter cvih_end(VertexHandle _vh) const 00511 { return ConstVertexIHalfedgeIter(*this, _vh, true); } 00513 ConstVertexOHalfedgeIter cvoh_end(VertexHandle _vh) const 00514 { return ConstVertexOHalfedgeIter(*this, _vh, true); } 00516 ConstVertexEdgeIter cve_end(VertexHandle _vh) const 00517 { return ConstVertexEdgeIter(*this, _vh, true); } 00519 ConstVertexFaceIter cvf_end(VertexHandle _vh) const 00520 { return ConstVertexFaceIter(*this, _vh, true); } 00521 00523 FaceVertexIter fv_end(FaceHandle _fh) 00524 { return FaceVertexIter(*this, _fh, true); } 00526 FaceHalfedgeIter fh_end(FaceHandle _fh) 00527 { return FaceHalfedgeIter(*this, _fh, true); } 00529 FaceEdgeIter fe_end(FaceHandle _fh) 00530 { return FaceEdgeIter(*this, _fh, true); } 00532 FaceFaceIter ff_end(FaceHandle _fh) 00533 { return FaceFaceIter(*this, _fh, true); } 00534 00536 ConstFaceVertexIter cfv_end(FaceHandle _fh) const 00537 { return ConstFaceVertexIter(*this, _fh, true); } 00539 ConstFaceHalfedgeIter cfh_end(FaceHandle _fh) const 00540 { return ConstFaceHalfedgeIter(*this, _fh, true); } 00542 ConstFaceEdgeIter cfe_end(FaceHandle _fh) const 00543 { return ConstFaceEdgeIter(*this, _fh, true); } 00545 ConstFaceFaceIter cff_end(FaceHandle _fh) const 00546 { return ConstFaceFaceIter(*this, _fh, true); } 00548 00552 bool is_boundary(HalfedgeHandle _heh) const 00553 { return ArrayKernel::is_boundary(_heh); } 00554 00557 bool is_boundary(EdgeHandle _eh) const 00558 { 00559 return (is_boundary(halfedge_handle(_eh, 0)) || 00560 is_boundary(halfedge_handle(_eh, 1))); 00561 } 00563 bool is_boundary(VertexHandle _vh) const 00564 { 00565 HalfedgeHandle heh(halfedge_handle(_vh)); 00566 return (!(heh.is_valid() && face_handle(heh).is_valid())); 00567 } 00568 00575 bool is_boundary(FaceHandle _fh, bool _check_vertex=false) const; 00577 bool is_manifold(VertexHandle _vh) const; 00579 00580 // --- shortcuts --- 00581 00583 inline FaceHandle opposite_face_handle(HalfedgeHandle _heh) const 00584 { return face_handle(opposite_halfedge_handle(_heh)); } 00585 00586 // --- misc --- 00587 00591 void adjust_outgoing_halfedge(VertexHandle _vh); 00593 HalfedgeHandle find_halfedge(VertexHandle _start_vh, VertexHandle _end_vh) const; 00595 uint valence(VertexHandle _vh) const; 00597 uint valence(FaceHandle _fh) const; 00598 00599 // --- connectivity operattions 00600 00614 void collapse(HalfedgeHandle _heh); 00619 bool is_simple_link(EdgeHandle _eh) const; 00624 bool is_simply_connected(FaceHandle _fh) const; 00637 FaceHandle remove_edge(EdgeHandle _eh); 00641 void reinsert_edge(EdgeHandle _eh); 00651 HalfedgeHandle insert_edge(HalfedgeHandle _prev_heh, HalfedgeHandle _next_heh); 00652 00654 void split(FaceHandle _fh, VertexHandle _vh); 00656 void triangulate(FaceHandle _fh); 00658 void triangulate(); 00659 00660 00666 00667 const Vertex& deref(VertexHandle _h) const { return vertex(_h); } 00668 Vertex& deref(VertexHandle _h) { return vertex(_h); } 00669 const Halfedge& deref(HalfedgeHandle _h) const { return halfedge(_h); } 00670 Halfedge& deref(HalfedgeHandle _h) { return halfedge(_h); } 00671 const Edge& deref(EdgeHandle _h) const { return edge(_h); } 00672 Edge& deref(EdgeHandle _h) { return edge(_h); } 00673 const Face& deref(FaceHandle _h) const { return face(_h); } 00674 Face& deref(FaceHandle _h) { return face(_h); } 00676 00677 protected: 00679 void collapse_edge(HalfedgeHandle _hh); 00681 void collapse_loop(HalfedgeHandle _hh); 00682 }; 00683 00684 }//namespace OpenMesh 00685 00686 #endif//OPENMESH_POLYCONNECTIVITY_HH