OpenMesh
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>
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 {
74 };
75 
76 
79 
80 
81 //== CLASS DEFINITION =========================================================
82 
83 
84 
86 {
87  Q_OBJECT
88 
89 public:
90 
91  typedef MeshViewerWidget Base;
92  typedef ProgViewerWidget This;
93 
94 
95 public:
97  ProgViewerWidget(QWidget* _parent=0)
98  : MeshViewerWidget(_parent)
99  {
100  timer_ = new QTimer(this);
101 
102  connect( timer_, SIGNAL(timeout()), SLOT(animate()) );
103  }
104 
107  {
108  delete timer_;
109  }
110 
112  void open_prog_mesh(const char* _filename);
113 
114 protected slots:
115 
116 void animate( void );
117 
118 private:
119 
120  QTimer *timer_;
121 
122  struct PMInfo
123  {
124  MyMesh::Point p0;
125  MyMesh::VertexHandle v0, v1, vl, vr;
126  };
127  typedef std::vector<PMInfo> PMInfoContainer;
128  typedef PMInfoContainer::iterator PMInfoIter;
129 
131  void refine(unsigned int _n);
132 
134  void coarsen(unsigned int _n);
135 
136  virtual void keyPressEvent(QKeyEvent* _event);
137 
138  // mesh data
139  bool animateRefinement_;
140  PMInfoContainer pminfos_;
141  PMInfoIter pmiter_;
142  size_t n_base_vertices_, n_base_faces_, n_detail_vertices_;
143  size_t n_max_vertices_;
144 };
145 
146 
147 //=============================================================================
148 #endif // OPENMESHAPPS_PROGVIEWERWIDGET_HH defined
149 //=============================================================================
150 
#define VertexAttributes(_i)
Macro for defining the vertex attributes. See Specifying your MyMesh.
Definition: Traits.hh:79
Base class for all traits.
Definition: Traits.hh:121
Add status to mesh item (all items)
Definition: Attributes.hh:85
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Definition: Traits.hh:88
Add storage for previous halfedge (halfedges). The bit is set by default in the DefaultTraits.
Definition: Attributes.hh:84
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:82
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.
Definition: Traits.hh:85
This file provides some macros containing attribute usage.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
Triangle mesh based on the ArrayKernel.
Definition: PolyMesh_ArrayKernelT.hh:73
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
~ProgViewerWidget()
destructor
Definition: ProgViewerWidget.hh:106
This namespace holds per item attributes like normal/color.
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:112
ProgViewerWidget(QWidget *_parent=0)
default constructor
Definition: ProgViewerWidget.hh:97
Definition: ProgViewerWidget.hh:85
Polygonal mesh based on the ArrayKernel.
Definition: PolyMesh_ArrayKernelT.hh:94
#define HalfedgeAttributes(_i)
Macro for defining the halfedge attributes. See Specifying your MyMesh.
Definition: Traits.hh:82
Definition: MeshViewerWidget.hh:75

Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .