Mesh.hh 59.3 KB
Newer Older
1
2
3
#ifndef OPENMESH_PYTHON_MESH_HH
#define OPENMESH_PYTHON_MESH_HH

Alexander Dielen's avatar
Alexander Dielen committed
4
#include "Utilities.hh"
5
#include "MeshTypes.hh"
6
7
8
#include "Iterator.hh"
#include "Circulator.hh"

9
10
#include <algorithm>

Alexander Dielen's avatar
Alexander Dielen committed
11
12
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
13

Alexander Dielen's avatar
Alexander Dielen committed
14
15
namespace py = pybind11;
namespace OM = OpenMesh;
16

17

18
19
20
21
22
23
/**
 * Return value policy for functions that return references to objects that are
 * managed by %OpenMesh.
 */
#define OPENMESH_PYTHON_DEFAULT_POLICY py::return_value_policy::copy

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
 * Set the status of an item.
 *
 * @tparam Mesh A mesh type.
 * @tparam PropHandle A handle type.
 *
 * @param _self The mesh instance that is to be used.
 * @param _h The handle of the item whose status is to be set.
 * @param _info The status to be set.
 *
 * Depending on @ref OPENMESH_PYTHON_DEFAULT_POLICY, Mesh::status may
 * return by value instead of reference. This function ensures that the
 * status of an item can be changed nonetheless.
 */
template <class Mesh, class IndexHandle>
void set_status(Mesh& _self, IndexHandle _h, const OpenMesh::Attributes::StatusInfo& _info) {
	_self.status(_h) = _info;
}

/**
 * Set the value of a property of an item.
 *
 * @tparam Mesh A mesh type.
 * @tparam PropHandle A property handle type.
 * @tparam IndexHandle The appropriate handle type.
 *
 * @param _self The mesh instance that is to be used.
 * @param _ph The property that is to be set.
 * @param _h The handle of the item whose property is to be set.
 * @param _value The value to be set.
 *
 * Depending on @ref OPENMESH_PYTHON_DEFAULT_POLICY, Mesh::property may
 * return by value instead of reference. This function ensures that the
 * property value of an item can be changed nonetheless.
 */
template <class Mesh, class PropHandle, class IndexHandle>
Alexander Dielen's avatar
Alexander Dielen committed
60
void set_property(Mesh& _self, PropHandle _ph, IndexHandle _h, const py::object& _value) {
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	_self.property(_ph, _h) = _value;
}

/**
 * Set the value of a mesh property.
 *
 * @tparam Mesh A mesh type.
 * @tparam PropHandle A property handle type.
 *
 * @param _self The mesh instance that is to be used.
 * @param _ph The property that is to be set.
 * @param _value The value to be set.
 *
 * Depending on @ref OPENMESH_PYTHON_DEFAULT_POLICY, Mesh::property may
 * return by value instead of reference. This function ensures that the
 * property value of an item can be changed nonetheless.
 */
template <class Mesh, class PropHandle>
Alexander Dielen's avatar
Alexander Dielen committed
79
void set_property(Mesh& _self, PropHandle _ph, const py::object& _value) {
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	_self.property(_ph) = _value;
}

/**
 * Thin wrapper for assign_connectivity.
 *
 * @tparam Mesh A mesh type.
 * @tparam OtherMesh A mesh type.
 *
 * @param _self The mesh instance that is to be used.
 * @param _other The mesh from which the connectivity is to be copied.
 */
template <class Mesh, class OtherMesh>
void assign_connectivity(Mesh& _self, const OtherMesh& _other) {
	_self.assign_connectivity(_other);
}

/**
 * Get an iterator.
 */
Alexander Dielen's avatar
Alexander Dielen committed
100
template <class Mesh, class Iterator, size_t (OM::ArrayKernel::*n_items)() const>
101
102
103
104
105
106
107
IteratorWrapperT<Iterator, n_items> get_iterator(Mesh& _self) {
	return IteratorWrapperT<Iterator, n_items>(_self, typename Iterator::value_type(0));
}

/**
 * Get a skipping iterator.
 */
Alexander Dielen's avatar
Alexander Dielen committed
108
template <class Mesh, class Iterator, size_t (OM::ArrayKernel::*n_items)() const>
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
IteratorWrapperT<Iterator, n_items> get_skipping_iterator(Mesh& _self) {
	return IteratorWrapperT<Iterator, n_items>(_self, typename Iterator::value_type(0), true);
}

/**
 * Get a circulator.
 *
 * @tparam Mesh A Mesh type.
 * @tparam Circulator A circulator type.
 * @tparam CenterEntityHandle The appropriate handle type.
 *
 * @param _self The mesh instance that is to be used.
 * @param _handle The handle of the item to circulate around.
 */
template <class Mesh, class Circulator, class CenterEntityHandle>
CirculatorWrapperT<Circulator, CenterEntityHandle> get_circulator(Mesh& _self, CenterEntityHandle _handle) {
	return CirculatorWrapperT<Circulator, CenterEntityHandle>(_self, _handle);
}

/**
 * Garbage collection using lists instead of vectors to keep track of a set of
 * handles.
 *
 * @tparam Mesh A Mesh type.
 *
 * @param _self The mesh instance that is to be used.
 * @param _vh_to_update The list of vertex handles to be updated.
 * @param _hh_to_update The list of halfedge handles to be updated.
 * @param _fh_to_update The list of face handles to be updated.
 * @param _v Remove deleted vertices?
 * @param _e Remove deleted edges?
 * @param _f Remove deleted faces?
 */
template <class Mesh>
Alexander Dielen's avatar
Alexander Dielen committed
143
void garbage_collection(Mesh& _self, py::list& _vh_to_update, py::list& _hh_to_update, py::list& _fh_to_update, bool _v = true, bool _e = true, bool _f = true) {
144
	// Convert list of handles to vector of pointers
Alexander Dielen's avatar
Alexander Dielen committed
145
146
147
148
149
150
	std::vector<OM::VertexHandle*> vh_vector;
	for (auto item : _vh_to_update) {
		if (py::isinstance<OM::VertexHandle>(item)) {
			vh_vector.push_back(item.cast<OM::VertexHandle*>());
		}
	}
151
152

	// Convert list of handles to vector of pointers
Alexander Dielen's avatar
Alexander Dielen committed
153
154
155
156
157
158
	std::vector<OM::HalfedgeHandle*> hh_vector;
	for (auto item : _hh_to_update) {
		if (py::isinstance<OM::HalfedgeHandle>(item)) {
			hh_vector.push_back(item.cast<OM::HalfedgeHandle*>());
		}
	}
159
160

	// Convert list of handles to vector of pointers
Alexander Dielen's avatar
Alexander Dielen committed
161
162
163
164
165
166
	std::vector<OM::FaceHandle*> fh_vector;
	for (auto item : _fh_to_update) {
		if (py::isinstance<OM::FaceHandle>(item)) {
			fh_vector.push_back(item.cast<OM::FaceHandle*>());
		}
	}
167
168
169
170
171
172
173
174
175
176
177
178
179
180

	// Call garbage collection
	_self.garbage_collection(vh_vector, hh_vector, fh_vector, _v, _e, _f);
}

/**
 * Add a new face from a %Python list of vertex handles.
 *
 * @tparam Mesh A Mesh type.
 *
 * @param _self The mesh instance that is to be used.
 * @param _vhandles The list of vertex handles.
 */
template<class Mesh>
Alexander Dielen's avatar
Alexander Dielen committed
181
182
183
184
185
186
187
188
OM::FaceHandle add_face(Mesh& _self, const py::list& _vhandles) {
	// TODO Use automatic conversion instead?
	std::vector<OM::VertexHandle> vector;
	for (auto item : _vhandles) {
		if (py::isinstance<OM::VertexHandle>(item)) {
			vector.push_back(item.cast<OM::VertexHandle>());
		}
	}
189
190
191
	return _self.add_face(vector);
}

192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**
 * Converts OpenMesh vectors to numpy arrays.
 *
 * @tparam vector A Vector type.
 * @param _vec The vector to be converted.
 */
template<class Vector>
py::array_t<typename Vector::value_type> vec2numpy(const Vector& _vec) {
	typedef typename Vector::value_type dtype;
	dtype *data = new dtype[_vec.size()];
	std::copy_n(_vec.data(), _vec.size(), data);
	py::capsule base = free_when_done(data);
	return py::array_t<dtype>({_vec.size()}, {sizeof(dtype)}, data, base);
}

207
/**
Alexander Dielen's avatar
Alexander Dielen committed
208
 * Converts OpenMesh vectors to numpy arrays.
209
 *
Alexander Dielen's avatar
Alexander Dielen committed
210
211
 * The returned array references the vector's underlying data, i.e. changes
 * made to the returned array affect the original mesh.
212
213
 *
 * @tparam Mesh A Mesh type.
Alexander Dielen's avatar
Alexander Dielen committed
214
 * @tparam vector A Vector type.
215
 *
Alexander Dielen's avatar
Alexander Dielen committed
216
217
218
219
 * @param _mesh The mesh that owns the vector's underlying memory. In order
 * to avaoid dangling pointers, the lifetime of this mesh is tied to the
 * lifetime of the returned numpy array.
 * @param _vec The vector to be converted.
220
 */
Alexander Dielen's avatar
Alexander Dielen committed
221
template<class Mesh, class Vector>
222
py::array_t<typename Vector::value_type> vec2numpy(Mesh& _mesh, Vector& _vec, size_t _n = 1) {
Alexander Dielen's avatar
Alexander Dielen committed
223
	typedef typename Vector::value_type dtype;
224
225
226
227
228
229
230
231
232
233
234
	std::vector<size_t> shape;
	std::vector<size_t> strides;
	if (_n == 1) {
		shape = {_vec.size()};
		strides = {sizeof(dtype)};
	}
	else {
		shape = {_n, _vec.size()};
		strides = {_vec.size() * sizeof(dtype), sizeof(dtype)};
	}
	return py::array_t<dtype>(shape, strides, _vec.data(), py::cast(_mesh));
Alexander Dielen's avatar
Alexander Dielen committed
235
236
237
}

template<class Mesh>
238
239
py::array_t<float> flt2numpy(Mesh& _mesh, const float& _flt, size_t _n = 1) {
	return py::array_t<float>({_n}, {sizeof(float)}, &_flt, py::cast(_mesh));
Alexander Dielen's avatar
Alexander Dielen committed
240
241
}

242
template<class Mesh>
243
244
py::array_t<double> flt2numpy(Mesh& _mesh, const double& _flt, size_t _n = 1) {
	return py::array_t<double>({_n}, {sizeof(double)}, &_flt, py::cast(_mesh));
245
246
}

247
248
249
250
251
252
/**
 * Returns the face indices of this mesh as a numpy array.
 *
 * Note that the array is constructed on the fly and does not
 * reference the underlying mesh.
 */
253
py::array_t<int> face_vertex_indices_trimesh(TriMesh& _self) {
254
255
256
257
258
259
260
261
262
263
264
265
	if (_self.n_faces() == 0) {
		return py::array_t<int>();
	}
	int *indices = new int[_self.n_faces() * 3];
	for (auto fh : _self.faces()) {
		auto fv_it = _self.fv_iter(fh);
		indices[fh.idx() * 3 + 0] = fv_it->idx(); ++fv_it;
		indices[fh.idx() * 3 + 1] = fv_it->idx(); ++fv_it;
		indices[fh.idx() * 3 + 2] = fv_it->idx();
	}
	const auto shape = {_self.n_faces(), size_t(3)};
	const auto strides = {3 * sizeof(int), sizeof(int)};
266
267
	py::capsule base = free_when_done(indices);
	return py::array_t<int>(shape, strides, indices, base);
268
269
270
271
272
273
274
275
276
277
278
}

/**
 * Returns the face indices of this mesh as a numpy array.
 *
 * If the faces of the mesh have different valences, the array
 * is padded with -1 entries.
 *
 * Note that the array is constructed on the fly and does not
 * reference the underlying mesh.
 */
279
py::array_t<int> face_vertex_indices_polymesh(PolyMesh& _self) {
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
	if (_self.n_faces() == 0) {
		return py::array_t<int>();
	}
	int max_valence = 0;
	for (auto fh : _self.faces()) {
		max_valence = std::max(max_valence, int(_self.valence(fh)));
	}
	int *indices = new int[_self.n_faces() * max_valence];
	for (auto fh : _self.faces()) {
		auto fv_it = _self.fv_iter(fh);
		const int valence = _self.valence(fh);
		for (int i = 0; i < valence; ++i) {
			indices[fh.idx() * max_valence + i] = fv_it->idx();
			++fv_it;
		}
		for (int i = valence; i < max_valence; ++i) {
			indices[fh.idx() * max_valence + i] = -1;
		}
	}
	const auto shape = {_self.n_faces(), size_t(max_valence)};
	const auto strides = {max_valence * sizeof(int), sizeof(int)};
301
302
	py::capsule base = free_when_done(indices);
	return py::array_t<int>(shape, strides, indices, base);
303
304
}

305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/**
 * Returns the edge indices of this mesh as a numpy array.
 *
 * Note that the array is constructed on the fly and does not
 * reference the underlying mesh.
 */
template<class Mesh>
py::array_t<int> edge_vertex_indices(Mesh& _self) {
	if (_self.n_edges() == 0) {
		return py::array_t<int>();
	}
	int *indices = new int[_self.n_edges() * 2];
	for (auto eh : _self.edges()) {
		auto heh = _self.halfedge_handle(eh, 0);
		auto vh1 = _self.from_vertex_handle(heh);
		auto vh2 = _self.to_vertex_handle(heh);
		indices[eh.idx() * 2 + 0] = vh1.idx();
		indices[eh.idx() * 2 + 1] = vh2.idx();
	}
	const auto shape = {_self.n_edges(), size_t(2)};
	const auto strides = {2 * sizeof(int), sizeof(int)};
	py::capsule base = free_when_done(indices);
	return py::array_t<int>(shape, strides, indices, base);
}

/**
 * Returns the halfedge indices of this mesh as a numpy array.
 *
 * Note that the array is constructed on the fly and does not
 * reference the underlying mesh.
 */
template<class Mesh>
py::array_t<int> halfedge_vertex_indices(Mesh& _self) {
	if (_self.n_halfedges() == 0) {
		return py::array_t<int>();
	}
	int *indices = new int[_self.n_halfedges() * 2];
	for (auto heh : _self.halfedges()) {
		auto vh1 = _self.from_vertex_handle(heh);
		auto vh2 = _self.to_vertex_handle(heh);
		indices[heh.idx() * 2 + 0] = vh1.idx();
		indices[heh.idx() * 2 + 1] = vh2.idx();
	}
	const auto shape = {_self.n_halfedges(), size_t(2)};
	const auto strides = {2 * sizeof(int), sizeof(int)};
	py::capsule base = free_when_done(indices);
	return py::array_t<int>(shape, strides, indices, base);
}

354
355
356
357
358
/**
 * This function template is used to expose mesh member functions that are only
 * available for a specific type of mesh (i.e. they are available for polygon
 * meshes or triangle meshes, but not both).
 *
Alexander Dielen's avatar
Alexander Dielen committed
359
 * @tparam Class A pybind11::class type.
360
 *
Alexander Dielen's avatar
Alexander Dielen committed
361
 * @param _class The pybind11::class instance for which the member
362
363
364
365
366
367
368
369
370
371
372
 * functions are to be defined.
 */
template <class Class>
void expose_type_specific_functions(Class& _class) {
	// See the template specializations below
}

/**
 * Function template specialization for polygon meshes.
 */
template <>
Alexander Dielen's avatar
Alexander Dielen committed
373
void expose_type_specific_functions(py::class_<PolyMesh>& _class) {
374
375
376
377
378
	typedef PolyMesh::Scalar Scalar;
	typedef PolyMesh::Point  Point;
	typedef PolyMesh::Normal Normal;
	typedef PolyMesh::Color  Color;

379
	typedef py::array_t<typename Point::value_type> np_point_t;
380

Alexander Dielen's avatar
Alexander Dielen committed
381
382
383
	OM::FaceHandle (PolyMesh::*add_face_3_vh)(OM::VertexHandle, OM::VertexHandle, OM::VertexHandle                  ) = &PolyMesh::add_face;
	OM::FaceHandle (PolyMesh::*add_face_4_vh)(OM::VertexHandle, OM::VertexHandle, OM::VertexHandle, OM::VertexHandle) = &PolyMesh::add_face;
	OM::FaceHandle (*add_face_list)(PolyMesh&, const py::list&) = &add_face;
384
385
386
387
388
389

	_class
		.def("add_face", add_face_3_vh)
		.def("add_face", add_face_4_vh)
		.def("add_face", add_face_list)

390
391
392
393
394
395
396
		.def("split", [](PolyMesh& _self, OM::EdgeHandle _eh, np_point_t _arr) {
				_self.split(_eh, Point(_arr.at(0), _arr.at(1), _arr.at(2)));
			})

		.def("split", [](PolyMesh& _self, OM::FaceHandle _fh, np_point_t _arr) {
				_self.split(_fh, Point(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
397
398

		.def("insert_edge", &PolyMesh::insert_edge)
399

400
401
		.def("face_vertex_indices", &face_vertex_indices_polymesh)
		.def("fv_indices", &face_vertex_indices_polymesh)
402

403
		.def("calc_face_normal", [](PolyMesh& _self, np_point_t _p0, np_point_t _p1, np_point_t _p2) {
404
405
406
407
408
				const Point p0(_p0.at(0), _p0.at(1), _p0.at(2));
				const Point p1(_p1.at(0), _p1.at(1), _p1.at(2));
				const Point p2(_p2.at(0), _p2.at(1), _p2.at(2));
				return vec2numpy(_self.calc_face_normal(p0, p1, p2));
			})
409
410
411
412
413
414
415
		;
}

/**
 * Function template specialization for triangle meshes.
 */
template <>
Alexander Dielen's avatar
Alexander Dielen committed
416
void expose_type_specific_functions(py::class_<TriMesh>& _class) {
417
418
419
420
421
	typedef TriMesh::Scalar Scalar;
	typedef TriMesh::Point  Point;
	typedef TriMesh::Normal Normal;
	typedef TriMesh::Color  Color;

422
423
	typedef py::array_t<typename Point::value_type> np_point_t;

Alexander Dielen's avatar
Alexander Dielen committed
424
425
	OM::FaceHandle (TriMesh::*add_face_3_vh)(OM::VertexHandle, OM::VertexHandle, OM::VertexHandle) = &TriMesh::add_face;
	OM::FaceHandle (*add_face_list)(TriMesh&, const py::list&) = &add_face;
426

427
	void (TriMesh::*split_copy_eh_vh)(OM::EdgeHandle, OM::VertexHandle) = &TriMesh::split_copy;
Alexander Dielen's avatar
Alexander Dielen committed
428
	OM::HalfedgeHandle (TriMesh::*vertex_split_vh)(OM::VertexHandle, OM::VertexHandle, OM::VertexHandle, OM::VertexHandle) = &TriMesh::vertex_split;
429
430
431
432
433

	_class
		.def("add_face", add_face_3_vh)
		.def("add_face", add_face_list)

434
435
436
437
438
439
440
		.def("split", [](TriMesh& _self, OM::EdgeHandle _eh, np_point_t _arr) {
				return _self.split(_eh, Point(_arr.at(0), _arr.at(1), _arr.at(2)));
			})

		.def("split", [](TriMesh& _self, OM::FaceHandle _fh, np_point_t _arr) {
				return _self.split(_fh, Point(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
441
442

		.def("split_copy", split_copy_eh_vh)
443
444
445
446
447
448
449
450

		.def("split_copy", [](TriMesh& _self, OM::EdgeHandle _eh, np_point_t _arr) {
				return _self.split_copy(_eh, Point(_arr.at(0), _arr.at(1), _arr.at(2)));
			})

		.def("split_copy", [](TriMesh& _self, OM::FaceHandle _fh, np_point_t _arr) {
				return _self.split_copy(_fh, Point(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
451
452
453
454
455
456

		.def("opposite_vh", &TriMesh::opposite_vh)
		.def("opposite_he_opposite_vh", &TriMesh::opposite_he_opposite_vh)

		.def("vertex_split", vertex_split_vh)

457
458
459
460
		.def("vertex_split", [](TriMesh& _self, np_point_t _arr, OM::VertexHandle _v1, OM::VertexHandle _vl, OM::VertexHandle _vr) {
				return _self.vertex_split(Point(_arr.at(0), _arr.at(1), _arr.at(2)), _v1, _vl, _vr);
			})

461
462
		.def("is_flip_ok", &TriMesh::is_flip_ok)
		.def("flip", &TriMesh::flip)
463

464
465
		.def("face_vertex_indices", &face_vertex_indices_trimesh)
		.def("fv_indices", &face_vertex_indices_trimesh)
466
467
468
469
470
471
472
473
474
475
476
477
		;
}


/**
 * Expose a mesh type to %Python.
 *
 * @tparam Mesh A mesh type.
 *
 * @param _name The name of the mesh type to be exposed.
 */
template <class Mesh>
Alexander Dielen's avatar
Alexander Dielen committed
478
void expose_mesh(py::module& m, const char *_name) {
479
480
481
482
483
484
485
	using OpenMesh::Attributes::StatusInfo;

	typedef typename Mesh::Scalar Scalar;
	typedef typename Mesh::Point  Point;
	typedef typename Mesh::Normal Normal;
	typedef typename Mesh::Color  Color;

486
487
488
489
	typedef typename Mesh::TexCoord1D TexCoord1D;
	typedef typename Mesh::TexCoord2D TexCoord2D;
	typedef typename Mesh::TexCoord3D TexCoord3D;

490
491
492
493
494
	//======================================================================
	//  KernelT Function Pointers
	//======================================================================

	// Get the i'th item
Alexander Dielen's avatar
Alexander Dielen committed
495
496
497
498
	OM::VertexHandle   (Mesh::*vertex_handle_uint  )(unsigned int) const = &Mesh::vertex_handle;
	OM::HalfedgeHandle (Mesh::*halfedge_handle_uint)(unsigned int) const = &Mesh::halfedge_handle;
	OM::EdgeHandle     (Mesh::*edge_handle_uint    )(unsigned int) const = &Mesh::edge_handle;
	OM::FaceHandle     (Mesh::*face_handle_uint    )(unsigned int) const = &Mesh::face_handle;
499
500
501

	// Delete items
	void (Mesh::*garbage_collection_bools)(bool, bool, bool) = &Mesh::garbage_collection;
Alexander Dielen's avatar
Alexander Dielen committed
502
	void (*garbage_collection_lists_bools)(Mesh&, py::list&, py::list&, py::list&, bool, bool, bool) = &garbage_collection;
503
504

	// Vertex connectivity
Alexander Dielen's avatar
Alexander Dielen committed
505
506
	OM::HalfedgeHandle (Mesh::*halfedge_handle_vh)(OM::VertexHandle) const = &Mesh::halfedge_handle;
	OM::HalfedgeHandle (Mesh::*halfedge_handle_fh)(OM::FaceHandle  ) const = &Mesh::halfedge_handle;
507
508

	// Halfedge connectivity
Alexander Dielen's avatar
Alexander Dielen committed
509
510
511
	OM::FaceHandle     (Mesh::*face_handle_hh         )(OM::HalfedgeHandle) const = &Mesh::face_handle;
	OM::HalfedgeHandle (Mesh::*prev_halfedge_handle_hh)(OM::HalfedgeHandle) const = &Mesh::prev_halfedge_handle;
	OM::EdgeHandle     (Mesh::*edge_handle_hh         )(OM::HalfedgeHandle) const = &Mesh::edge_handle;
512
513

	// Edge connectivity
Alexander Dielen's avatar
Alexander Dielen committed
514
	OM::HalfedgeHandle (Mesh::*halfedge_handle_eh_uint)(OM::EdgeHandle, unsigned int) const = &Mesh::halfedge_handle;
515
516

	// Set halfedge
Alexander Dielen's avatar
Alexander Dielen committed
517
518
	void (Mesh::*set_halfedge_handle_vh_hh)(OM::VertexHandle, OM::HalfedgeHandle) = &Mesh::set_halfedge_handle;
	void (Mesh::*set_halfedge_handle_fh_hh)(OM::FaceHandle,   OM::HalfedgeHandle) = &Mesh::set_halfedge_handle;
519
520

	// Handle -> Item
Alexander Dielen's avatar
Alexander Dielen committed
521
522
523
524
	const typename Mesh::Vertex&   (Mesh::*vertex  )(OM::VertexHandle  ) const = &Mesh::vertex;
	const typename Mesh::Halfedge& (Mesh::*halfedge)(OM::HalfedgeHandle) const = &Mesh::halfedge;
	const typename Mesh::Edge&     (Mesh::*edge    )(OM::EdgeHandle    ) const = &Mesh::edge;
	const typename Mesh::Face&     (Mesh::*face    )(OM::FaceHandle    ) const = &Mesh::face;
525
526

	// Item -> Handle
Alexander Dielen's avatar
Alexander Dielen committed
527
528
529
530
	OM::VertexHandle   (Mesh::*handle_v)(const typename Mesh::Vertex&  ) const = &Mesh::handle;
	OM::HalfedgeHandle (Mesh::*handle_h)(const typename Mesh::Halfedge&) const = &Mesh::handle;
	OM::EdgeHandle     (Mesh::*handle_e)(const typename Mesh::Edge&    ) const = &Mesh::handle;
	OM::FaceHandle     (Mesh::*handle_f)(const typename Mesh::Face&    ) const = &Mesh::handle;
531
532

	// Get value of a standard property (status)
Alexander Dielen's avatar
Alexander Dielen committed
533
534
535
536
	const StatusInfo& (Mesh::*status_vh)(OM::VertexHandle  ) const = &Mesh::status;
	const StatusInfo& (Mesh::*status_hh)(OM::HalfedgeHandle) const = &Mesh::status;
	const StatusInfo& (Mesh::*status_eh)(OM::EdgeHandle    ) const = &Mesh::status;
	const StatusInfo& (Mesh::*status_fh)(OM::FaceHandle    ) const = &Mesh::status;
537
538

	// Set value of a standard property (status)
Alexander Dielen's avatar
Alexander Dielen committed
539
540
541
542
	void (*set_status_vh)(Mesh&, OM::VertexHandle,   const StatusInfo&) = &set_status;
	void (*set_status_hh)(Mesh&, OM::HalfedgeHandle, const StatusInfo&) = &set_status;
	void (*set_status_eh)(Mesh&, OM::EdgeHandle,     const StatusInfo&) = &set_status;
	void (*set_status_fh)(Mesh&, OM::FaceHandle,     const StatusInfo&) = &set_status;
543
544

	// Property management - add property
545
546
547
548
549
	void (Mesh::*add_property_vph)(OM::VPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
	void (Mesh::*add_property_eph)(OM::EPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
	void (Mesh::*add_property_hph)(OM::HPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
	void (Mesh::*add_property_fph)(OM::FPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
	void (Mesh::*add_property_mph)(OM::MPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
550
551

	// Property management - remove property
552
553
554
555
556
	void (Mesh::*remove_property_vph)(OM::VPropHandleT<py::none>&) = &Mesh::remove_property;
	void (Mesh::*remove_property_eph)(OM::EPropHandleT<py::none>&) = &Mesh::remove_property;
	void (Mesh::*remove_property_hph)(OM::HPropHandleT<py::none>&) = &Mesh::remove_property;
	void (Mesh::*remove_property_fph)(OM::FPropHandleT<py::none>&) = &Mesh::remove_property;
	void (Mesh::*remove_property_mph)(OM::MPropHandleT<py::none>&) = &Mesh::remove_property;
557
558

	// Property management - get property by name
559
560
561
562
563
	bool (Mesh::*get_property_handle_vph)(OM::VPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
	bool (Mesh::*get_property_handle_eph)(OM::EPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
	bool (Mesh::*get_property_handle_hph)(OM::HPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
	bool (Mesh::*get_property_handle_fph)(OM::FPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
	bool (Mesh::*get_property_handle_mph)(OM::MPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
564
565

	// Property management - get property value for an item
566
567
568
569
570
	const py::none& (Mesh::*property_vertex  )(OM::VPropHandleT<py::none>, OM::VertexHandle  ) const = &Mesh::property;
	const py::none& (Mesh::*property_edge    )(OM::EPropHandleT<py::none>, OM::EdgeHandle    ) const = &Mesh::property;
	const py::none& (Mesh::*property_halfedge)(OM::HPropHandleT<py::none>, OM::HalfedgeHandle) const = &Mesh::property;
	const py::none& (Mesh::*property_face    )(OM::FPropHandleT<py::none>, OM::FaceHandle    ) const = &Mesh::property;
	const py::none& (Mesh::*property_mesh    )(OM::MPropHandleT<py::none>                    ) const = &Mesh::property;
571
572

	// Property management - set property value for an item
573
574
575
576
577
	void (*set_property_vertex  )(Mesh&, OM::VPropHandleT<py::none>, OM::VertexHandle,   const py::object&) = &set_property;
	void (*set_property_edge    )(Mesh&, OM::EPropHandleT<py::none>, OM::EdgeHandle,     const py::object&) = &set_property;
	void (*set_property_halfedge)(Mesh&, OM::HPropHandleT<py::none>, OM::HalfedgeHandle, const py::object&) = &set_property;
	void (*set_property_face    )(Mesh&, OM::FPropHandleT<py::none>, OM::FaceHandle,     const py::object&) = &set_property;
	void (*set_property_mesh    )(Mesh&, OM::MPropHandleT<py::none>,                     const py::object&) = &set_property;
578
579

	// Low-level adding new items
Alexander Dielen's avatar
Alexander Dielen committed
580
581
582
	OM::VertexHandle (Mesh::*new_vertex_void )(void                        ) = &Mesh::new_vertex;
	OM::FaceHandle   (Mesh::*new_face_void   )(void                        ) = &Mesh::new_face;
	OM::FaceHandle   (Mesh::*new_face_face   )(const typename Mesh::Face&  ) = &Mesh::new_face;
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599

	// Kernel item iterators
	IteratorWrapperT<typename Mesh::VertexIter,   &Mesh::n_vertices > (*vertices )(Mesh&) = &get_iterator;
	IteratorWrapperT<typename Mesh::HalfedgeIter, &Mesh::n_halfedges> (*halfedges)(Mesh&) = &get_iterator;
	IteratorWrapperT<typename Mesh::EdgeIter,     &Mesh::n_edges    > (*edges    )(Mesh&) = &get_iterator;
	IteratorWrapperT<typename Mesh::FaceIter,     &Mesh::n_faces    > (*faces    )(Mesh&) = &get_iterator;

	IteratorWrapperT<typename Mesh::VertexIter,   &Mesh::n_vertices > (*svertices )(Mesh&) = &get_skipping_iterator;
	IteratorWrapperT<typename Mesh::HalfedgeIter, &Mesh::n_halfedges> (*shalfedges)(Mesh&) = &get_skipping_iterator;
	IteratorWrapperT<typename Mesh::EdgeIter,     &Mesh::n_edges    > (*sedges    )(Mesh&) = &get_skipping_iterator;
	IteratorWrapperT<typename Mesh::FaceIter,     &Mesh::n_faces    > (*sfaces    )(Mesh&) = &get_skipping_iterator;

	//======================================================================
	//  BaseKernel Function Pointers
	//======================================================================

	// Copy property
600
601
602
603
	void (Mesh::*copy_property_vprop)(OM::VPropHandleT<py::none>&, OM::VertexHandle,   OM::VertexHandle  ) = &Mesh::copy_property;
	void (Mesh::*copy_property_hprop)(OM::HPropHandleT<py::none>,  OM::HalfedgeHandle, OM::HalfedgeHandle) = &Mesh::copy_property;
	void (Mesh::*copy_property_eprop)(OM::EPropHandleT<py::none>,  OM::EdgeHandle,     OM::EdgeHandle    ) = &Mesh::copy_property;
	void (Mesh::*copy_property_fprop)(OM::FPropHandleT<py::none>,  OM::FaceHandle,     OM::FaceHandle    ) = &Mesh::copy_property;
604
605

	// Copy all properties
Alexander Dielen's avatar
Alexander Dielen committed
606
607
608
609
	void (Mesh::*copy_all_properties_vh_vh_bool)(OM::VertexHandle,   OM::VertexHandle,   bool) = &Mesh::copy_all_properties;
	void (Mesh::*copy_all_properties_hh_hh_bool)(OM::HalfedgeHandle, OM::HalfedgeHandle, bool) = &Mesh::copy_all_properties;
	void (Mesh::*copy_all_properties_eh_eh_bool)(OM::EdgeHandle,     OM::EdgeHandle,     bool) = &Mesh::copy_all_properties;
	void (Mesh::*copy_all_properties_fh_fh_bool)(OM::FaceHandle,     OM::FaceHandle,     bool) = &Mesh::copy_all_properties;
610
611
612
613
614
615
616
617
618
619

	//======================================================================
	//  PolyConnectivity Function Pointers
	//======================================================================

	// Assign connectivity
	void (*assign_connectivity_poly)(Mesh&, const PolyMesh&) = &assign_connectivity;
	void (*assign_connectivity_tri )(Mesh&, const TriMesh& ) = &assign_connectivity;

	// Vertex and face valence
Alexander Dielen's avatar
Alexander Dielen committed
620
621
	unsigned int (Mesh::*valence_vh)(OM::VertexHandle) const = &Mesh::valence;
	unsigned int (Mesh::*valence_fh)(OM::FaceHandle  ) const = &Mesh::valence;
622
623

	// Triangulate face or mesh
Alexander Dielen's avatar
Alexander Dielen committed
624
625
	void (Mesh::*triangulate_fh  )(OM::FaceHandle) = &Mesh::triangulate;
	void (Mesh::*triangulate_void)(              ) = &Mesh::triangulate;
626
627

	// Vertex and Face circulators
Alexander Dielen's avatar
Alexander Dielen committed
628
629
630
631
632
633
634
635
636
637
	CirculatorWrapperT<typename Mesh::VertexVertexIter,    OM::VertexHandle  > (*vv )(Mesh&, OM::VertexHandle  ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::VertexIHalfedgeIter, OM::VertexHandle  > (*vih)(Mesh&, OM::VertexHandle  ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::VertexOHalfedgeIter, OM::VertexHandle  > (*voh)(Mesh&, OM::VertexHandle  ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::VertexEdgeIter,      OM::VertexHandle  > (*ve )(Mesh&, OM::VertexHandle  ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::VertexFaceIter,      OM::VertexHandle  > (*vf )(Mesh&, OM::VertexHandle  ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::FaceVertexIter,      OM::FaceHandle    > (*fv )(Mesh&, OM::FaceHandle    ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::FaceHalfedgeIter,    OM::FaceHandle    > (*fh )(Mesh&, OM::FaceHandle    ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::FaceEdgeIter,        OM::FaceHandle    > (*fe )(Mesh&, OM::FaceHandle    ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::FaceFaceIter,        OM::FaceHandle    > (*ff )(Mesh&, OM::FaceHandle    ) = &get_circulator;
	CirculatorWrapperT<typename Mesh::HalfedgeLoopIter,    OM::HalfedgeHandle> (*hl )(Mesh&, OM::HalfedgeHandle) = &get_circulator;
638
639

	// Boundary and manifold tests
Alexander Dielen's avatar
Alexander Dielen committed
640
641
642
643
	bool (Mesh::*is_boundary_hh)(OM::HalfedgeHandle  ) const = &Mesh::is_boundary;
	bool (Mesh::*is_boundary_eh)(OM::EdgeHandle      ) const = &Mesh::is_boundary;
	bool (Mesh::*is_boundary_vh)(OM::VertexHandle    ) const = &Mesh::is_boundary;
	bool (Mesh::*is_boundary_fh)(OM::FaceHandle, bool) const = &Mesh::is_boundary;
644
645

	// Generic handle derefertiation
Alexander Dielen's avatar
Alexander Dielen committed
646
647
648
649
	const typename Mesh::Vertex&   (Mesh::*deref_vh)(OM::VertexHandle  ) const = &Mesh::deref;
	const typename Mesh::Halfedge& (Mesh::*deref_hh)(OM::HalfedgeHandle) const = &Mesh::deref;
	const typename Mesh::Edge&     (Mesh::*deref_eh)(OM::EdgeHandle    ) const = &Mesh::deref;
	const typename Mesh::Face&     (Mesh::*deref_fh)(OM::FaceHandle    ) const = &Mesh::deref;
650
651
652
653
654

	//======================================================================
	//  PolyMeshT Function Pointers
	//======================================================================

Alexander Dielen's avatar
Alexander Dielen committed
655
656
	Scalar (Mesh::*calc_edge_length_eh)(OM::EdgeHandle    ) const = &Mesh::calc_edge_length;
	Scalar (Mesh::*calc_edge_length_hh)(OM::HalfedgeHandle) const = &Mesh::calc_edge_length;
657

Alexander Dielen's avatar
Alexander Dielen committed
658
659
	Scalar (Mesh::*calc_edge_sqr_length_eh)(OM::EdgeHandle    ) const = &Mesh::calc_edge_sqr_length;
	Scalar (Mesh::*calc_edge_sqr_length_hh)(OM::HalfedgeHandle) const = &Mesh::calc_edge_sqr_length;
660

Alexander Dielen's avatar
Alexander Dielen committed
661
662
	Scalar (Mesh::*calc_dihedral_angle_fast_hh)(OM::HalfedgeHandle) const = &Mesh::calc_dihedral_angle_fast;
	Scalar (Mesh::*calc_dihedral_angle_fast_eh)(OM::EdgeHandle    ) const = &Mesh::calc_dihedral_angle_fast;
663

Alexander Dielen's avatar
Alexander Dielen committed
664
665
	Scalar (Mesh::*calc_dihedral_angle_hh)(OM::HalfedgeHandle) const = &Mesh::calc_dihedral_angle;
	Scalar (Mesh::*calc_dihedral_angle_eh)(OM::EdgeHandle    ) const = &Mesh::calc_dihedral_angle;
666
667
668

	unsigned int (Mesh::*find_feature_edges)(Scalar) = &Mesh::find_feature_edges;

Alexander Dielen's avatar
Alexander Dielen committed
669
670
	void (Mesh::*split_fh_vh)(OM::FaceHandle, OM::VertexHandle) = &Mesh::split;
	void (Mesh::*split_eh_vh)(OM::EdgeHandle, OM::VertexHandle) = &Mesh::split;
671

672
673
	void (Mesh::*split_copy_fh_vh)(OM::FaceHandle, OM::VertexHandle) = &Mesh::split_copy;

674
675
676
677
	//======================================================================
	//  Mesh Type
	//======================================================================

Alexander Dielen's avatar
Alexander Dielen committed
678
	py::class_<Mesh> class_mesh(m, _name);
679
680

	class_mesh
Alexander Dielen's avatar
Alexander Dielen committed
681
		.def(py::init<>())
682
683
684
685
686
687
688

		//======================================================================
		//  KernelT
		//======================================================================

		.def("reserve", &Mesh::reserve)

Alexander Dielen's avatar
Alexander Dielen committed
689
690
691
692
		.def("vertex", vertex, py::return_value_policy::reference)
		.def("halfedge", halfedge, py::return_value_policy::reference)
		.def("edge", edge, py::return_value_policy::reference)
		.def("face", face, py::return_value_policy::reference)
693
694
695
696
697
698
699
700
701
702
703
704
705

		.def("handle", handle_v)
		.def("handle", handle_h)
		.def("handle", handle_e)
		.def("handle", handle_f)

		.def("vertex_handle", vertex_handle_uint)
		.def("halfedge_handle", halfedge_handle_uint)
		.def("edge_handle", edge_handle_uint)
		.def("face_handle", face_handle_uint)

		.def("clear", &Mesh::clear)
		.def("clean", &Mesh::clean)
Alexander Dielen's avatar
Alexander Dielen committed
706
707
708
709
710
		.def("garbage_collection", garbage_collection_bools,
			py::arg("v")=true, py::arg("e")=true, py::arg("f")=true)
		.def("garbage_collection", garbage_collection_lists_bools,
			py::arg("vh_to_update"), py::arg("hh_to_update"), py::arg("fh_to_update"),
			py::arg("v")=true, py::arg("e")=true, py::arg("f")=true)
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807

		.def("n_vertices", &Mesh::n_vertices)
		.def("n_halfedges", &Mesh::n_halfedges)
		.def("n_edges", &Mesh::n_edges)
		.def("n_faces", &Mesh::n_faces)
		.def("vertices_empty", &Mesh::vertices_empty)
		.def("halfedges_empty", &Mesh::halfedges_empty)
		.def("edges_empty", &Mesh::edges_empty)
		.def("faces_empty", &Mesh::faces_empty)

		.def("halfedge_handle", halfedge_handle_vh)
		.def("set_halfedge_handle", set_halfedge_handle_vh_hh)

		.def("to_vertex_handle", &Mesh::to_vertex_handle)
		.def("from_vertex_handle", &Mesh::from_vertex_handle)
		.def("set_vertex_handle", &Mesh::set_vertex_handle)
		.def("face_handle", face_handle_hh)
		.def("set_face_handle", &Mesh::set_face_handle)
		.def("next_halfedge_handle", &Mesh::next_halfedge_handle)
		.def("set_next_halfedge_handle", &Mesh::set_next_halfedge_handle)
		.def("prev_halfedge_handle", prev_halfedge_handle_hh)
		.def("opposite_halfedge_handle", &Mesh::opposite_halfedge_handle)
		.def("ccw_rotated_halfedge_handle", &Mesh::ccw_rotated_halfedge_handle)
		.def("cw_rotated_halfedge_handle", &Mesh::cw_rotated_halfedge_handle)
		.def("edge_handle", edge_handle_hh)

		.def("halfedge_handle", halfedge_handle_eh_uint)

		.def("halfedge_handle", halfedge_handle_fh)
		.def("set_halfedge_handle", set_halfedge_handle_fh_hh)

		.def("status", status_vh, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("set_status", set_status_vh)
		.def("status", status_hh, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("set_status", set_status_hh)
		.def("status", status_eh, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("set_status", set_status_eh)
		.def("status", status_fh, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("set_status", set_status_fh)

		.def("request_vertex_normals", &Mesh::request_vertex_normals)
		.def("request_vertex_colors", &Mesh::request_vertex_colors)
		.def("request_vertex_texcoords1D", &Mesh::request_vertex_texcoords1D)
		.def("request_vertex_texcoords2D", &Mesh::request_vertex_texcoords2D)
		.def("request_vertex_texcoords3D", &Mesh::request_vertex_texcoords3D)
		.def("request_vertex_status", &Mesh::request_vertex_status)
		.def("request_halfedge_status", &Mesh::request_halfedge_status)
		.def("request_halfedge_normals", &Mesh::request_halfedge_normals)
		.def("request_halfedge_colors", &Mesh::request_halfedge_colors)
		.def("request_halfedge_texcoords1D", &Mesh::request_halfedge_texcoords1D)
		.def("request_halfedge_texcoords2D", &Mesh::request_halfedge_texcoords2D)
		.def("request_halfedge_texcoords3D", &Mesh::request_halfedge_texcoords3D)
		.def("request_edge_status", &Mesh::request_edge_status)
		.def("request_edge_colors", &Mesh::request_edge_colors)
		.def("request_face_normals", &Mesh::request_face_normals)
		.def("request_face_colors", &Mesh::request_face_colors)
		.def("request_face_status", &Mesh::request_face_status)
		.def("request_face_texture_index", &Mesh::request_face_texture_index)

		.def("release_vertex_normals", &Mesh::release_vertex_normals)
		.def("release_vertex_colors", &Mesh::release_vertex_colors)
		.def("release_vertex_texcoords1D", &Mesh::release_vertex_texcoords1D)
		.def("release_vertex_texcoords2D", &Mesh::release_vertex_texcoords2D)
		.def("release_vertex_texcoords3D", &Mesh::release_vertex_texcoords3D)
		.def("release_vertex_status", &Mesh::release_vertex_status)
		.def("release_halfedge_status", &Mesh::release_halfedge_status)
		.def("release_halfedge_normals", &Mesh::release_halfedge_normals)
		.def("release_halfedge_colors", &Mesh::release_halfedge_colors)
		.def("release_halfedge_texcoords1D", &Mesh::release_halfedge_texcoords1D)
		.def("release_halfedge_texcoords2D", &Mesh::release_halfedge_texcoords2D)
		.def("release_halfedge_texcoords3D", &Mesh::release_halfedge_texcoords3D)
		.def("release_edge_status", &Mesh::release_edge_status)
		.def("release_edge_colors", &Mesh::release_edge_colors)
		.def("release_face_normals", &Mesh::release_face_normals)
		.def("release_face_colors", &Mesh::release_face_colors)
		.def("release_face_status", &Mesh::release_face_status)
		.def("release_face_texture_index", &Mesh::release_face_texture_index)

		.def("has_vertex_normals", &Mesh::has_vertex_normals)
		.def("has_vertex_colors", &Mesh::has_vertex_colors)
		.def("has_vertex_texcoords1D", &Mesh::has_vertex_texcoords1D)
		.def("has_vertex_texcoords2D", &Mesh::has_vertex_texcoords2D)
		.def("has_vertex_texcoords3D", &Mesh::has_vertex_texcoords3D)
		.def("has_vertex_status", &Mesh::has_vertex_status)
		.def("has_halfedge_status", &Mesh::has_halfedge_status)
		.def("has_halfedge_normals", &Mesh::has_halfedge_normals)
		.def("has_halfedge_colors", &Mesh::has_halfedge_colors)
		.def("has_halfedge_texcoords1D", &Mesh::has_halfedge_texcoords1D)
		.def("has_halfedge_texcoords2D", &Mesh::has_halfedge_texcoords2D)
		.def("has_halfedge_texcoords3D", &Mesh::has_halfedge_texcoords3D)
		.def("has_edge_status", &Mesh::has_edge_status)
		.def("has_edge_colors", &Mesh::has_edge_colors)
		.def("has_face_normals", &Mesh::has_face_normals)
		.def("has_face_colors", &Mesh::has_face_colors)
		.def("has_face_status", &Mesh::has_face_status)
		.def("has_face_texture_index", &Mesh::has_face_texture_index)

Alexander Dielen's avatar
Alexander Dielen committed
808
809
810
811
812
		.def("add_property", add_property_vph, py::arg("ph"), py::arg("name")="<vprop>")
		.def("add_property", add_property_eph, py::arg("ph"), py::arg("name")="<eprop>")
		.def("add_property", add_property_hph, py::arg("ph"), py::arg("name")="<hprop>")
		.def("add_property", add_property_fph, py::arg("ph"), py::arg("name")="<fprop>")
		.def("add_property", add_property_mph, py::arg("ph"), py::arg("name")="<mprop>")
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838

		.def("remove_property", remove_property_vph)
		.def("remove_property", remove_property_eph)
		.def("remove_property", remove_property_hph)
		.def("remove_property", remove_property_fph)
		.def("remove_property", remove_property_mph)

		.def("get_property_handle", get_property_handle_vph)
		.def("get_property_handle", get_property_handle_eph)
		.def("get_property_handle", get_property_handle_hph)
		.def("get_property_handle", get_property_handle_fph)
		.def("get_property_handle", get_property_handle_mph)

		.def("property", property_vertex, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("property", property_edge, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("property", property_halfedge, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("property", property_face, OPENMESH_PYTHON_DEFAULT_POLICY)
		.def("property", property_mesh, OPENMESH_PYTHON_DEFAULT_POLICY)

		.def("set_property", set_property_vertex)
		.def("set_property", set_property_edge)
		.def("set_property", set_property_halfedge)
		.def("set_property", set_property_face)
		.def("set_property", set_property_mesh)

		.def("new_vertex", new_vertex_void)
839
840
841
842
		.def("new_vertex", [](Mesh& _self, py::array_t<typename Point::value_type> _arr) {
				return _self.new_vertex(Point(_arr.at(0), _arr.at(1), _arr.at(2)));
			})

843
		.def("new_edge", &Mesh::new_edge)
844

845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
		.def("new_face", new_face_void)
		.def("new_face", new_face_face)

		.def("vertices", vertices)
		.def("halfedges", halfedges)
		.def("edges", edges)
		.def("faces", faces)

		.def("svertices", svertices)
		.def("shalfedges", shalfedges)
		.def("sedges", sedges)
		.def("sfaces", sfaces)

		//======================================================================
		//  BaseKernel
		//======================================================================

		.def("copy_property", copy_property_vprop)
		.def("copy_property", copy_property_hprop)
		.def("copy_property", copy_property_eprop)
		.def("copy_property", copy_property_fprop)

Alexander Dielen's avatar
Alexander Dielen committed
867
868
869
870
871
872
873
874
		.def("copy_all_properties", copy_all_properties_vh_vh_bool,
			py::arg("vh_from"), py::arg("vh_to"), py::arg("copy_build_in")=false)
		.def("copy_all_properties", copy_all_properties_hh_hh_bool,
			py::arg("hh_from"), py::arg("hh_to"), py::arg("copy_build_in")=false)
		.def("copy_all_properties", copy_all_properties_eh_eh_bool,
			py::arg("eh_from"), py::arg("eh_to"), py::arg("copy_build_in")=false)
		.def("copy_all_properties", copy_all_properties_fh_fh_bool,
			py::arg("fh_from"), py::arg("fh_to"), py::arg("copy_build_in")=false)
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897

		//======================================================================
		//  PolyConnectivity
		//======================================================================

		.def("assign_connectivity", assign_connectivity_poly)
		.def("assign_connectivity", assign_connectivity_tri)

		.def("opposite_face_handle", &Mesh::opposite_face_handle)
		.def("adjust_outgoing_halfedge", &Mesh::adjust_outgoing_halfedge)
		.def("find_halfedge", &Mesh::find_halfedge)
		.def("valence", valence_vh)
		.def("valence", valence_fh)
		.def("collapse", &Mesh::collapse)
		.def("is_simple_link", &Mesh::is_simple_link)
		.def("is_simply_connected", &Mesh::is_simply_connected)
		.def("remove_edge", &Mesh::remove_edge)
		.def("reinsert_edge", &Mesh::reinsert_edge)
		.def("triangulate", triangulate_fh)
		.def("triangulate", triangulate_void)
		.def("split_edge", &Mesh::split_edge)
		.def("split_edge_copy", &Mesh::split_edge_copy)

898
899
		.def("add_vertex", [](Mesh& _self, py::array_t<typename Point::value_type> _arr)
			{ return _self.add_vertex(Point(_arr.at(0), _arr.at(1), _arr.at(2))); })
900
901

		.def("is_collapse_ok",  &Mesh::is_collapse_ok)
902
903
904
905
906
907

		.def("delete_vertex", [](Mesh& _self, OM::VertexHandle _vh, bool _delete_isolated) {
				if (!_self.has_vertex_status()) _self.request_vertex_status();
				if (!_self.has_face_status()) _self.request_face_status();
				_self.delete_vertex(_vh, _delete_isolated);
			}, py::arg("vh"), py::arg("delete_isolated_vertices")=true)
908

909
		.def("delete_edge", [](Mesh& _self, OM::EdgeHandle _eh, bool _delete_isolated) {
910
				if (!_self.has_vertex_status() && _delete_isolated) _self.request_vertex_status();
911
912
913
914
				if (!_self.has_edge_status()) _self.request_edge_status();
				if (!_self.has_face_status()) _self.request_face_status();
				_self.delete_edge(_eh, _delete_isolated);
			}, py::arg("eh"), py::arg("delete_isolated_vertices")=true)
915

916
		.def("delete_face", [](Mesh& _self, OM::FaceHandle _fh, bool _delete_isolated) {
917
				if (!_self.has_vertex_status() && _delete_isolated) _self.request_vertex_status();
918
919
920
				if (!_self.has_face_status()) _self.request_face_status();
				_self.delete_face(_fh, _delete_isolated);
			}, py::arg("fh"), py::arg("delete_isolated_vertices")=true)
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937

		.def("vv", vv)
		.def("vih", vih)
		.def("voh", voh)
		.def("ve", ve)
		.def("vf", vf)

		.def("fv", fv)
		.def("fh", fh)
		.def("fe", fe)
		.def("ff", ff)

		.def("hl", hl)

		.def("is_boundary", is_boundary_hh)
		.def("is_boundary", is_boundary_eh)
		.def("is_boundary", is_boundary_vh)
Alexander Dielen's avatar
Alexander Dielen committed
938
		.def("is_boundary", is_boundary_fh, py::arg("fh"), py::arg("check_vertex")=false)
939
940
		.def("is_manifold", &Mesh::is_manifold)

Alexander Dielen's avatar
Alexander Dielen committed
941
942
943
944
		.def("deref", deref_vh, py::return_value_policy::reference)
		.def("deref", deref_hh, py::return_value_policy::reference)
		.def("deref", deref_eh, py::return_value_policy::reference)
		.def("deref", deref_fh, py::return_value_policy::reference)
945

Alexander Dielen's avatar
Alexander Dielen committed
946
		.def_static("is_triangles", &Mesh::is_triangles)
947

Alexander Dielen's avatar
Alexander Dielen committed
948
949
950
951
		.def_readonly_static("InvalidVertexHandle", &Mesh::InvalidVertexHandle)
		.def_readonly_static("InvalidHalfedgeHandle", &Mesh::InvalidHalfedgeHandle)
		.def_readonly_static("InvalidEdgeHandle", &Mesh::InvalidEdgeHandle)
		.def_readonly_static("InvalidFaceHandle", &Mesh::InvalidFaceHandle)
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969

		//======================================================================
		//  PolyMeshT
		//======================================================================

		.def("calc_edge_length", calc_edge_length_eh)
		.def("calc_edge_length", calc_edge_length_hh)
		.def("calc_edge_sqr_length", calc_edge_sqr_length_eh)
		.def("calc_edge_sqr_length", calc_edge_sqr_length_hh)

		.def("calc_sector_angle", &Mesh::calc_sector_angle)
		.def("calc_sector_area", &Mesh::calc_sector_area)

		.def("calc_dihedral_angle_fast", calc_dihedral_angle_fast_hh)
		.def("calc_dihedral_angle_fast", calc_dihedral_angle_fast_eh)
		.def("calc_dihedral_angle", calc_dihedral_angle_hh)
		.def("calc_dihedral_angle", calc_dihedral_angle_eh)

Alexander Dielen's avatar
Alexander Dielen committed
970
		.def("find_feature_edges", find_feature_edges, py::arg("angle_tresh")=OM::deg_to_rad(44.0))
971
972
973
974

		.def("split", split_fh_vh)
		.def("split", split_eh_vh)

975
976
		.def("split_copy", split_copy_fh_vh)

977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
		.def("update_normals", [](Mesh& _self) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
				}
				if (!_self.has_halfedge_normals()) {
					_self.request_halfedge_normals();
				}
				if (!_self.has_vertex_normals()) {
					_self.request_vertex_normals();
				}
				_self.update_normals();
			})

		.def("update_normal", [](Mesh& _self, OM::FaceHandle _fh) {
				if (!_self.has_face_normals()) _self.request_face_normals();
				_self.update_normal(_fh);
			})
994

995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
		.def("update_face_normals", [](Mesh& _self) {
				if (!_self.has_face_normals()) _self.request_face_normals();
				_self.update_face_normals();
			})

		.def("update_normal", [](Mesh& _self, OM::HalfedgeHandle _hh, double _feature_angle) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
					_self.update_face_normals();
				}
				if (!_self.has_halfedge_normals()) {
					_self.request_halfedge_normals();
				}
				_self.update_normal(_hh, _feature_angle);
			}, py::arg("heh"), py::arg("feature_angle")=0.8)
1010

1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
		.def("update_halfedge_normals", [](Mesh& _self, double _feature_angle) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
					_self.update_face_normals();
				}
				if (!_self.has_halfedge_normals()) {
					_self.request_halfedge_normals();
				}
				_self.update_halfedge_normals(_feature_angle);
			}, py::arg("feature_angle")=0.8)

		.def("update_normal", [](Mesh& _self, OM::VertexHandle _vh) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
					_self.update_face_normals();
				}
				if (!_self.has_vertex_normals()) {
					_self.request_vertex_normals();
				}
				_self.update_normal(_vh);
			})
1032

1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
		.def("update_vertex_normals", [](Mesh& _self) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
					_self.update_face_normals();
				}
				if (!_self.has_vertex_normals()) {
					_self.request_vertex_normals();
				}
				_self.update_vertex_normals();
			})
1043
1044
1045

		.def("is_estimated_feature_edge", &Mesh::is_estimated_feature_edge)

Alexander Dielen's avatar
Alexander Dielen committed
1046
		.def_static("is_polymesh", &Mesh::is_polymesh)
1047
		.def("is_trimesh", &Mesh::is_trimesh)
1048

1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
		//======================================================================
		//  numpy calc_*
		//======================================================================

		.def("calc_face_normal", [](Mesh& _self, OM::FaceHandle _fh) {
				return vec2numpy(_self.calc_face_normal(_fh));
			})

		.def("calc_halfedge_normal", [](Mesh& _self, OM::HalfedgeHandle _heh, double _feature_angle) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
					_self.update_face_normals();
				}
				return vec2numpy(_self.calc_halfedge_normal(_heh, _feature_angle));
			}, py::arg("heh"), py::arg("feature_angle")=0.8)

		.def("calc_vertex_normal", [](Mesh& _self, OM::VertexHandle _vh) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
					_self.update_face_normals();
				}
				return vec2numpy(_self.calc_vertex_normal(_vh));
			})

		.def("calc_vertex_normal_fast", [](Mesh& _self, OM::VertexHandle _vh) {
				if (!_self.has_face_normals()) {
					_self.request_face_normals();
					_self.update_face_normals();
				}
				typename Mesh::Normal n;
				_self.calc_vertex_normal_fast(_vh, n);
				return vec2numpy(n);
			})

		.def("calc_vertex_normal_correct", [](Mesh& _self, OM::VertexHandle _vh) {
				typename Mesh::Normal n;
				_self.calc_vertex_normal_correct(_vh, n);
				return vec2numpy(n);
			})

		.def("calc_vertex_normal_loop", [](Mesh& _self, OM::VertexHandle _vh) {
				typename Mesh::Normal n;
				_self.calc_vertex_normal_loop(_vh, n);
				return vec2numpy(n);
			})

		.def("calc_face_centroid", [](Mesh& _self, OM::FaceHandle _fh) {
				return vec2numpy(_self.calc_face_centroid(_fh));
			})

		.def("calc_edge_vector", [](Mesh& _self, OM::EdgeHandle _eh) {
				return vec2numpy(_self.calc_edge_vector(_eh));
			})

		.def("calc_edge_vector", [](Mesh& _self, OM::HalfedgeHandle _heh) {
				return vec2numpy(_self.calc_edge_vector(_heh));
			})

		.def("calc_sector_vectors", [](Mesh& _self, OM::HalfedgeHandle _heh) {
				typename Mesh::Normal vec0;
				typename Mesh::Normal vec1;
				_self.calc_sector_vectors(_heh, vec0, vec1);
				return std::make_tuple(vec2numpy(vec0), vec2numpy(vec1));
			})

		.def("calc_sector_normal", [](Mesh& _self, OM::HalfedgeHandle _heh) {
				typename Mesh::Normal n;
				_self.calc_sector_normal(_heh, n);
				return vec2numpy(n);
			})

1120
		//======================================================================
1121
		//  numpy vector getter
1122
1123
		//======================================================================

1124
1125
1126
		.def("point", [](Mesh& _self, OM::VertexHandle _h) {
				return vec2numpy(_self, _self.point(_h));
			})
Alexander Dielen's avatar
Alexander Dielen committed
1127

1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
		.def("normal", [](Mesh& _self, OM::VertexHandle _h) {
				if (!_self.has_vertex_normals()) _self.request_vertex_normals();
				return vec2numpy(_self, _self.normal(_h));
			})
		.def("normal", [](Mesh& _self, OM::HalfedgeHandle _h) {
				if (!_self.has_halfedge_normals()) _self.request_halfedge_normals();
				return vec2numpy(_self, _self.normal(_h));
			})
		.def("normal", [](Mesh& _self, OM::FaceHandle _h) {
				if (!_self.has_face_normals()) _self.request_face_normals();
				return vec2numpy(_self, _self.normal(_h));
			})
Alexander Dielen's avatar
Alexander Dielen committed
1140

1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
		.def("color", [](Mesh& _self, OM::VertexHandle _h) {
				if (!_self.has_vertex_colors()) _self.request_vertex_colors();
				return vec2numpy(_self, _self.color(_h));
			})
		.def("color", [](Mesh& _self, OM::HalfedgeHandle _h) {
				if (!_self.has_halfedge_colors()) _self.request_halfedge_colors();
				return vec2numpy(_self, _self.color(_h));
			})
		.def("color", [](Mesh& _self, OM::EdgeHandle _h) {
				if (!_self.has_edge_colors()) _self.request_edge_colors();
				return vec2numpy(_self, _self.color(_h));
			})
		.def("color", [](Mesh& _self, OM::FaceHandle _h) {
				if (!_self.has_face_colors()) _self.request_face_colors();
				return vec2numpy(_self, _self.color(_h));
			})
Alexander Dielen's avatar
Alexander Dielen committed
1157

1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
		.def("texcoord1D", [](Mesh& _self, OM::VertexHandle _h) {
				if (!_self.has_vertex_texcoords1D()) _self.request_vertex_texcoords1D();
				return flt2numpy(_self, _self.texcoord1D(_h));
			})
		.def("texcoord1D", [](Mesh& _self, OM::HalfedgeHandle _h) {
				if (!_self.has_halfedge_texcoords1D()) _self.request_halfedge_texcoords1D();
				return flt2numpy(_self, _self.texcoord1D(_h));
			})
		.def("texcoord2D", [](Mesh& _self, OM::VertexHandle _h) {
				if (!_self.has_vertex_texcoords2D()) _self.request_vertex_texcoords2D();
				return vec2numpy(_self, _self.texcoord2D(_h));
			})
		.def("texcoord2D", [](Mesh& _self, OM::HalfedgeHandle _h) {
				if (!_self.has_halfedge_texcoords2D()) _self.request_halfedge_texcoords2D();
				return vec2numpy(_self, _self.texcoord2D(_h));
			})
		.def("texcoord3D", [](Mesh& _self, OM::VertexHandle _h) {
				if (!_self.has_vertex_texcoords3D()) _self.request_vertex_texcoords3D();
				return vec2numpy(_self, _self.texcoord3D(_h));
			})
		.def("texcoord3D", [](Mesh& _self, OM::HalfedgeHandle _h) {
				if (!_self.has_halfedge_texcoords3D()) _self.request_halfedge_texcoords3D();
				return vec2numpy(_self, _self.texcoord3D(_h));
			})
Alexander Dielen's avatar
Alexander Dielen committed
1182

1183
1184
1185
1186
		//======================================================================
		//  numpy vector setter
		//======================================================================

1187
1188
1189
		.def("set_point", [](Mesh& _self, OM::VertexHandle _h, py::array_t<typename Point::value_type> _arr) {
				_self.point(_h) = Point(_arr.at(0), _arr.at(1), _arr.at(2));
			})
1190

1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
		.def("set_normal", [](Mesh& _self, OM::VertexHandle _h, py::array_t<typename Normal::value_type> _arr) {
				if (!_self.has_vertex_normals()) _self.request_vertex_normals();
				_self.set_normal(_h, typename Mesh::Normal(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
		.def("set_normal", [](Mesh& _self, OM::HalfedgeHandle _h, py::array_t<typename Normal::value_type> _arr) {
				if (!_self.has_halfedge_normals()) _self.request_halfedge_normals();
				_self.set_normal(_h, typename Mesh::Normal(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
		.def("set_normal", [](Mesh& _self, OM::FaceHandle _h, py::array_t<typename Normal::value_type> _arr) {
				if (!_self.has_face_normals()) _self.request_face_normals();
				_self.set_normal(_h, typename Mesh::Normal(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
1203

1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
		.def("set_color", [](Mesh& _self, OM::VertexHandle _h, py::array_t<typename Color::value_type> _arr) {
				if(!_self.has_vertex_colors()) _self.request_vertex_colors();
				_self.set_color(_h, typename Mesh::Color(_arr.at(0), _arr.at(1), _arr.at(2), _arr.at(3)));
			})
		.def("set_color", [](Mesh& _self, OM::HalfedgeHandle _h, py::array_t<typename Color::value_type> _arr) {
				if(!_self.has_halfedge_colors()) _self.request_halfedge_colors();
				_self.set_color(_h, typename Mesh::Color(_arr.at(0), _arr.at(1), _arr.at(2), _arr.at(3)));
			})
		.def("set_color", [](Mesh& _self, OM::EdgeHandle _h, py::array_t<typename Color::value_type> _arr) {
				if(!_self.has_edge_colors()) _self.request_edge_colors();
				_self.set_color(_h, typename Mesh::Color(_arr.at(0), _arr.at(1), _arr.at(2), _arr.at(3)));
			})
		.def("set_color", [](Mesh& _self, OM::FaceHandle _h, py::array_t<typename Color::value_type> _arr) {
				if(!_self.has_face_colors()) _self.request_face_colors();
				_self.set_color(_h, typename Mesh::Color(_arr.at(0), _arr.at(1), _arr.at(2), _arr.at(3)));
			})
1220

1221
1222
1223
1224
1225
1226
1227
1228
		.def("set_texcoord1D", [](Mesh& _self, OM::VertexHandle _h, py::array_t<TexCoord1D> _arr) {
				if (!_self.has_vertex_texcoords1D()) _self.request_vertex_texcoords1D();
				_self.set_texcoord1D(_h, _arr.at(0));
			})
		.def("set_texcoord1D", [](Mesh& _self, OM::HalfedgeHandle _h, py::array_t<TexCoord1D> _arr) {
				if (!_self.has_halfedge_texcoords1D()) _self.request_halfedge_texcoords1D();
				_self.set_texcoord1D(_h, _arr.at(0));
			})
1229

1230
1231
1232
1233
1234
1235
1236
1237
		.def("set_texcoord2D", [](Mesh& _self, OM::VertexHandle _h, py::array_t<typename TexCoord2D::value_type> _arr) {
				if (!_self.has_vertex_texcoords2D()) _self.request_vertex_texcoords2D();
				_self.set_texcoord2D(_h, typename Mesh::TexCoord2D(_arr.at(0), _arr.at(1)));
			})
		.def("set_texcoord2D", [](Mesh& _self, OM::HalfedgeHandle _h, py::array_t<typename TexCoord2D::value_type> _arr) {
				if (!_self.has_halfedge_texcoords2D()) _self.request_halfedge_texcoords2D();
				_self.set_texcoord2D(_h, typename Mesh::TexCoord2D(_arr.at(0), _arr.at(1)));
			})
1238

1239
1240
1241
1242
1243
1244
1245
1246
		.def("set_texcoord3D", [](Mesh& _self, OM::VertexHandle _h, py::array_t<typename TexCoord3D::value_type> _arr) {
				if (!_self.has_vertex_texcoords3D()) _self.request_vertex_texcoords3D();
				_self.set_texcoord3D(_h, typename Mesh::TexCoord3D(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
		.def("set_texcoord3D", [](Mesh& _self, OM::HalfedgeHandle _h, py::array_t<typename TexCoord3D::value_type> _arr) {
				if (!_self.has_halfedge_texcoords3D()) _self.request_halfedge_texcoords3D();
				_self.set_texcoord3D(_h, typename Mesh::TexCoord3D(_arr.at(0), _arr.at(1), _arr.at(2)));
			})
1247
1248
1249
1250
1251

		//======================================================================
		//  numpy matrix getter
		//======================================================================

1252
1253
1254
		.def("points", [](Mesh& _self) {
				return vec2numpy(_self, _self.point(OM::VertexHandle(0)), _self.n_vertices());
			})
1255

1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
		.def("vertex_normals", [](Mesh& _self) {
				if (!_self.has_vertex_normals()) _self.request_vertex_normals();
				return vec2numpy(_self, _self.normal(OM::VertexHandle(0)), _self.n_vertices());
			})
		.def("vertex_colors", [](Mesh& _self) {
				if (!_self.has_vertex_colors()) _self.request_vertex_colors();
				return vec2numpy(_self, _self.color(OM::VertexHandle(0)), _self.n_vertices());
			})
		.def("vertex_texcoords1D", [](Mesh& _self) {
				if (!_self.has_vertex_texcoords1D()) _self.request_vertex_texcoords1D();
				return flt2numpy(_self, _self.texcoord1D(OM::VertexHandle(0)), _self.n_vertices());
			})
		.def("vertex_texcoords2D", [](Mesh& _self) {
				if (!_self.has_vertex_texcoords2D()) _self.request_vertex_texcoords2D();
				return vec2numpy(_self, _self.texcoord2D(OM::VertexHandle(0)), _self.n_vertices());
			})
		.def("vertex_texcoords3D", [](Mesh& _self) {
				if (!_self.has_vertex_texcoords3D()) _self.request_vertex_texcoords3D();
				return vec2numpy(_self, _self.texcoord3D(OM::VertexHandle(0)), _self.n_vertices());
			})
1276

1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
		.def("halfedge_normals", [](Mesh& _self) {
				if (!_self.has_halfedge_normals()) _self.request_halfedge_normals();
				return vec2numpy(_self, _self.normal(OM::HalfedgeHandle(0)), _self.n_halfedges());
			})
		.def("halfedge_colors", [](Mesh& _self) {
				if (!_self.has_halfedge_colors()) _self.request_halfedge_colors();
				return vec2numpy(_self, _self.color(OM::HalfedgeHandle(0)), _self.n_halfedges());
			})
		.def("halfedge_texcoords1D", [](Mesh& _self) {
				if (!_self.has_halfedge_texcoords1D()) _self.request_halfedge_texcoords1D();
				return flt2numpy(_self, _self.texcoord1D(OM::HalfedgeHandle(0)), _self.n_halfedges());
			})
		.def("halfedge_texcoords2D", [](Mesh& _self) {
				if (!_self.has_halfedge_texcoords2D()) _self.request_halfedge_texcoords2D();
				return vec2numpy(_self, _self.texcoord2D(OM::HalfedgeHandle(0)), _self.n_halfedges());
			})
		.def("halfedge_texcoords3D", [](Mesh& _self) {
				if (!_self.has_halfedge_texcoords3D()) _self.request_halfedge_texcoords3D();
				return vec2numpy(_self, _self.texcoord3D(OM::HalfedgeHandle(0)), _self.n_halfedges());
			})
1297

1298
1299
1300
1301
		.def("edge_colors", [](Mesh& _self) {
				if (!_self.has_edge_colors()) _self.request_edge_colors();
				return vec2numpy(_self, _self.color(OM::EdgeHandle(0)), _self.n_edges());
			})
1302

1303
1304
1305
1306
1307
1308
1309
1310
		.def("face_normals", [](Mesh& _self) {
				if (!_self.has_face_normals()) _self.request_face_normals();
				return vec2numpy(_self, _self.normal(OM::FaceHandle(0)), _self.n_faces());
			})
		.def("face_colors",  [](Mesh& _self) {
				if (!_self.has_face_colors()) _self.request_face_colors();
				return vec2numpy(_self, _self.color (OM::FaceHandle(0)), _self.n_faces());
			})
1311
1312

		//======================================================================
Alexander Dielen's avatar
Alexander Dielen committed
1313
		//  numpy indices
1314
1315
		//======================================================================

Alexander Dielen's avatar
Alexander Dielen committed
1316
1317
1318
1319
		.def("edge_vertex_indices", &edge_vertex_indices<Mesh>)
		.def("ev_indices", &edge_vertex_indices<Mesh>)
		.def("halfedge_vertex_indices", &halfedge_vertex_indices<Mesh>)
		.def("hv_indices", &halfedge_vertex_indices<Mesh>)
1320
1321

		//======================================================================
Alexander Dielen's avatar
Alexander Dielen committed
1322
		//  new property interface: single item
1323
1324
		//======================================================================

Alexander Dielen's avatar
Alexander Dielen committed
1325
1326
1327
1328
		.def("vertex_property", &Mesh::template py_property<OM::VertexHandle, typename Mesh::VPropHandle>)
		.def("halfedge_property", &Mesh::template py_property<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
		.def("edge_property", &Mesh::template py_property<OM::EdgeHandle, typename Mesh::EPropHandle>)
		.def("face_property", &Mesh::template py_property<OM::FaceHandle, typename Mesh::FPropHandle>)
1329

Alexander Dielen's avatar
Alexander Dielen committed
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
		.def("set_vertex_property", &Mesh::template py_set_property<OM::VertexHandle, typename Mesh::VPropHandle>)
		.def("set_halfedge_property", &Mesh::template py_set_property<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
		.def("set_edge_property", &Mesh::template py_set_property<OM::EdgeHandle, typename Mesh::EPropHandle>)
		.def("set_face_property", &Mesh::template py_set_property<OM::FaceHandle, typename Mesh::FPropHandle>)

		.def("has_vertex_property", &Mesh::template py_has_property<OM::VertexHandle>)
		.def("has_halfedge_property", &Mesh::template py_has_property<OM::HalfedgeHandle>)
		.def("has_edge_property", &Mesh::template py_has_property<OM::EdgeHandle>)
		.def("has_face_property", &Mesh::template py_has_property<OM::FaceHandle>)

		.def("remove_vertex_property", &Mesh::template py_remove_property<OM::VertexHandle>)
		.def("remove_halfedge_property", &Mesh::template py_remove_property<OM::HalfedgeHandle>)
		.def("remove_edge_property", &Mesh::template py_remove_property<OM::EdgeHandle>)
		.def("remove_face_property", &Mesh::template py_remove_property<OM::FaceHandle>)

		//======================================================================
		//  new property interface: generic
		//======================================================================

		.def("vertex_property", &Mesh::template py_property_generic<OM::VertexHandle, typename Mesh::VPropHandle>)
		.def("halfedge_property", &Mesh::template py_property_generic<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
		.def("edge_property", &Mesh::template py_property_generic<OM::EdgeHandle, typename Mesh::EPropHandle>)
		.def("face_property", &Mesh::template py_property_generic<OM::FaceHandle, typename Mesh::FPropHandle>)

		.def("set_vertex_property", &Mesh::template py_set_property_generic<OM::VertexHandle, typename Mesh::VPropHandle>)
		.def("set_halfedge_property", &Mesh::template py_set_property_generic<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
		.def("set_edge_property", &Mesh::template py_set_property_generic<OM::EdgeHandle, typename Mesh::EPropHandle>)
		.def("set_face_property", &Mesh::template py_set_property_generic<OM::FaceHandle, typename Mesh::FPropHandle>)

		//======================================================================
		//  new property interface: array
		//======================================================================

		.def("vertex_property_array", &Mesh::template py_property_array<OM::VertexHandle, typename Mesh::VPropHandle>)
		.def("halfedge_property_array", &Mesh::template py_property_array<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
		.def("edge_property_array", &Mesh::template py_property_array<OM::EdgeHandle, typename Mesh::EPropHandle>)
		.def("face_property_array", &Mesh::template py_property_array<OM::FaceHandle, typename Mesh::FPropHandle>)

		.def("set_vertex_property_array", &Mesh::template py_set_property_array<OM::VertexHandle, typename Mesh::VPropHandle>)
		.def("set_halfedge_property_array", &Mesh::template py_set_property_array<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
		.def("set_edge_property_array", &Mesh::template py_set_property_array<OM::EdgeHandle, typename Mesh::EPropHandle>)
		.def("set_face_property_array", &Mesh::template py_set_property_array<OM::FaceHandle, typename Mesh::FPropHandle>)
1372
1373
1374
1375
1376
1377
1378
		;

	expose_type_specific_functions(class_mesh);

}

#endif