Blender V2.61 - r43446

LOD_QSDecimator.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_INCLUDED_LOD_QSDecimator_H
00034 #define NAN_INCLUDED_LOD_QSDecimator_H
00035 
00036 #include "MEM_NonCopyable.h"
00037 #include "LOD_ManMesh2.h"
00038 #include "LOD_ExternNormalEditor.h"
00039 #include "LOD_EdgeCollapser.h"
00040 #include "LOD_QuadricEditor.h"
00041 
00042 class LOD_ExternBufferEditor;
00043 
00044 class LOD_QSDecimator : public MEM_NonCopyable {
00045 
00046 public :
00047 
00048     static
00049         LOD_QSDecimator *
00050     New(
00051         LOD_ManMesh2 &mesh,
00052         LOD_ExternNormalEditor &face_editor,
00053         LOD_ExternBufferEditor &extern_editor
00054     );
00055 
00056 
00057         bool
00058     Arm(
00059     );
00060 
00061 
00062         bool
00063     Step(
00064     );
00065 
00066 private :
00067 
00068     LOD_QSDecimator(
00069         LOD_ManMesh2 &mesh,
00070         LOD_ExternNormalEditor &face_editor,
00071         LOD_ExternBufferEditor &extern_editor
00072     );
00073 
00074         bool
00075     CollapseEdge(
00076     );
00077 
00078         bool
00079     BuildHeap(
00080     );
00081 
00082         void
00083     UpdateHeap(
00084         std::vector<LOD_EdgeInd> &deg_edges,
00085         std::vector<LOD_EdgeInd> &new_edges
00086     );  
00087 
00088         void
00089     DeletePrimitives(
00090         const std::vector<LOD_EdgeInd> & degenerate_edges,
00091         const std::vector<LOD_FaceInd> & degenerate_faces,
00092         const std::vector<LOD_VertexInd> & degenerate_vertices
00093     );
00094 
00095 
00096 private :   
00097 
00098     // owned by this class
00100 
00101     MEM_SmartPtr<LOD_EdgeCollapser> m_collapser;
00102     MEM_SmartPtr<CTR_UHeap<LOD_Edge> > m_heap;
00103     MEM_SmartPtr<LOD_QuadricEditor> m_quadric_editor;
00104 
00105     bool m_is_armed;
00106 
00107     // arguments to New(...)
00109 
00110     LOD_ManMesh2 & m_mesh;
00111     LOD_ExternNormalEditor &m_face_editor;
00112     LOD_ExternBufferEditor & m_extern_editor;   
00113 
00114     // temporary buffers
00116 
00117     std::vector<LOD_FaceInd> m_deg_faces;
00118     std::vector<LOD_EdgeInd> m_deg_edges;
00119     std::vector<LOD_VertexInd> m_deg_vertices;
00120 
00121     std::vector<LOD_FaceInd> m_update_faces;
00122     std::vector<LOD_EdgeInd> m_new_edges;
00123     std::vector<LOD_VertexInd> m_update_vertices;
00124 
00125 
00126 };
00127 
00128 #endif
00129