1 #ifndef OPENMESH_PYTHON_ITERATOR_HH 2 #define OPENMESH_PYTHON_ITERATOR_HH 20 template<
class Iterator,
size_t (OpenMesh::ArrayKernel::*n_items)() const>
32 mesh_(_mesh), n_items_(n_items),
33 iterator_(_mesh, _hnd, _skip),
34 iterator_end_(_mesh, typename Iterator::value_type(int((_mesh.*n_items)()))) {
45 mesh_(_mesh), n_items_(n_items),
46 iterator_(_mesh, _hnd, _skip),
47 iterator_end_(_mesh, typename Iterator::value_type(int((_mesh.*n_items)()))) {
65 typename Iterator::value_type
next() {
66 if (iterator_ != iterator_end_) {
67 typename Iterator::value_type res = *iterator_;
72 PyErr_SetString(PyExc_StopIteration,
"No more data.");
73 boost::python::throw_error_already_set();
75 return typename Iterator::value_type();
83 unsigned int len()
const {
84 return (mesh_.*n_items_)();
91 Iterator iterator_end_;
107 template<
class Iterator,
size_t (OpenMesh::ArrayKernel::*n_items)() const>
109 class_<IteratorWrapperT<Iterator, n_items> >(_name, init<PolyMesh&, typename Iterator::value_type, optional<bool> >())
110 .def(init<
TriMesh&,
typename Iterator::value_type, optional<bool> >())
void expose_iterator(const char *_name)
Expose an iterator type to Python.
Definition: Iterator.hh:108
IteratorWrapperT(const PolyMesh &_mesh, typename Iterator::value_type _hnd, bool _skip=false)
Constructor.
Definition: Iterator.hh:31
IteratorWrapperT(const TriMesh &_mesh, typename Iterator::value_type _hnd, bool _skip=false)
Constructor.
Definition: Iterator.hh:44
Connectivity Class for polygonal meshes.
Definition: PolyConnectivity.hh:61
unsigned int len() const
Implementation of Python's __len__ magic method.
Definition: Iterator.hh:83
Iterator::value_type next()
Implementation of Python's __next__ magic method.
Definition: Iterator.hh:65
Wrapper for mesh item iterators.
Definition: Iterator.hh:21
Polygonal mesh based on the ArrayKernel.
Definition: PolyMesh_ArrayKernelT.hh:98
IteratorWrapperT iter() const
Implementation of Python's __iter__ magic method.
Definition: Iterator.hh:55
Triangle mesh based on the ArrayKernel.
Definition: TriMesh_ArrayKernelT.hh:98
Mesh kernel using arrays for mesh item storage.
Definition: ArrayKernel.hh:92
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64