Blender  V2.59
LOD_QSDecimator.h
Go to the documentation of this file.
00001 /*
00002  * $Id: LOD_QSDecimator.h 35147 2011-02-25 10:47:28Z jesterking $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): none yet.
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #ifndef NAN_INCLUDED_LOD_QSDecimator_H
00035 #define NAN_INCLUDED_LOD_QSDecimator_H
00036 
00037 #include "MEM_NonCopyable.h"
00038 #include "LOD_ManMesh2.h"
00039 #include "LOD_ExternNormalEditor.h"
00040 #include "LOD_EdgeCollapser.h"
00041 #include "LOD_QuadricEditor.h"
00042 
00043 class LOD_ExternBufferEditor;
00044 
00045 class LOD_QSDecimator : public MEM_NonCopyable {
00046 
00047 public :
00048 
00049         static
00050                 LOD_QSDecimator *
00051         New(
00052                 LOD_ManMesh2 &mesh,
00053                 LOD_ExternNormalEditor &face_editor,
00054                 LOD_ExternBufferEditor &extern_editor
00055         );
00056 
00057 
00058                 bool
00059         Arm(
00060         );
00061 
00062 
00063                 bool
00064         Step(
00065         );
00066 
00067 private :
00068 
00069         LOD_QSDecimator(
00070                 LOD_ManMesh2 &mesh,
00071                 LOD_ExternNormalEditor &face_editor,
00072                 LOD_ExternBufferEditor &extern_editor
00073         );
00074 
00075                 bool
00076         CollapseEdge(
00077         );
00078 
00079                 bool
00080         BuildHeap(
00081         );
00082 
00083                 void
00084         UpdateHeap(
00085                 std::vector<LOD_EdgeInd> &deg_edges,
00086                 std::vector<LOD_EdgeInd> &new_edges
00087         );      
00088 
00089                 void
00090         DeletePrimitives(
00091                 const std::vector<LOD_EdgeInd> & degenerate_edges,
00092                 const std::vector<LOD_FaceInd> & degenerate_faces,
00093                 const std::vector<LOD_VertexInd> & degenerate_vertices
00094         );
00095 
00096 
00097 private :       
00098 
00099         // owned by this class
00101 
00102         MEM_SmartPtr<LOD_EdgeCollapser> m_collapser;
00103         MEM_SmartPtr<CTR_UHeap<LOD_Edge> > m_heap;
00104         MEM_SmartPtr<LOD_QuadricEditor> m_quadric_editor;
00105 
00106         bool m_is_armed;
00107 
00108         // arguments to New(...)
00110 
00111         LOD_ManMesh2 & m_mesh;
00112         LOD_ExternNormalEditor &m_face_editor;
00113         LOD_ExternBufferEditor & m_extern_editor;       
00114 
00115         // temporary buffers
00117 
00118         std::vector<LOD_FaceInd> m_deg_faces;
00119         std::vector<LOD_EdgeInd> m_deg_edges;
00120         std::vector<LOD_VertexInd> m_deg_vertices;
00121 
00122         std::vector<LOD_FaceInd> m_update_faces;
00123         std::vector<LOD_EdgeInd> m_new_edges;
00124         std::vector<LOD_VertexInd> m_update_vertices;
00125 
00126 
00127 };
00128 
00129 #endif
00130