Developer Documentation
VDPMSynthesizerViewerWidget.hh
1 /* ========================================================================= *
2  * *
3  * OpenMesh *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openmesh.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenMesh. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40  * ========================================================================= */
41 
42 
43 
44 //=============================================================================
45 //
46 // CLASS newClass
47 //
48 //=============================================================================
49 
50 
51 #ifndef OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
52 #define OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
53 
54 
55 //== INCLUDES =================================================================
56 
57 #include <string>
58 #include <QTimer>
59 
60 #include <OpenMesh/Core/IO/MeshIO.hh>
61 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
62 #include <OpenMesh/Apps/QtViewer/MeshViewerWidgetT.hh>
63 
64 #include <OpenMesh/Tools/VDPM/MeshTraits.hh>
65 #include <OpenMesh/Tools/VDPM/StreamingDef.hh>
66 #include <OpenMesh/Tools/VDPM/ViewingParameters.hh>
67 #include <OpenMesh/Tools/VDPM/VHierarchy.hh>
68 #include <OpenMesh/Tools/VDPM/VFront.hh>
69 
70 
71 //== FORWARDDECLARATIONS ======================================================
72 
73 
74 //== NAMESPACES ===============================================================
75 
76 namespace OpenMesh {
77 
78 
79 //== CLASS DEFINITION =========================================================
80 
81 
91 typedef TriMesh_ArrayKernelT<VDPM::MeshTraits> VDPMMesh;
93 
94 
95  // using view dependent progressive mesh
96 
97  using VDPM::Plane3d;
98  using VDPM::VFront;
99  using VDPM::VHierarchy;
100  using VDPM::VHierarchyNode;
101  using VDPM::VHierarchyNodeIndex;
102  using VDPM::VHierarchyNodeHandle;
104  using VDPM::ViewingParameters;
105 
106 
107 //== CLASS DEFINITION =========================================================
108 
109 
110 class VDPMSynthesizerViewerWidget : public MeshViewerWidget
111 {
112 public:
113 
114  typedef MeshViewerWidget Base;
115 
116 public:
117 
118  VDPMSynthesizerViewerWidget(QWidget* _parent=0, const char* _name=0);
119 
121 
123  void open_vd_prog_mesh(const char* _filename);
124 
125 
126 private:
127 
128  QString qFilename_;
129  VHierarchy vhierarchy_;
130  VFront vfront_;
131  ViewingParameters viewing_parameters_;
132  float kappa_square_;
133  bool adaptive_mode_;
134 
135  unsigned int n_base_vertices_;
136  unsigned int n_base_edges_;
137  unsigned int n_base_faces_;
138  unsigned int n_details_;
139 
140 
141 private:
142 
143  bool outside_view_frustum(const OpenMesh::Vec3f &pos, float radius);
144 
145  bool oriented_away(float sin_square,
146  float distance_square,
147  float product_value);
148 
149  bool screen_space_error(float mue_square,
150  float sigma_square,
151  float distance_square,
152  float product_value);
153 
154  void update_viewing_parameters();
155 
156  virtual void keyPressEvent(QKeyEvent* _event);
157 
158 protected:
159 
161  virtual void draw_scene(const std::string& _draw_mode);
162 
163 public:
164 
165  void adaptive_refinement();
166 
167  bool qrefine(VHierarchyNodeHandle _node_handle);
168 
169  void force_vsplit(VHierarchyNodeHandle _node_handle);
170 
171  bool ecol_legal(VHierarchyNodeHandle _parent_handle,
172  VDPMMesh::HalfedgeHandle& v0v1);
173 
174  void get_active_cuts(VHierarchyNodeHandle _node_handle,
176 
177  void vsplit(VHierarchyNodeHandle _node_handle,
179 
180  void ecol(VHierarchyNodeHandle _parent_handle,
181  const VDPMMesh::HalfedgeHandle& v0v1);
182 
183  void init_vfront();
184 
185 };
186 
187 
188 //=============================================================================
189 } // namespace OpenMesh
190 //=============================================================================
191 #endif // OPENMESHAPPS_VDPMSYNTHESIZERVIEWERWIDGET_HH defined
192 //=============================================================================
virtual void draw_scene(const std::string &_draw_mode)
inherited drawing method
void open_vd_prog_mesh(const char *_filename)
open view-dependent progressive mesh
std::vector< VHierarchyNodeHandle > VHierarchyNodeHandleContainer
Container for vertex hierarchy node handles.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136