Developer Documentation

ProgViewerWidget.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 #ifndef OPENMESHAPPS_PROGVIEWERWIDGET_HH
46 #define OPENMESHAPPS_PROGVIEWERWIDGET_HH
47
48
49 //== INCLUDES =================================================================
50
51 #include <QTimer>
52 #include <OpenMesh/Apps/QtViewer/MeshViewerWidgetT.hh>
53 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
54 #include <OpenMesh/Core/Mesh/Attributes.hh>
55 #include <string>
56
57
58
59 //== CLASS DEFINITION =========================================================
60
61
62 using namespace OpenMesh;
63 using namespace OpenMesh::Attributes;
64
65
66 struct MyTraits : public OpenMesh::DefaultTraits
67 {
68 VertexAttributes ( OpenMesh::Attributes::Normal |
69 OpenMesh::Attributes::Status );
70 EdgeAttributes ( OpenMesh::Attributes::Status );
71 HalfedgeAttributes( OpenMesh::Attributes::PrevHalfedge );
72 FaceAttributes ( OpenMesh::Attributes::Normal |
73 OpenMesh::Attributes::Status );
74 };
75
76
77 typedef OpenMesh::TriMesh_ArrayKernelT<MyTraits> MyMesh;
78 typedef MeshViewerWidgetT<MyMesh> MeshViewerWidget;
79
80
81 //== CLASS DEFINITION =========================================================
82
83
84
85 class ProgViewerWidget : public MeshViewerWidget
86 {
87 Q_OBJECT
88
89 public:
90
91 typedef MeshViewerWidget Base;
92 typedef ProgViewerWidget This;
93
94
95 public:
97 explicit ProgViewerWidget(QWidget* _parent=0)
98 : MeshViewerWidget(_parent),
99 n_base_vertices_(0),
100 n_base_faces_(0),
101 n_detail_vertices_(0),
102 n_max_vertices_(0)
103 {
104 timer_ = new QTimer(this);
105
106 connect( timer_, SIGNAL(timeout()), SLOT(animate()) );
107 }
108
110 ~ProgViewerWidget()
111 {
112 delete timer_;
113 }
114
116 void open_prog_mesh(const char* _filename);
117
118 protected slots:
119
120 void animate( void );
121
122 private:
123
124 QTimer *timer_;
125
126 struct PMInfo
127 {
128 MyMesh::Point p0;
129 MyMesh::VertexHandle v0, v1, vl, vr;
130 };
131 typedef std::vector<PMInfo> PMInfoContainer;
132 typedef PMInfoContainer::iterator PMInfoIter;
133
135 void refine(unsigned int _n);
136
138 void coarsen(unsigned int _n);
139
140 virtual void keyPressEvent(QKeyEvent* _event) override;
141
142 // mesh data
143 bool animateRefinement_;
144 PMInfoContainer pminfos_;
145 PMInfoIter pmiter_;
146 size_t n_base_vertices_, n_base_faces_, n_detail_vertices_;
147 size_t n_max_vertices_;
148 };
149
150
151 //=============================================================================
152 #endif // OPENMESHAPPS_PROGVIEWERWIDGET_HH defined
153 //=============================================================================
154
OpenMesh::Attributes::PrevHalfedge
Add storage for previous halfedge (halfedges). The bit is set by default in the DefaultTraits.
Definition: Attributes.hh:84
OpenMesh::PolyMeshT::Point
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:112
OpenMesh::TriMesh_ArrayKernelT
Definition: PolyMesh_ArrayKernelT.hh:73
MeshViewerWidget
Definition: MeshViewerWidget.hh:75
OpenMesh::Attributes::Status
Add status to mesh item (all items)
Definition: Attributes.hh:85
ProgViewerWidget
Definition: ProgViewerWidget.hh:85
OpenMesh::Attributes::Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:82
ProgViewerWidget::PMInfo
Definition: ProgViewerWidget.hh:126
OpenMesh
Definition: MeshItems.hh:59
VertexAttributes
#define VertexAttributes(_i)
Macro for defining the vertex attributes. See Specifying your MyMesh.
Definition: Traits.hh:79
EdgeAttributes
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.
Definition: Traits.hh:85
Attributes.hh
MeshViewerWidgetT< MyMesh >
OpenMesh::DefaultTraits
Definition: Traits.hh:121
HalfedgeAttributes
#define HalfedgeAttributes(_i)
Macro for defining the halfedge attributes. See Specifying your MyMesh.
Definition: Traits.hh:82
OpenMesh::Attributes
FaceAttributes
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Definition: Traits.hh:88
ProgViewerWidget::ProgViewerWidget
ProgViewerWidget(QWidget *_parent=0)
default constructor
Definition: ProgViewerWidget.hh:97
OpenMesh::PolyMeshT::VertexHandle
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
ProgViewerWidget::~ProgViewerWidget
~ProgViewerWidget()
destructor
Definition: ProgViewerWidget.hh:110