| OpenMesh

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 * $Revision$ *
45 * $Date$ *
46 * *
47 \*===========================================================================*/
48
49 //=============================================================================
50 //
51 // CLASS newClass
52 //
53 //=============================================================================
54
55
56 #ifndef OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
57 #define OPENMESH_VDPROGMESH_VDPMSYNTHESIZERVIEWERWIDGET_HH
58
59
60 //== INCLUDES =================================================================
61
62 #include <string>
63 #include <QTimer>
64
65 #include <OpenMesh/Core/IO/MeshIO.hh>
66 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
67 #include <OpenMesh/Apps/QtViewer/MeshViewerWidgetT.hh>
68
69 #include <OpenMesh/Tools/VDPM/MeshTraits.hh>
70 #include <OpenMesh/Tools/VDPM/StreamingDef.hh>
71 #include <OpenMesh/Tools/VDPM/ViewingParameters.hh>
72 #include <OpenMesh/Tools/VDPM/VHierarchy.hh>
73 #include <OpenMesh/Tools/VDPM/VFront.hh>
74
75
76 //== FORWARDDECLARATIONS ======================================================
77
78
79 //== NAMESPACES ===============================================================
80
81 namespace OpenMesh {
82
83
84 //== CLASS DEFINITION =========================================================
85
86
96 typedef TriMesh_ArrayKernelT<VDPM::MeshTraits> VDPMMesh;
97 typedef MeshViewerWidgetT<VDPMMesh> MeshViewerWidget;
98
99
100 // using view dependent progressive mesh
101
102 using VDPM::Plane3d;
103 using VDPM::VFront;
104 using VDPM::VHierarchy;
105 using VDPM::VHierarchyNode;
106 using VDPM::VHierarchyNodeIndex;
107 using VDPM::VHierarchyNodeHandle;
108 using VDPM::VHierarchyNodeHandleContainer;
109 using VDPM::ViewingParameters;
110
111
112 //== CLASS DEFINITION =========================================================
113
114
115 class VDPMSynthesizerViewerWidget : public MeshViewerWidget
116 {
117 public:
118
119 typedef MeshViewerWidget Base;
120
121 public:
122
123 VDPMSynthesizerViewerWidget(QWidget* _parent=0, const char* _name=0);
124
125 ~VDPMSynthesizerViewerWidget();
126
128 void open_vd_prog_mesh(const char* _filename);
129
130
131 private:
132
133 QString qFilename_;
134 VHierarchy vhierarchy_;
135 VFront vfront_;
136 ViewingParameters viewing_parameters_;
137 float kappa_square_;
138 bool adaptive_mode_;
139
140 unsigned int n_base_vertices_;
141 unsigned int n_base_edges_;
142 unsigned int n_base_faces_;
143 unsigned int n_details_;
144
145
146 private:
147
148 bool outside_view_frustum(const OpenMesh::Vec3f &pos, float radius);
149
150 bool oriented_away(float sin_square,
151 float distance_square,
152 float product_value);
153
154 bool screen_space_error(float mue_square,
155 float sigma_square,
156 float distance_square,
157 float product_value);
158
159 void update_viewing_parameters();
160
161 virtual void keyPressEvent(QKeyEvent* _event);
162
163 protected:
164
166 virtual void draw_scene(const std::string& _draw_mode);
167
168 public:
169
170 void adaptive_refinement();
171
172 bool qrefine(VHierarchyNodeHandle _node_handle);
173
174 void force_vsplit(VHierarchyNodeHandle _node_handle);
175
176 bool ecol_legal(VHierarchyNodeHandle _parent_handle,
177 VDPMMesh::HalfedgeHandle& v0v1);
178
179 void get_active_cuts(VHierarchyNodeHandle _node_handle,
180 VDPMMesh::VertexHandle &vl, VDPMMesh::VertexHandle &vr);
181
182 void vsplit(VHierarchyNodeHandle _node_handle,
183 VDPMMesh::VertexHandle vl, VDPMMesh::VertexHandle vr);
184
185 void ecol(VHierarchyNodeHandle _parent_handle,
186 const VDPMMesh::HalfedgeHandle& v0v1);
187
188 void init_vfront();
189
190 };
191
192
193 //=============================================================================
194 } // namespace OpenMesh
195 //=============================================================================
196 #endif // OPENMESHAPPS_VDPMSYNTHESIZERVIEWERWIDGET_HH defined
197 //=============================================================================
MeshViewerWidgetT
Definition: MeshViewerWidgetT.hh:76
OpenMesh::VDPMSynthesizerViewerWidget::draw_scene
virtual void draw_scene(const std::string &_draw_mode)
inherited drawing method
Definition: VDPMSynthesizerViewerWidget.cc:105
OpenMesh::PolyMeshT::VertexHandle
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139
MeshViewerWidget
Definition: MeshViewerWidget.hh:80
OpenMesh::VectorT< float, 3 >
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
OpenMesh::VDPM::VHierarchyNodeHandleContainer
std::vector< VHierarchyNodeHandle > VHierarchyNodeHandleContainer
Container for vertex hierarchy node handles.
Definition: VHierarchyNode.hh:188
OpenMesh::VDPMSynthesizerViewerWidget::open_vd_prog_mesh
void open_vd_prog_mesh(const char *_filename)
open view-dependent progressive mesh
Definition: VDPMSynthesizerViewerWidget.cc:388
OpenMesh::VDPMSynthesizerViewerWidget
Definition: VDPMSynthesizerViewerWidget.hh:115