Developer Documentation
Bindings.cc
1 #include "Python/Bindings.hh"
2 #include "Python/Vector.hh"
3 #include "Python/Mesh.hh"
4 #include "Python/PropertyManager.hh"
5 #include "Python/InputOutput.hh"
6 #include "Python/Decimater.hh"
7 
8 #include <memory>
9 
10 namespace OpenMesh {
11 namespace Python {
12 
16 void expose_items() {
17  class_<ArrayItems::Vertex>("Vertex");
18  class_<ArrayItems::Halfedge>("Halfedge");
19  class_<ArrayItems::Edge>("Edge");
20  class_<ArrayItems::Face>("Face");
21 }
22 
27  class_<BaseHandle>("BaseHandle", init<optional<int> >())
28  .def("idx", &BaseHandle::idx)
29  .def("is_valid", &BaseHandle::is_valid)
30  .def("reset", &BaseHandle::reset)
31  .def("invalidate", &BaseHandle::invalidate)
32  .def(self == self)
33  .def(self != self)
34  .def(self < self)
35  ;
36 
37  class_<VertexHandle, bases<BaseHandle> >("VertexHandle", init<optional<int> >());
38  class_<HalfedgeHandle, bases<BaseHandle> >("HalfedgeHandle", init<optional<int> >());
39  class_<EdgeHandle, bases<BaseHandle> >("EdgeHandle", init<optional<int> >());
40  class_<FaceHandle, bases<BaseHandle> >("FaceHandle", init<optional<int> >());
41 
42  class_<BasePropHandleT<object>, bases<BaseHandle> >("BasePropHandle", init<optional<int> >());
43 
44  class_<VPropHandleT<object>, bases<BasePropHandleT<object> > >("VPropHandle", init<optional<int> >())
45  .def(init<const BasePropHandleT<object>&>());
46  class_<HPropHandleT<object>, bases<BasePropHandleT<object> > >("HPropHandle", init<optional<int> >())
47  .def(init<const BasePropHandleT<object>&>());
48  class_<EPropHandleT<object>, bases<BasePropHandleT<object> > >("EPropHandle", init<optional<int> >())
49  .def(init<const BasePropHandleT<object>&>());
50  class_<FPropHandleT<object>, bases<BasePropHandleT<object> > >("FPropHandle", init<optional<int> >())
51  .def(init<const BasePropHandleT<object>&>());
52  class_<MPropHandleT<object>, bases<BasePropHandleT<object> > >("MPropHandle", init<optional<int> >())
53  .def(init<const BasePropHandleT<object>&>());
54 }
55 
56 
63 
64  enum_<StatusBits>("StatusBits")
65  .value("DELETED", OpenMesh::Attributes::DELETED)
66  .value("LOCKED", OpenMesh::Attributes::LOCKED)
67  .value("SELECTED", OpenMesh::Attributes::SELECTED)
68  .value("HIDDEN", OpenMesh::Attributes::HIDDEN)
69  .value("FEATURE", OpenMesh::Attributes::FEATURE)
70  .value("TAGGED", OpenMesh::Attributes::TAGGED)
71  .value("TAGGED2", OpenMesh::Attributes::TAGGED2)
72  .value("FIXEDNONMANIFOLD", OpenMesh::Attributes::FIXEDNONMANIFOLD)
73  .value("UNUSED", OpenMesh::Attributes::UNUSED)
74  ;
75 
76  class_<StatusInfo>("StatusInfo")
77  .def("deleted", &StatusInfo::deleted)
78  .def("set_deleted", &StatusInfo::set_deleted)
79  .def("locked", &StatusInfo::locked)
80  .def("set_locked", &StatusInfo::set_locked)
81  .def("selected", &StatusInfo::selected)
82  .def("set_selected", &StatusInfo::set_selected)
83  .def("hidden", &StatusInfo::hidden)
84  .def("set_hidden", &StatusInfo::set_hidden)
85  .def("feature", &StatusInfo::feature)
86  .def("set_feature", &StatusInfo::set_feature)
87  .def("tagged", &StatusInfo::tagged)
88  .def("set_tagged", &StatusInfo::set_tagged)
89  .def("tagged2", &StatusInfo::tagged2)
90  .def("set_tagged2", &StatusInfo::set_tagged2)
91  .def("fixed_nonmanifold", &StatusInfo::fixed_nonmanifold)
92  .def("set_fixed_nonmanifold", &StatusInfo::set_fixed_nonmanifold)
93  .def("bits", &StatusInfo::bits)
94  .def("set_bits", &StatusInfo::set_bits)
95  .def("is_bit_set", &StatusInfo::is_bit_set)
96  .def("set_bit", &StatusInfo::set_bit)
97  .def("unset_bit", &StatusInfo::unset_bit)
98  .def("change_bit", &StatusInfo::change_bit)
99  ;
100 }
101 
102 BOOST_PYTHON_MODULE(openmesh) {
103  expose_items();
104  expose_handles();
106 
107  expose_vec<float, 2>("Vec2f");
108  expose_vec<float, 3>("Vec3f");
109  expose_vec<float, 4>("Vec4f");
110  expose_vec<double, 2>("Vec2d");
111  expose_vec<double, 3>("Vec3d");
112  expose_vec<double, 4>("Vec4d");
113 
114  expose_mesh<PolyMesh>("PolyMesh");
115  expose_mesh<TriMesh>("TriMesh");
116 
117  expose_iterator<OpenMesh::PolyConnectivity::VertexIter, &OpenMesh::ArrayKernel::n_vertices>("VertexIter");
118  expose_iterator<OpenMesh::PolyConnectivity::HalfedgeIter, &OpenMesh::ArrayKernel::n_halfedges>("HalfedgeIter");
119  expose_iterator<OpenMesh::PolyConnectivity::EdgeIter, &OpenMesh::ArrayKernel::n_edges>("EdgeIter");
120  expose_iterator<OpenMesh::PolyConnectivity::FaceIter, &OpenMesh::ArrayKernel::n_faces>("FaceIter");
121 
122  expose_circulator<OpenMesh::PolyConnectivity::VertexVertexIter, VertexHandle>("VertexVertexIter");
123  expose_circulator<OpenMesh::PolyConnectivity::VertexIHalfedgeIter, VertexHandle>("VertexIHalfedgeIter");
124  expose_circulator<OpenMesh::PolyConnectivity::VertexOHalfedgeIter, VertexHandle>("VertexOHalfedgeIter");
125  expose_circulator<OpenMesh::PolyConnectivity::VertexEdgeIter, VertexHandle>("VertexEdgeIter");
126  expose_circulator<OpenMesh::PolyConnectivity::VertexFaceIter, VertexHandle>("VertexFaceIter");
127 
128  expose_circulator<OpenMesh::PolyConnectivity::FaceVertexIter, FaceHandle>("FaceVertexIter");
129  expose_circulator<OpenMesh::PolyConnectivity::FaceHalfedgeIter, FaceHandle>("FaceHalfedgeIter");
130  expose_circulator<OpenMesh::PolyConnectivity::FaceEdgeIter, FaceHandle>("FaceEdgeIter");
131  expose_circulator<OpenMesh::PolyConnectivity::FaceFaceIter, FaceHandle>("FaceFaceIter");
132 
133  expose_circulator<OpenMesh::PolyConnectivity::HalfedgeLoopIter, HalfedgeHandle>("HalfedgeLoopIter");
134 
139 
140  expose_property_manager<VPropHandleT<object>, VertexHandle, VertexIterWrapper>("VPropertyManager");
141  expose_property_manager<HPropHandleT<object>, HalfedgeHandle, HalfedgeIterWrapper>("HPropertyManager");
142  expose_property_manager<EPropHandleT<object>, EdgeHandle, EdgeIterWrapper>("EPropertyManager");
143  expose_property_manager<FPropHandleT<object>, FaceHandle, FaceIterWrapper>("FPropertyManager");
144 
145  expose_io();
146 
147  expose_decimater<PolyMesh>("PolyMesh");
148  expose_decimater<TriMesh>("TriMesh");
149 }
150 
151 } // namespace Python
152 } // namespace OpenMesh
void expose_handles()
Definition: Bindings.cc:26
Item was non-two-manifold and had to be fixed.
Definition: Status.hh:88
Item has been deleted.
Definition: Status.hh:81
Item is locked.
Definition: Status.hh:82
Handle for a edge entity.
Definition: Handles.hh:139
void expose_items()
Definition: Bindings.cc:16
bool is_valid() const
The handle is valid iff the index is not equal to -1.
Definition: Handles.hh:77
int idx() const
Get the underlying index of this handle.
Definition: Handles.hh:74
Handle for a halfedge entity.
Definition: Handles.hh:132
Handle for a vertex entity.
Definition: Handles.hh:125
void expose_status_bits_and_info()
Definition: Bindings.cc:60
Base property handle.
Definition: Property.hh:471
void invalidate()
reset handle to be invalid
Definition: Handles.hh:82
Item is a feature or belongs to a feature.
Definition: Status.hh:85
Handle for a face entity.
Definition: Handles.hh:146
Item is tagged.
Definition: Status.hh:86
Item is hidden.
Definition: Status.hh:84
Alternate bit for tagging an item.
Definition: Status.hh:87
Item is selected.
Definition: Status.hh:83
void reset()
reset handle to be invalid
Definition: Handles.hh:80