Blender V2.61 - r43446

LOD_EdgeCollapser.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #ifndef NAN_INCLDUED_EgdeCollapser_h
00034 #define NAN_INCLDUED_EgdeCollapser_h
00035 
00036 // This is a helper class that collapses edges of a 2 - manifold mesh.
00037 
00038 #include "LOD_MeshPrimitives.h"
00039 #include "MEM_NonCopyable.h"
00040 #include <vector>
00041 #include <functional>
00042 
00043 class LOD_ManMesh2;
00044 
00045 class LOD_EdgeCollapser 
00046 : public  MEM_NonCopyable
00047 {
00048 
00049 public :
00050             
00051     static
00052         LOD_EdgeCollapser * 
00053     New(
00054     );
00055 
00056     // returns via arguments the set of modified
00057     // verts,edges and faces.
00058 
00059         bool
00060     CollapseEdge(
00061         LOD_EdgeInd ei,
00062         LOD_ManMesh2 &mesh,
00063         std::vector<LOD_EdgeInd> &  degenerate_edges,
00064         std::vector<LOD_FaceInd> &  degenerate_faces,
00065         std::vector<LOD_VertexInd> & degenerate_vertices,
00066         std::vector<LOD_EdgeInd> &  new_edges,
00067         std::vector<LOD_FaceInd> &  update_faces,
00068         std::vector<LOD_VertexInd> & update_vertices
00069     );
00070 
00071 private :
00072 
00073     LOD_EdgeCollapser(
00074     );
00075 
00076     // Test to see if the result of collapsing the
00077     // edge produces 2 junctions in the mesh i.e. where
00078     // an edge is shared by more than 2 polygons
00079 
00080     // We count the number of coincedent edge pairs that
00081     // result from the collapse of collapse_edge.
00082 
00083     // If collapse edge is a boundary edge then the number of
00084     // coincedent pairs should be 1
00085     // else it should be 2.
00086 
00087         bool
00088     TJunctionTest(
00089         LOD_ManMesh2 &mesh,
00090         std::vector<LOD_EdgeInd> &e_v0v1,
00091         LOD_EdgeInd collapse_edge
00092     );
00093 
00094     // here's the definition of the sort function
00095     // we use to determine coincedent edges
00096 
00097     // assumes the edges are normalized i.e. m_verts[0] <= m_verts[1]
00098 
00099     struct less : std::binary_function<LOD_Edge, LOD_Edge, bool> {
00100             bool 
00101         operator()(
00102             const LOD_Edge& a,
00103             const LOD_Edge& b
00104         ) const {
00105                 
00106             if (int(a.m_verts[0]) == int(b.m_verts[0])) {
00107                 return (int(a.m_verts[1]) < int(b.m_verts[1]));
00108             } else {
00109                 return (int(a.m_verts[0]) < int(b.m_verts[0]));
00110             }
00111         }
00112     };
00113 
00114 };
00115 
00116 #endif
00117