| OpenMesh

ModProgMeshT.hh
Go to the documentation of this file.
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
48 //=============================================================================
49 //
50 // CLASS ModProgMeshT
51 //
52 //=============================================================================
53
54 #ifndef OPENMESH_TOOLS_MODPROGMESHT_HH
55 #define OPENMESH_TOOLS_MODPROGMESHT_HH
56
57
58 //== INCLUDES =================================================================
59
60 #include <OpenMesh/Tools/Decimater/ModBaseT.hh>
61 #include <OpenMesh/Core/Utils/Property.hh>
62
63
64 //== NAMESPACE ================================================================
65
66 namespace OpenMesh {
67 namespace Decimater {
68
69
70 //== CLASS DEFINITION =========================================================
71
72
79 template <class MeshT>
80 class ModProgMeshT : public ModBaseT<MeshT>
81 {
82 public:
83
84 DECIMATING_MODULE( ModProgMeshT, MeshT, ProgMesh );
85
89 struct Info
90 {
93 Info( const CollapseInfo& _ci )
94 : v0(_ci.v0), v1(_ci.v1), vl(_ci.vl),vr(_ci.vr)
95 {}
96
97 typename Mesh::VertexHandle v0;
98 typename Mesh::VertexHandle v1;
99 typename Mesh::VertexHandle vl;
100 typename Mesh::VertexHandle vr;
101
102 };
103
105 typedef std::vector<Info> InfoList;
106
107
108 public:
109
111 ModProgMeshT( MeshT &_mesh ) : Base(_mesh, true)
112 {
113 Base::mesh().add_property( idx_ );
114 }
115
116
118 ~ModProgMeshT()
119 {
120 Base::mesh().remove_property( idx_ );
121 }
122
123 const InfoList& pmi() const
124 {
125 return pmi_;
126 }
127
128 public: // inherited
129
130
133 void postprocess_collapse(const CollapseInfo& _ci)
134 {
135 pmi_.push_back( Info( _ci ) );
136 }
137
138
139 bool is_binary(void) const { return true; }
140
141
142 public: // specific methods
143
168 bool write( const std::string& _ofname );
170 const InfoList& infolist() const { return pmi_; }
171
172 private:
173
174 // hide this method form user
175 void set_binary(bool _b) {}
176
177 InfoList pmi_;
178 VPropHandleT<size_t> idx_;
179 };
180
181
182 //=============================================================================
183 } // END_NS_DECIMATER
184 } // END_NS_OPENMESH
185 //=============================================================================
186 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_DECIMATER_MODPROGMESH_CC)
187 #define OSG_MODPROGMESH_TEMPLATES
188 #include "ModProgMeshT_impl.hh"
189 #endif
190 //=============================================================================
191 #endif // OPENMESH_TOOLS_PROGMESHT_HH defined
192 //=============================================================================
193
OpenMesh::Decimater::ModBaseT
Base class for all decimation modules.
Definition: ModBaseT.hh:192
OpenMesh::VPropHandleT< size_t >
OpenMesh::Decimater::ModProgMeshT::infolist
const InfoList & infolist() const
Reference to collected information.
Definition: ModProgMeshT.hh:170
OpenMesh::Decimater::ModProgMeshT::Info::vl
Mesh::VertexHandle vl
See CollapseInfoT::vl.
Definition: ModProgMeshT.hh:99
OpenMesh::Decimater::ModProgMeshT::Info::vr
Mesh::VertexHandle vr
See CollapseInfoT::vr.
Definition: ModProgMeshT.hh:100
DECIMATING_MODULE
#define DECIMATING_MODULE(Classname, MeshT, Name)
Convenience macro, to be used in derived modules The macro defines the types.
Definition: ModBaseT.hh:149
OpenMesh::Decimater::ModProgMeshT::Info::Info
Info(const CollapseInfo &_ci)
Initializing constructor copies appropriate handles from collapse information _ci.
Definition: ModProgMeshT.hh:93
ModProgMeshT_impl.hh
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
ModBaseT.hh
Base class for all decimation modules.
OpenMesh::Decimater::ModProgMeshT::Info::v1
Mesh::VertexHandle v1
See CollapseInfoT::v1.
Definition: ModProgMeshT.hh:98
OpenMesh::Decimater::ModProgMeshT::Info
Struct storing progressive mesh information.
Definition: ModProgMeshT.hh:89
OpenMesh::Decimater::ModProgMeshT::postprocess_collapse
void postprocess_collapse(const CollapseInfo &_ci)
Stores collapse information in a queue.
Definition: ModProgMeshT.hh:133
OpenMesh::Decimater::ModProgMeshT::Info::v0
Mesh::VertexHandle v0
See CollapseInfoT::v0.
Definition: ModProgMeshT.hh:97
OpenMesh::Decimater::ModProgMeshT::write
bool write(const std::string &_ofname)
Write progressive mesh data to a file in proprietary binary format .pm.
Definition: ModProgMeshT_impl.hh:82
OpenMesh::Decimater::CollapseInfoT
Stores information about a halfedge collapse.
Definition: CollapseInfoT.hh:74
OpenMesh::Decimater::ModProgMeshT::ModProgMeshT
ModProgMeshT(MeshT &_mesh)
Constructor.
Definition: ModProgMeshT.hh:111
OpenMesh::Decimater::ModProgMeshT::InfoList
std::vector< Info > InfoList
Type of the list storing the progressive mesh info Info.
Definition: ModProgMeshT.hh:105
OpenMesh::Decimater::ModProgMeshT::~ModProgMeshT
~ModProgMeshT()
Destructor.
Definition: ModProgMeshT.hh:118
OpenMesh::Decimater::ModProgMeshT
Collect progressive mesh information while decimating.
Definition: ModProgMeshT.hh:80