Blender V2.61 - r43446

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