OpenMesh
OpenMesh/Tools/Decimater/CollapseInfoT.hh
Go to the documentation of this file.
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 
00047 //=============================================================================
00048 //
00049 //  STRUCT CollpaseInfoT
00050 //
00051 //=============================================================================
00052 
00053 #ifndef OPENMESH_DECIMATER_COLLAPSEINFOT_HH
00054 #define OPENMESH_DECIMATER_COLLAPSEINFOT_HH
00055 
00056 
00057 //== INCLUDES =================================================================
00058 
00059 
00060 //== NAMESPACE ================================================================
00061 
00062 namespace OpenMesh  { 
00063 namespace Decimater {
00064 
00065 
00066 //== CLASS DEFINITION =========================================================
00067 
00076 template <class Mesh>
00077 struct CollapseInfoT
00078 {
00079 public:
00089    CollapseInfoT(Mesh& _mesh, typename Mesh::HalfedgeHandle _heh);
00090 
00091   Mesh&                          mesh;
00092 
00093   typename Mesh::HalfedgeHandle  v0v1; 
00094   typename Mesh::HalfedgeHandle  v1v0; 
00095   typename Mesh::VertexHandle    v0;   
00096   typename Mesh::VertexHandle    v1;   
00097   typename Mesh::Point           p0;   
00098   typename Mesh::Point           p1;   
00099   typename Mesh::FaceHandle      fl;   
00100   typename Mesh::FaceHandle      fr;   
00101   typename Mesh::VertexHandle    vl;   
00102   typename Mesh::VertexHandle    vr;   
00103 
00104 
00107   typename Mesh::HalfedgeHandle  vlv1, v0vl, vrv0, v1vr;
00109 };
00110 
00111 
00112 //-----------------------------------------------------------------------------
00113 
00114 
00115 // CollapseInfoT::CollapseInfoT( _mesh, _heh )
00116 //
00117 //   Local configuration of halfedge collapse to be stored in CollapseInfoT:
00118 /* 
00119            vl
00120            * 
00121           / \
00122          /   \
00123         / fl  \
00124     v0 *------>* v1
00125         \ fr  /
00126          \   /
00127           \ /
00128            * 
00129            vr
00130 */
00131 // Parameters:
00132 //   _mesh               Reference to mesh
00133 //   _heh                The halfedge (v0 -> v1) defining the collapse
00134 //
00135 template <class Mesh>
00136 inline
00137 CollapseInfoT<Mesh>::
00138 CollapseInfoT(Mesh& _mesh, typename Mesh::HalfedgeHandle _heh) :
00139 
00140   mesh(_mesh),
00141   v0v1(_heh),
00142   v1v0(_mesh.opposite_halfedge_handle(v0v1)),
00143   v0(_mesh.to_vertex_handle(v1v0)),
00144   v1(_mesh.to_vertex_handle(v0v1)),
00145   p0(_mesh.point(v0)),
00146   p1(_mesh.point(v1)),
00147   fl(_mesh.face_handle(v0v1)),
00148   fr(_mesh.face_handle(v1v0))
00149 
00150 {
00151   // get vl
00152   if (fl.is_valid())
00153   {
00154     vlv1 = mesh.next_halfedge_handle(v0v1);
00155     v0vl = mesh.next_halfedge_handle(vlv1);
00156     vl   = mesh.to_vertex_handle(vlv1);
00157     vlv1 = mesh.opposite_halfedge_handle(vlv1);
00158     v0vl = mesh.opposite_halfedge_handle(v0vl);
00159   }
00160 
00161 
00162   // get vr
00163   if (fr.is_valid())
00164   {
00165     vrv0 = mesh.next_halfedge_handle(v1v0);
00166     v1vr = mesh.next_halfedge_handle(vrv0);
00167     vr   = mesh.to_vertex_handle(vrv0);
00168     vrv0 = mesh.opposite_halfedge_handle(vrv0);
00169     v1vr = mesh.opposite_halfedge_handle(v1vr);
00170   }
00171 }  
00172 
00173 //=============================================================================
00174 } // END_NS_DECIMATER
00175 } // END_NS_OPENMESH
00176 //=============================================================================
00177 #endif // OPENMESH_DECIMATER_COLLAPSEINFOT_HH defined
00178 //=============================================================================
00179