| OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Circulator.hh
1 #ifndef OPENMESH_PYTHON_CIRCULATOR_HH
2 #define OPENMESH_PYTHON_CIRCULATOR_HH
3
4 #include "Python/Bindings.hh"
5
6 namespace OpenMesh {
7 namespace Python {
8
18 template<class Circulator, class CenterEntityHandle>
19 class CirculatorWrapperT {
20 public:
21
28 CirculatorWrapperT(PolyMesh& _mesh, CenterEntityHandle _center) :
29 circulator_(_mesh, _center) {
30 }
31
38 CirculatorWrapperT(TriMesh& _mesh, CenterEntityHandle _center) :
39 circulator_(_mesh, _center) {
40 }
41
47 CirculatorWrapperT iter() const {
48 return *this;
49 }
50
57 typename Circulator::value_type next() {
58 if (circulator_.is_valid()) {
59 typename Circulator::value_type res = *circulator_;
60 ++circulator_;
61 return res;
62 }
63 else {
64 PyErr_SetString(PyExc_StopIteration, "No more data.");
65 boost::python::throw_error_already_set();
66 }
67 return typename Circulator::value_type();
68 }
69
70 private:
71 Circulator circulator_;
72 };
73
85 template<class Circulator, class CenterEntityHandle>
86 void expose_circulator(const char *_name) {
87 class_<CirculatorWrapperT<Circulator, CenterEntityHandle> >(_name, init<TriMesh&, CenterEntityHandle>())
88 .def(init<PolyMesh&, CenterEntityHandle>())
89 .def("__iter__", &CirculatorWrapperT<Circulator, CenterEntityHandle>::iter)
90 .def("__next__", &CirculatorWrapperT<Circulator, CenterEntityHandle>::next)
91 .def("next", &CirculatorWrapperT<Circulator, CenterEntityHandle>::next)
92 ;
93 }
94
95 } // namespace OpenMesh
96 } // namespace Python
97
98 #endif
OpenMesh::Python::CirculatorWrapperT::CirculatorWrapperT
CirculatorWrapperT(TriMesh &_mesh, CenterEntityHandle _center)
Constructor.
Definition: Circulator.hh:38
OpenMesh::Python::expose_circulator
void expose_circulator(const char *_name)
Expose a circulator type to Python.
Definition: Circulator.hh:86
OpenMesh::Python::CirculatorWrapperT::CirculatorWrapperT
CirculatorWrapperT(PolyMesh &_mesh, CenterEntityHandle _center)
Constructor.
Definition: Circulator.hh:28
OpenMesh::Python::CirculatorWrapperT::next
Circulator::value_type next()
Implementation of Python's __next__ magic method.
Definition: Circulator.hh:57
OpenMesh::Python::CirculatorWrapperT::iter
CirculatorWrapperT iter() const
Implementation of Python's __iter__ magic method.
Definition: Circulator.hh:47
OpenMesh::TriMesh_ArrayKernelT
Triangle mesh based on the ArrayKernel.
Definition: TriMesh_ArrayKernelT.hh:98
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
Bindings.hh
OpenMesh::PolyMesh_ArrayKernelT
Polygonal mesh based on the ArrayKernel.
Definition: PolyMesh_ArrayKernelT.hh:98
OpenMesh::Python::CirculatorWrapperT
Wrapper for circulators.
Definition: Circulator.hh:19