OpenMesh
|
00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenMesh. * 00009 * * 00010 * OpenMesh is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenMesh is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenMesh. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 /*===========================================================================*\ 00036 * * 00037 * $Revision: 362 $ * 00038 * $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ * 00039 * * 00040 \*===========================================================================*/ 00041 00042 //============================================================================= 00043 // 00044 // CLASS newClass 00045 // 00046 //============================================================================= 00047 00048 00049 #ifndef OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH 00050 #define OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH 00051 00052 00053 //== INCLUDES ================================================================= 00054 00055 #include <string> 00056 #include <QTimer> 00057 00058 #include <OpenMesh/Core/IO/MeshIO.hh> 00059 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> 00060 #include <OpenMesh/Apps/QtViewer/MeshViewerWidgetT.hh> 00061 00062 #include <OpenMesh/Tools/VDPM/MeshTraits.hh> 00063 #include <OpenMesh/Tools/VDPM/StreamingDef.hh> 00064 #include <OpenMesh/Tools/VDPM/ViewingParameters.hh> 00065 #include <OpenMesh/Tools/VDPM/VHierarchy.hh> 00066 #include <OpenMesh/Tools/VDPM/VFront.hh> 00067 00068 00069 //== FORWARDDECLARATIONS ====================================================== 00070 00071 00072 //== NAMESPACES =============================================================== 00073 00074 namespace OpenMesh { 00075 00076 00077 //== CLASS DEFINITION ========================================================= 00078 00079 00089 typedef TriMesh_ArrayKernelT<VDPM::MeshTraits> VDPMMesh; 00090 typedef MeshViewerWidgetT<VDPMMesh> MeshViewerWidget; 00091 00092 00093 // using view dependent progressive mesh 00094 00095 using VDPM::Plane3d; 00096 using VDPM::VFront; 00097 using VDPM::VHierarchy; 00098 using VDPM::VHierarchyNode; 00099 using VDPM::VHierarchyNodeIndex; 00100 using VDPM::VHierarchyNodeHandle; 00101 using VDPM::VHierarchyNodeHandleContainer; 00102 using VDPM::ViewingParameters; 00103 00104 00105 //== CLASS DEFINITION ========================================================= 00106 00107 00108 class VDPMSynthesizerViewerWidget : public MeshViewerWidget 00109 { 00110 public: 00111 00112 typedef MeshViewerWidget Base; 00113 00114 public: 00115 00116 VDPMSynthesizerViewerWidget(QWidget* _parent=0, const char* _name=0) 00117 : MeshViewerWidget(_parent) 00118 { 00119 adaptive_mode_ = true; 00120 } 00121 00122 ~VDPMSynthesizerViewerWidget() 00123 { 00124 00125 } 00126 00128 void open_vd_prog_mesh(const char* _filename); 00129 00130 00131 private: 00132 00133 QString qFilename_; 00134 VHierarchy vhierarchy_; 00135 VFront vfront_; 00136 ViewingParameters viewing_parameters_; 00137 float kappa_square_; 00138 bool adaptive_mode_; 00139 00140 unsigned int n_base_vertices_; 00141 unsigned int n_base_edges_; 00142 unsigned int n_base_faces_; 00143 unsigned int n_details_; 00144 00145 00146 private: 00147 00148 bool outside_view_frustum(const OpenMesh::Vec3f &pos, float radius); 00149 00150 bool oriented_away(float sin_square, 00151 float distance_square, 00152 float product_value); 00153 00154 bool screen_space_error(float mue_square, 00155 float sigma_square, 00156 float distance_square, 00157 float product_value); 00158 00159 void update_viewing_parameters(); 00160 00161 virtual void keyPressEvent(QKeyEvent* _event); 00162 00163 protected: 00164 00166 virtual void draw_scene(const std::string& _draw_mode); 00167 00168 public: 00169 00170 void adaptive_refinement(); 00171 00172 bool qrefine(VHierarchyNodeHandle _node_handle); 00173 00174 void force_vsplit(VHierarchyNodeHandle _node_handle); 00175 00176 bool ecol_legal(VHierarchyNodeHandle _parent_handle, 00177 VDPMMesh::HalfedgeHandle& v0v1); 00178 00179 void get_active_cuts(VHierarchyNodeHandle _node_handle, 00180 VDPMMesh::VertexHandle &vl, VDPMMesh::VertexHandle &vr); 00181 00182 void vsplit(VHierarchyNodeHandle _node_handle, 00183 VDPMMesh::VertexHandle vl, VDPMMesh::VertexHandle vr); 00184 00185 void ecol(VHierarchyNodeHandle _parent_handle, 00186 const VDPMMesh::HalfedgeHandle& v0v1); 00187 00188 void init_vfront(); 00189 00190 }; 00191 00192 00193 //============================================================================= 00194 } // namespace OpenMesh 00195 //============================================================================= 00196 #endif // OPENMESHAPPS_VDPMSYNTHESIZERVIEWERWIDGET_HH defined 00197 //=============================================================================