OpenMesh
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
ModBaseT.hh
Go to the documentation of this file.
1
/*===========================================================================*\
2
* *
3
* OpenMesh *
4
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
5
* www.openmesh.org *
6
* *
7
*---------------------------------------------------------------------------*
8
* This file is part of OpenMesh. *
9
* *
10
* OpenMesh is free software: you can redistribute it and/or modify *
11
* it under the terms of the GNU Lesser General Public License as *
12
* published by the Free Software Foundation, either version 3 of *
13
* the License, or (at your option) any later version with the *
14
* following exceptions: *
15
* *
16
* If other files instantiate templates or use macros *
17
* or inline functions from this file, or you compile this file and *
18
* link it with other files to produce an executable, this file does *
19
* not by itself cause the resulting executable to be covered by the *
20
* GNU Lesser General Public License. This exception does not however *
21
* invalidate any other reasons why the executable file might be *
22
* covered by the GNU Lesser General Public License. *
23
* *
24
* OpenMesh is distributed in the hope that it will be useful, *
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27
* GNU Lesser General Public License for more details. *
28
* *
29
* You should have received a copy of the GNU LesserGeneral Public *
30
* License along with OpenMesh. If not, *
31
* see <http://www.gnu.org/licenses/>. *
32
* *
33
\*===========================================================================*/
34
35
/*===========================================================================*\
36
* *
37
* $Revision: 448 $ *
38
* $Date: 2011-11-04 13:59:37 +0100 (Fr, 04 Nov 2011) $ *
39
* *
40
\*===========================================================================*/
41
46
//=============================================================================
47
//
48
// CLASS ModBaseT
49
//
50
//=============================================================================
51
52
#ifndef OPENMESH_DECIMATER_MODBASET_HH
53
#define OPENMESH_DECIMATER_MODBASET_HH
54
55
56
//== INCLUDES =================================================================
57
58
#include <OpenMesh/Core/Utils/Noncopyable.hh>
59
#include <
OpenMesh/Tools/Decimater/CollapseInfoT.hh
>
60
#include <string>
61
62
63
//== NAMESPACE ================================================================
64
65
namespace
OpenMesh {
66
namespace
Decimater {
67
68
69
//== FORWARD DECLARATIONS =====================================================
70
71
template
<
typename
Mesh>
class
DecimaterT;
72
73
74
//== CLASS DEFINITION =========================================================
75
79
template
<
typename
Module>
80
class
ModHandleT
:
private
Utils::Noncopyable
81
{
82
public
:
83
84
typedef
ModHandleT<Module>
Self
;
85
typedef
Module module_type;
86
87
public
:
88
90
ModHandleT
() : mod_(NULL) {}
91
93
~ModHandleT
() {
/* don't delete mod_, since handle is not owner! */
}
94
97
bool
is_valid
()
const
{
return
mod_ != NULL; }
98
99
private
:
100
101
#if defined(OM_CC_MSVC)
102
friend
class
DecimaterT
;
103
#else
104
template
<
typename
Mesh>
friend
class
DecimaterT
;
105
#endif
106
107
void
clear() { mod_ = NULL; }
108
void
init(Module* _m) { mod_ = _m; }
109
Module* module() {
return
mod_; }
110
111
112
private
:
113
114
Module* mod_;
115
116
};
117
118
119
120
121
//== CLASS DEFINITION =========================================================
122
123
124
127
#define DECIMATER_MODNAME(_mod_name) \
128
virtual const std::string& name() const { \
129
static std::string _s_modname_(#_mod_name); return _s_modname_; \
130
}
131
132
146
#define DECIMATING_MODULE(Classname, DecimaterT, Name) \
147
typedef Classname < DecimaterT > Self; \
148
typedef OpenMesh::Decimater::ModHandleT< Self > Handle; \
149
typedef OpenMesh::Decimater::ModBaseT< DecimaterT > Base; \
150
typedef typename Base::Mesh Mesh; \
151
typedef typename Base::CollapseInfo CollapseInfo; \
152
DECIMATER_MODNAME( Name )
153
154
155
156
//== CLASS DEFINITION =========================================================
157
158
187
template
<
typename
DecimaterType>
188
class
ModBaseT
189
{
190
public
:
191
192
typedef
typename
DecimaterType::Mesh Mesh;
193
typedef
CollapseInfoT<Mesh>
CollapseInfo
;
194
195
enum
{
196
ILLEGAL_COLLAPSE = -1,
197
LEGAL_COLLAPSE = 0
198
};
199
200
protected
:
201
204
ModBaseT
(DecimaterType& _dec,
bool
_is_binary)
205
: dec_(_dec), is_binary_(_is_binary) {}
206
207
public
:
208
210
virtual
~ModBaseT
() { }
211
213
DECIMATER_MODNAME
(ModBase);
214
215
217
bool
is_binary
(
void
)
const
{
return
is_binary_; }
218
220
void
set_binary
(
bool
_b) { is_binary_ = _b; }
221
222
223
public
:
// common interface
224
226
virtual
void
initialize
() { }
227
242
virtual
float
collapse_priority(
const
CollapseInfoT<Mesh>
&
/* _ci */
)
243
{
return
LEGAL_COLLAPSE; }
244
248
virtual
void
preprocess_collapse(
const
CollapseInfoT<Mesh>
&
/* _ci */
)
249
{}
250
254
virtual
void
postprocess_collapse(
const
CollapseInfoT<Mesh>
&
/* _ci */
)
255
{}
256
257
258
259
protected
:
260
262
Mesh&
mesh
() {
return
dec_.mesh(); }
263
264
private
:
265
266
// hide copy constructor & assignemnt
267
ModBaseT
(
const
ModBaseT
& _cpy);
268
ModBaseT
& operator=(
const
ModBaseT
& );
269
270
// reference to decimater
271
DecimaterType &dec_;
272
273
bool
is_binary_;
274
};
275
276
277
//=============================================================================
278
}
// namespace Decimater
279
}
// namespace OpenMesh
280
//=============================================================================
281
#endif // OPENMESH_DECIMATER_MODBASE_HH defined
282
//=============================================================================
283
Project
OpenMesh
, © Computer Graphics Group, RWTH Aachen. Documentation generated using
doxygen
.