OpenMesh
OpenMesh/Core/Mesh/TriConnectivity.hh
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: 456 $                                                         *
00038  *   $Date: 2011-11-14 09:16:07 +0100 (Mo, 14 Nov 2011) $                   *
00039  *                                                                           *
00040 \*===========================================================================*/
00041 
00042 #ifndef OPENMESH_TRICONNECTIVITY_HH
00043 #define OPENMESH_TRICONNECTIVITY_HH
00044 
00045 #include <OpenMesh/Core/Mesh/PolyConnectivity.hh>
00046 
00047 namespace OpenMesh {
00048 
00051 class TriConnectivity : public PolyConnectivity
00052 {
00053 public:
00054 
00055   TriConnectivity() {}
00056   virtual ~TriConnectivity() {}
00057 
00058   inline static bool is_triangles()
00059   { return true; }
00060 
00064   inline void assign_connectivity(const TriConnectivity& _other)
00065   { PolyConnectivity::assign_connectivity(_other); }
00066   
00067   inline void assign_connectivity(const PolyConnectivity& _other)
00068   { 
00069     PolyConnectivity::assign_connectivity(_other); 
00070     triangulate();
00071   }
00072   
00079   FaceHandle add_face(const std::vector<VertexHandle>& _vhandles)
00080   { return add_face(&_vhandles.front(), _vhandles.size()); }
00081   
00082   FaceHandle add_face(const VertexHandle* _vhandles, uint _vhs_size);
00083   
00084   FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2)
00085   { 
00086     VertexHandle vhs[3] = { _vh0, _vh1, _vh2 };
00087     return PolyConnectivity::add_face(vhs, 3); 
00088   }
00089   
00091 
00095   inline VertexHandle opposite_vh(HalfedgeHandle _heh) const
00096   {
00097     return is_boundary(_heh) ? InvalidVertexHandle :
00098                                to_vertex_handle(next_halfedge_handle(_heh));
00099   }
00100 
00104   VertexHandle opposite_he_opposite_vh(HalfedgeHandle _heh) const
00105   { return opposite_vh(opposite_halfedge_handle(_heh)); }
00106 
00110 
00111 
00116   bool is_collapse_ok(HalfedgeHandle _heh);
00117 
00119   HalfedgeHandle vertex_split(VertexHandle v0, VertexHandle v1,
00120                               VertexHandle vl, VertexHandle vr);
00121 
00123   bool is_flip_ok(EdgeHandle _eh) const;
00124 
00127   void flip(EdgeHandle _eh);
00128 
00130   void split(EdgeHandle _eh, VertexHandle _vh);
00131 
00133   inline void split(FaceHandle _fh, VertexHandle _vh)
00134   { PolyConnectivity::split(_fh, _vh); }
00135 
00137 
00138 private:
00140   HalfedgeHandle insert_loop(HalfedgeHandle _hh);
00142   HalfedgeHandle insert_edge(VertexHandle _vh,
00143                              HalfedgeHandle _h0, HalfedgeHandle _h1);
00144 };
00145 
00146 }
00147 
00148 #endif//OPENMESH_TRICONNECTIVITY_HH
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines