Developer Documentation
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 
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  explicit Info( const CollapseInfo& _ci )
94  : v0(_ci.v0), v1(_ci.v1), vl(_ci.vl),vr(_ci.vr)
95  {}
96 
101 
102  };
103 
105  typedef std::vector<Info> InfoList;
106 
107 
108 public:
109 
111  explicit ModProgMeshT( MeshT &_mesh ) : Base(_mesh, true)
112  {
113  Base::mesh().add_property( idx_ );
114  }
115 
116 
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) override
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_;
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 
void postprocess_collapse(const CollapseInfo &_ci) override
bool write(const std::string &_ofname)
std::vector< Info > InfoList
Type of the list storing the progressive mesh info Info.
Mesh::VertexHandle vr
See CollapseInfoT::vr.
ModProgMeshT(MeshT &_mesh)
Constructor.
Mesh::VertexHandle v1
See CollapseInfoT::v1.
Definition: ModProgMeshT.hh:98
const InfoList & infolist() const
Reference to collected information.
Mesh::VertexHandle vl
See CollapseInfoT::vl.
Definition: ModProgMeshT.hh:99
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
Mesh::VertexHandle v0
See CollapseInfoT::v0.
Definition: ModProgMeshT.hh:97