1 #ifndef OPENMESH_PYTHON_DECIMATER_HH
2 #define OPENMESH_PYTHON_DECIMATER_HH
9 #include "OpenMesh/Tools/Decimater/ModIndependentSetsT.hh"
22 #define INIT_MESH_REF init<Mesh&>()[with_custodian_and_ward<1,2>()]
24 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(decimate_overloads, decimate, 0, 1)
25 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(decimate_to_faces_overloads, decimate_to_faces, 0, 2)
26 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_max_err_overloads, set_max_err, 1, 2)
27 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_min_roundness_overloads, set_min_roundness, 1, 2)
30 template <class Handle>
31 void expose_module_handle(const
char *_name) {
32 class_<Handle, boost::noncopyable>(_name)
33 .def(
"is_valid", &Handle::is_valid)
37 template <
class Module>
38 list infolist(Module& _self) {
39 const typename Module::InfoList& infos = _self.infolist();
41 for (
size_t i = 0; i < infos.size(); ++i) {
48 void expose_decimater(
const char *_name) {
50 typedef Decimater::ModBaseT<Mesh> ModBase;
51 typedef Decimater::ModAspectRatioT<Mesh> ModAspectRatio;
52 typedef Decimater::ModEdgeLengthT<Mesh> ModEdgeLength;
53 typedef Decimater::ModHausdorffT<Mesh> ModHausdorff;
54 typedef Decimater::ModIndependentSetsT<Mesh> ModIndependentSets;
55 typedef Decimater::ModNormalDeviationT<Mesh> ModNormalDeviation;
56 typedef Decimater::ModNormalFlippingT<Mesh> ModNormalFlipping;
57 typedef Decimater::ModProgMeshT<Mesh> ModProgMesh;
58 typedef Decimater::ModQuadricT<Mesh> ModQuadric;
59 typedef Decimater::ModRoundnessT<Mesh> ModRoundness;
61 typedef Decimater::ModHandleT<ModAspectRatio> ModAspectRatioHandle;
62 typedef Decimater::ModHandleT<ModEdgeLength> ModEdgeLengthHandle;
63 typedef Decimater::ModHandleT<ModHausdorff> ModHausdorffHandle;
64 typedef Decimater::ModHandleT<ModIndependentSets> ModIndependentSetsHandle;
65 typedef Decimater::ModHandleT<ModNormalDeviation> ModNormalDeviationHandle;
66 typedef Decimater::ModHandleT<ModNormalFlipping> ModNormalFlippingHandle;
67 typedef Decimater::ModHandleT<ModProgMesh> ModProgMeshHandle;
68 typedef Decimater::ModHandleT<ModQuadric> ModQuadricHandle;
69 typedef Decimater::ModHandleT<ModRoundness> ModRoundnessHandle;
71 typedef Decimater::BaseDecimaterT<Mesh> BaseDecimater;
72 typedef Decimater::DecimaterT<Mesh> Decimater;
74 typedef typename ModProgMesh::Info Info;
75 typedef std::vector<Info> InfoList;
77 bool (BaseDecimater::*add1)(ModAspectRatioHandle&) = &Decimater::add;
78 bool (BaseDecimater::*add2)(ModEdgeLengthHandle&) = &Decimater::add;
79 bool (BaseDecimater::*add3)(ModHausdorffHandle&) = &Decimater::add;
80 bool (BaseDecimater::*add4)(ModIndependentSetsHandle&) = &Decimater::add;
81 bool (BaseDecimater::*add5)(ModNormalDeviationHandle&) = &Decimater::add;
82 bool (BaseDecimater::*add6)(ModNormalFlippingHandle&) = &Decimater::add;
83 bool (BaseDecimater::*add7)(ModProgMeshHandle&) = &Decimater::add;
84 bool (BaseDecimater::*add8)(ModQuadricHandle&) = &Decimater::add;
85 bool (BaseDecimater::*add9)(ModRoundnessHandle&) = &Decimater::add;
87 bool (BaseDecimater::*remove1)(ModAspectRatioHandle&) = &Decimater::remove;
88 bool (BaseDecimater::*remove2)(ModEdgeLengthHandle&) = &Decimater::remove;
89 bool (BaseDecimater::*remove3)(ModHausdorffHandle&) = &Decimater::remove;
90 bool (BaseDecimater::*remove4)(ModIndependentSetsHandle&) = &Decimater::remove;
91 bool (BaseDecimater::*remove5)(ModNormalDeviationHandle&) = &Decimater::remove;
92 bool (BaseDecimater::*remove6)(ModNormalFlippingHandle&) = &Decimater::remove;
93 bool (BaseDecimater::*remove7)(ModProgMeshHandle&) = &Decimater::remove;
94 bool (BaseDecimater::*remove8)(ModQuadricHandle&) = &Decimater::remove;
95 bool (BaseDecimater::*remove9)(ModRoundnessHandle&) = &Decimater::remove;
97 ModAspectRatio& (BaseDecimater::*module1)(ModAspectRatioHandle&) = &Decimater::module;
98 ModEdgeLength& (BaseDecimater::*module2)(ModEdgeLengthHandle&) = &Decimater::module;
99 ModHausdorff& (BaseDecimater::*module3)(ModHausdorffHandle&) = &Decimater::module;
100 ModIndependentSets& (BaseDecimater::*module4)(ModIndependentSetsHandle&) = &Decimater::module;
101 ModNormalDeviation& (BaseDecimater::*module5)(ModNormalDeviationHandle&) = &Decimater::module;
102 ModNormalFlipping& (BaseDecimater::*module6)(ModNormalFlippingHandle&) = &Decimater::module;
103 ModProgMesh& (BaseDecimater::*module7)(ModProgMeshHandle&) = &Decimater::module;
104 ModQuadric& (BaseDecimater::*module8)(ModQuadricHandle&) = &Decimater::module;
105 ModRoundness& (BaseDecimater::*module9)(ModRoundnessHandle&) = &Decimater::module;
111 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"Decimater");
113 class_<Decimater, boost::noncopyable>(buffer, INIT_MESH_REF)
114 .def(
"decimate", &Decimater::decimate, decimate_overloads())
115 .def(
"decimate_to", &Decimater::decimate_to)
116 .def(
"decimate_to_faces", &Decimater::decimate_to_faces, decimate_to_faces_overloads())
118 .def(
"initialize", &Decimater::initialize)
119 .def(
"is_initialized", &Decimater::is_initialized)
131 .def(
"remove", remove1)
132 .def(
"remove", remove2)
133 .def(
"remove", remove3)
134 .def(
"remove", remove4)
135 .def(
"remove", remove5)
136 .def(
"remove", remove6)
137 .def(
"remove", remove7)
138 .def(
"remove", remove8)
139 .def(
"remove", remove9)
141 .def(
"module", module1, return_value_policy<reference_existing_object>())
142 .def(
"module", module2, return_value_policy<reference_existing_object>())
143 .def(
"module", module3, return_value_policy<reference_existing_object>())
144 .def(
"module", module4, return_value_policy<reference_existing_object>())
145 .def(
"module", module5, return_value_policy<reference_existing_object>())
146 .def(
"module", module6, return_value_policy<reference_existing_object>())
147 .def(
"module", module7, return_value_policy<reference_existing_object>())
148 .def(
"module", module8, return_value_policy<reference_existing_object>())
149 .def(
"module", module9, return_value_policy<reference_existing_object>())
155 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModBase");
157 class_<ModBase, boost::noncopyable>(buffer, no_init)
159 .def(
"is_binary", &ModBase::is_binary)
160 .def(
"set_binary", &ModBase::set_binary)
161 .def(
"initialize", &ModBase::initialize)
162 .def(
"collapse_priority", &ModBase::collapse_priority)
163 .def(
"preprocess_collapse", &ModBase::preprocess_collapse)
164 .def(
"postprocess_collapse", &ModBase::postprocess_collapse)
165 .def(
"set_error_tolerance_factor", &ModBase::set_error_tolerance_factor)
171 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModAspectRatio");
173 class_<ModAspectRatio, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
174 .def(
"aspect_ratio", &ModAspectRatio::aspect_ratio)
175 .def(
"set_aspect_ratio", &ModAspectRatio::set_aspect_ratio)
178 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModAspectRatioHandle");
179 expose_module_handle<ModAspectRatioHandle>(buffer);
184 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModEdgeLength");
186 class_<ModEdgeLength, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
187 .def(
"edge_length", &ModEdgeLength::edge_length)
188 .def(
"set_edge_length", &ModEdgeLength::set_edge_length)
191 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModEdgeLengthHandle");
192 expose_module_handle<ModEdgeLengthHandle>(buffer);
197 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModHausdorff");
199 class_<ModHausdorff, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
200 .def(
"tolerance", &ModHausdorff::tolerance)
201 .def(
"set_tolerance", &ModHausdorff::set_tolerance)
204 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModHausdorffHandle");
205 expose_module_handle<ModHausdorffHandle>(buffer);
210 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModIndependentSets");
212 class_<ModIndependentSets, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF);
214 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModIndependentSetsHandle");
215 expose_module_handle<ModIndependentSetsHandle>(buffer);
220 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModNormalDeviation");
222 class_<ModNormalDeviation, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
223 .def(
"normal_deviation", &ModNormalDeviation::normal_deviation)
224 .def(
"set_normal_deviation", &ModNormalDeviation::set_normal_deviation)
227 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModNormalDeviationHandle");
228 expose_module_handle<ModNormalDeviationHandle>(buffer);
233 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModNormalFlipping");
235 class_<ModNormalFlipping, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
236 .def(
"max_normal_deviation", &ModNormalFlipping::max_normal_deviation)
237 .def(
"set_max_normal_deviation", &ModNormalFlipping::set_max_normal_deviation)
240 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModNormalFlippingHandle");
241 expose_module_handle<ModNormalFlippingHandle>(buffer);
246 class_<Info>(
"Info", no_init)
247 .def_readwrite(
"v0", &Info::v0)
248 .def_readwrite(
"v1", &Info::v1)
249 .def_readwrite(
"vl", &Info::vl)
250 .def_readwrite(
"vr", &Info::vr)
253 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModProgMesh");
255 class_<ModProgMesh, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
256 .def(
"pmi", &infolist<ModProgMesh>)
257 .def(
"infolist", &infolist<ModProgMesh>)
258 .def(
"write", &ModProgMesh::write)
261 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModProgMeshHandle");
262 expose_module_handle<ModProgMeshHandle>(buffer);
267 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModQuadric");
269 class_<ModQuadric, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
270 .def(
"set_max_err", &ModQuadric::set_max_err, set_max_err_overloads())
271 .def(
"unset_max_err", &ModQuadric::unset_max_err)
272 .def(
"max_err", &ModQuadric::max_err)
275 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModQuadricHandle");
276 expose_module_handle<ModQuadricHandle>(buffer);
281 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModRoundness");
283 class_<ModRoundness, bases<ModBase>, boost::noncopyable>(buffer, INIT_MESH_REF)
284 .def(
"set_min_angle", &ModRoundness::set_min_angle)
285 .def(
"set_min_roundness", &ModRoundness::set_min_roundness, set_min_roundness_overloads())
286 .def(
"unset_min_roundness", &ModRoundness::unset_min_roundness)
287 .def(
"roundness", &ModRoundness::roundness)
290 snprintf(buffer,
sizeof buffer,
"%s%s", _name,
"ModRoundnessHandle");
291 expose_module_handle<ModRoundnessHandle>(buffer);
#define OPENMESH_PYTHON_DEFAULT_POLICY