Blender  V2.59
LOD_NdQSDecimator.h
Go to the documentation of this file.
00001 /*
00002  * $Id: LOD_NdQSDecimator.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_NdQSDecimator_H
00035 #define NAN_INCLUDED_LOD_NdQSDecimator_H
00036 
00037 #include "common/NonCopyable.h"
00038 #include "LOD_ManMesh2.h"
00039 
00040 #include "LOD_EdgeCollapser.h"
00041 #include "LOD_NdQuadricEditor.h"
00042 
00043 class LOD_ExternBufferEditor;
00044 class LOD_ExternVColorEditor;
00045 class LOD_ExternNormalEditor;
00046 
00047 class LOD_NdQSDecimator : public NonCopyable {
00048 
00049 public :
00050 
00051         static
00052                 LOD_NdQSDecimator *
00053         New(
00054                 LOD_ManMesh2 &mesh,
00055                 LOD_ExternNormalEditor &face_editor,
00056                 LOD_ExternVColorEditor &color_editor,
00057                 LOD_ExternBufferEditor &extern_editor
00058         );
00059 
00060 
00061                 bool
00062         Arm(
00063         );
00064 
00065 
00066                 bool
00067         Step(
00068         );
00069 
00070 private :
00071 
00072         LOD_NdQSDecimator(
00073                 LOD_ManMesh2 &mesh,
00074                 LOD_ExternNormalEditor &face_editor,
00075                 LOD_ExternVColorEditor &color_editor,
00076                 LOD_ExternBufferEditor &extern_editor
00077         );
00078 
00079                 bool
00080         CollapseEdge(
00081         );
00082 
00083                 bool
00084         BuildHeap(
00085         );
00086 
00087                 void
00088         UpdateHeap(
00089                 std::vector<LOD_EdgeInd> &deg_edges,
00090                 std::vector<LOD_EdgeInd> &new_edges
00091         );      
00092 
00093                 void
00094         DeletePrimitives(
00095                 const std::vector<LOD_EdgeInd> & degenerate_edges,
00096                 const std::vector<LOD_FaceInd> & degenerate_faces,
00097                 const std::vector<LOD_VertexInd> & degenerate_vertices
00098         );
00099 
00100         // Iterate through the face set 
00101         // for each property of the face vertices 
00102         // compute a quadric for that property.
00103         // Add it to the quadric array. 
00104         
00105                 void
00106         ComputePropertyQuadrics(
00107         );
00108 
00109 
00110 private :       
00111 
00112                 
00113         // owned by this class
00115 
00116         NanPtr<LOD_EdgeCollapser> m_collapser;
00117         NanPtr<Heap<LOD_Edge> > m_heap;
00118         NanPtr<LOD_NdQuadricEditor> m_quadric_editor;
00119 
00120         bool m_is_armed;
00121 
00122         // arguments to New(...)
00124 
00125         LOD_ManMesh2 & m_mesh;
00126         LOD_ExternNormalEditor & m_face_editor;
00127         LOD_ExternBufferEditor & m_extern_editor;
00128         LOD_ExternVColorEditor & m_color_editor;        
00129 
00130         // temporary buffers
00132 
00133         std::vector<LOD_FaceInd> m_deg_faces;
00134         std::vector<LOD_EdgeInd> m_deg_edges;
00135         std::vector<LOD_VertexInd> m_deg_vertices;
00136 
00137         std::vector<LOD_FaceInd> m_update_faces;
00138         std::vector<LOD_EdgeInd> m_new_edges;
00139         std::vector<LOD_VertexInd> m_update_vertices;
00140 
00141 
00142 };
00143 
00144 #endif
00145