OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
VDPMSynthesizerViewerWidget.hh
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenMesh is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 736 $ *
38 * $Date: 2012-10-08 09:30:49 +0200 (Mo, 08 Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
42 //=============================================================================
43 //
44 // CLASS newClass
45 //
46 //=============================================================================
47
48
49 #ifndef OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
50 #define OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
51
52
53 //== INCLUDES =================================================================
54
55 #include <string>
56 #include <QTimer>
57
58 #include <OpenMesh/Core/IO/MeshIO.hh>
59 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
60 #include <OpenMesh/Apps/QtViewer/MeshViewerWidgetT.hh>
61
62 #include <OpenMesh/Tools/VDPM/MeshTraits.hh>
63 #include <OpenMesh/Tools/VDPM/StreamingDef.hh>
64 #include <OpenMesh/Tools/VDPM/ViewingParameters.hh>
65 #include <OpenMesh/Tools/VDPM/VHierarchy.hh>
66 #include <OpenMesh/Tools/VDPM/VFront.hh>
67
68
69 //== FORWARDDECLARATIONS ======================================================
70
71
72 //== NAMESPACES ===============================================================
73
74 namespace OpenMesh {
75
76
77 //== CLASS DEFINITION =========================================================
78
79
89 typedef TriMesh_ArrayKernelT<VDPM::MeshTraits> VDPMMesh;
90 typedef MeshViewerWidgetT<VDPMMesh> MeshViewerWidget;
91
92
93 // using view dependent progressive mesh
94
95 using VDPM::Plane3d;
96 using VDPM::VFront;
97 using VDPM::VHierarchy;
98 using VDPM::VHierarchyNode;
99 using VDPM::VHierarchyNodeIndex;
100 using VDPM::VHierarchyNodeHandle;
101 using VDPM::VHierarchyNodeHandleContainer;
102 using VDPM::ViewingParameters;
103
104
105 //== CLASS DEFINITION =========================================================
106
107
108 class VDPMSynthesizerViewerWidget : public MeshViewerWidget
109 {
110 public:
111
112 typedef MeshViewerWidget Base;
113
114 public:
115
116 VDPMSynthesizerViewerWidget(QWidget* _parent=0, const char* _name=0);
117
118 ~VDPMSynthesizerViewerWidget();
119
121 void open_vd_prog_mesh(const char* _filename);
122
123
124 private:
125
126 QString qFilename_;
127 VHierarchy vhierarchy_;
128 VFront vfront_;
129 ViewingParameters viewing_parameters_;
130 float kappa_square_;
131 bool adaptive_mode_;
132
133 unsigned int n_base_vertices_;
134 unsigned int n_base_edges_;
135 unsigned int n_base_faces_;
136 unsigned int n_details_;
137
138
139 private:
140
141 bool outside_view_frustum(const OpenMesh::Vec3f &pos, float radius);
142
143 bool oriented_away(float sin_square,
144 float distance_square,
145 float product_value);
146
147 bool screen_space_error(float mue_square,
148 float sigma_square,
149 float distance_square,
150 float product_value);
151
152 void update_viewing_parameters();
153
154 virtual void keyPressEvent(QKeyEvent* _event);
155
156 protected:
157
159 virtual void draw_scene(const std::string& _draw_mode);
160
161 public:
162
163 void adaptive_refinement();
164
165 bool qrefine(VHierarchyNodeHandle _node_handle);
166
167 void force_vsplit(VHierarchyNodeHandle _node_handle);
168
169 bool ecol_legal(VHierarchyNodeHandle _parent_handle,
170 VDPMMesh::HalfedgeHandle& v0v1);
171
172 void get_active_cuts(VHierarchyNodeHandle _node_handle,
173 VDPMMesh::VertexHandle &vl, VDPMMesh::VertexHandle &vr);
174
175 void vsplit(VHierarchyNodeHandle _node_handle,
176 VDPMMesh::VertexHandle vl, VDPMMesh::VertexHandle vr);
177
178 void ecol(VHierarchyNodeHandle _parent_handle,
179 const VDPMMesh::HalfedgeHandle& v0v1);
180
181 void init_vfront();
182
183 };
184
185
186 //=============================================================================
187 } // namespace OpenMesh
188 //=============================================================================
189 #endif // OPENMESHAPPS_VDPMSYNTHESIZERVIEWERWIDGET_HH defined
190 //=============================================================================