00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
00050 #define OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
00051
00052
00053
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
00070
00071
00072
00073
00074 namespace OpenMesh {
00075
00076
00077
00078
00079
00089 typedef TriMesh_ArrayKernelT<VDPM::MeshTraits> VDPMMesh;
00090 typedef MeshViewerWidgetT<VDPMMesh> MeshViewerWidget;
00091
00092
00093
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
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 }
00195
00196 #endif // OPENMESHAPPS_VDPMSYNTHESIZERVIEWERWIDGET_HH defined
00197