Commit a4bc4c13 authored by Alexander Dielen's avatar Alexander Dielen
Browse files

exposed subdiv functions

parent 961f9b87
Pipeline #17979 failed with stages
in 4 minutes and 30 seconds
......@@ -4,6 +4,8 @@
#include "Iterator.hh"
#include "Circulator.hh"
#include "InputOutput.hh"
#include "Subdivision.hh"
#include "Decimater.hh"
#include <pybind11/pybind11.h>
......@@ -40,4 +42,7 @@ PYBIND11_MODULE(openmesh, m) {
expose_decimater<PolyMesh>(m, "PolyMesh");
expose_decimater<TriMesh>(m, "TriMesh");
py::module algo = m.def_submodule("algorithms");
expose_subdiv(algo);
}
#ifndef OPENMESH_PYTHON_SUBDIVISION_HH
#define OPENMESH_PYTHON_SUBDIVISION_HH
#include "MeshTypes.hh"
#include <OpenMesh/Tools/Subdivider/Uniform/LoopT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/Sqrt3T.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/Sqrt3InterpolatingSubdividerLabsikGreinerT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/ModifiedButterFlyT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/MidpointT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/LongestEdgeT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/CatmullClarkT.hh>
#include <pybind11/pybind11.h>
namespace py = pybind11;
namespace OM = OpenMesh;
typedef OM::Subdivider::Uniform::LoopT<TriMesh> Loop;
typedef OM::Subdivider::Uniform::Sqrt3T<TriMesh> Sqrt3;
typedef OM::Subdivider::Uniform::InterpolatingSqrt3LGT<TriMesh> InterpolatingSqrt3;
typedef OM::Subdivider::Uniform::ModifiedButterflyT<TriMesh> ModifiedButterfly;
typedef OM::Subdivider::Uniform::MidpointT<TriMesh> Midpoint;
typedef OM::Subdivider::Uniform::CatmullClarkT<PolyMesh> CatmullClark;
template <class Mesh>
void longest_edge_fn(Mesh& mesh, double max_edge_length)
{
OM::Subdivider::Uniform::LongestEdgeT<Mesh> subdivider;
subdivider.attach(mesh);
subdivider.set_max_edge_length(max_edge_length);
subdivider(1); // argument is ignored
subdivider.detach();
}
template <class Subdivider>
void subdiv_fn(typename Subdivider::mesh_t& mesh, size_t n, bool update_points)
{
Subdivider subdivider;
subdivider.attach(mesh);
subdivider(n, update_points);
subdivider.detach();
}
template <class Subdivider>
void expose_subdiv_fn(py::module& m, const char *name)
{
m.def(name,
&subdiv_fn<Subdivider>,
py::arg("mesh"),
py::arg("iterations")=1,
py::arg("update_points")=true);
}
void expose_subdiv(py::module& m)
{
py::module subdiv = m.def_submodule("subdiv");
expose_subdiv_fn<Loop>(subdiv, "loop");
expose_subdiv_fn<Sqrt3>(subdiv, "sqrt3");
expose_subdiv_fn<InterpolatingSqrt3>(subdiv, "interpolating_sqrt3");
expose_subdiv_fn<ModifiedButterfly>(subdiv, "modified_butterfly");
expose_subdiv_fn<Midpoint>(subdiv, "midpoint");
expose_subdiv_fn<CatmullClark>(subdiv, "catmull_clark");
subdiv.def("longest_edge", longest_edge_fn<TriMesh>,
py::arg("mesh"), py::arg("max_edge_length"));
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment