Blender V2.61 - r43446

LOD_DecimationClass.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_DecimationClass_h
00034 #define NAN_INCLUDED_LOD_DecimationClass_h
00035 
00036 #include "MEM_SmartPtr.h"
00037 #include "MEM_NonCopyable.h"
00038 
00039 #include "LOD_ManMesh2.h"
00040 #include "LOD_QSDecimator.h"
00041 #include "LOD_ExternNormalEditor.h"
00042 #include "../extern/LOD_decimation.h"
00043 #include "LOD_ExternBufferEditor.h"
00044 
00045 
00046 class LOD_DecimationClass : public MEM_NonCopyable
00047 {
00048 public :
00049 
00050     enum {
00051         e_not_loaded,
00052         e_loaded,
00053         e_preprocessed
00054     } m_e_decimation_state;
00055 
00056 
00057     static
00058         LOD_DecimationClass *
00059     New(
00060         LOD_Decimation_InfoPtr extern_info
00061     ) {
00062         // create everything 
00063     
00064         MEM_SmartPtr<LOD_DecimationClass> output(new LOD_DecimationClass());
00065         MEM_SmartPtr<LOD_ManMesh2> mesh(LOD_ManMesh2::New());
00066         MEM_SmartPtr<LOD_ExternBufferEditor> extern_editor(LOD_ExternBufferEditor::New(extern_info));
00067 
00068         if (mesh == NULL || extern_editor == NULL) return NULL;
00069         MEM_SmartPtr<LOD_ExternNormalEditor> normals(LOD_ExternNormalEditor::New(extern_info,mesh.Ref()));
00070 
00071         if (normals == NULL) return NULL;
00072         MEM_SmartPtr<LOD_QSDecimator> decimator(LOD_QSDecimator::New(
00073             mesh.Ref(),
00074             normals.Ref(),
00075             extern_editor.Ref()
00076         ));     
00077         if (decimator == NULL || output == NULL) return NULL;
00078 
00079         output->m_mesh = mesh.Release();
00080         output->m_decimator = decimator.Release();
00081         output->m_normals = normals.Release();
00082         output->m_extern_editor = extern_editor.Release();
00083 
00084         return output.Release();
00085     }
00086 
00087         LOD_ManMesh2 &
00088     Mesh(
00089     ){
00090         return m_mesh.Ref();
00091     }
00092 
00093         LOD_QSDecimator &
00094     Decimator(
00095     ) {
00096         return m_decimator.Ref();
00097     }
00098 
00099         LOD_ExternNormalEditor &
00100     FaceEditor(
00101     ){
00102         return m_normals.Ref();
00103     }
00104             
00105 private :
00106 
00107     LOD_DecimationClass(
00108     ) : m_e_decimation_state(e_not_loaded) {
00109     };
00110 
00111     MEM_SmartPtr<LOD_ManMesh2> m_mesh;
00112     MEM_SmartPtr<LOD_QSDecimator> m_decimator;
00113     MEM_SmartPtr<LOD_ExternNormalEditor> m_normals;
00114     MEM_SmartPtr<LOD_ExternBufferEditor> m_extern_editor;
00115 };
00116 
00117 #endif
00118