xmsgeom  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
TrTriangulatorPoints_py.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
7 //------------------------------------------------------------------------------
8 
9 //----- Included files ---------------------------------------------------------
10 #include <pybind11/pybind11.h>
11 #include <pybind11/numpy.h>
12 #include <boost/shared_ptr.hpp>
15 #include <iostream>
16 #include <fstream>
17 
18 
19 //----- Namespace declaration --------------------------------------------------
20 namespace py = pybind11;
21 
22 //----- Python Interface -------------------------------------------------------
23 PYBIND11_DECLARE_HOLDER_TYPE(T, boost::shared_ptr<T>);
24 
25 void initTrTriangulatorPoints(py::module &m) {
26 
27  py::module modMeshUtils = m.def_submodule("TrTriangulatorPoints")
28  .def("triangulate", [](py::iterable pts, py::iterable tris, py::iterable tris_adj) -> py::iterable {
29  boost::shared_ptr<xms::VecPt3d> vec_pts = xms::VecPt3dFromPyIter(pts);
30  boost::shared_ptr<xms::VecInt> vec_tris = xms::VecIntFromPyIter(tris);
31  boost::shared_ptr<xms::VecInt2d> vec_tris_adj = xms::VecInt2dFromPyIter(tris_adj);
32  xms::TrTriangulatorPoints triangulator(*vec_pts, *vec_tris, &(*vec_tris_adj));
33  triangulator.Triangulate();
34 
35  // Return pts, tris, and tris_adj
36  return py::make_tuple(xms::PyIterFromVecPt3d(*vec_pts),
37  xms::PyIterFromVecInt(*vec_tris), xms::PyIterFromVecInt2d(*vec_tris_adj));
38  },"Triangulate the points into a tin.", py::arg("pts"),py::arg("tris"),py::arg("tris_adj")
39  )
40  ;
41 }
py::iterable PyIterFromVecInt2d(const VecInt2d &int2d)
py::iterable PyIterFromVecPt3d(const VecPt3d &pts)
py::iterable PyIterFromVecInt(const VecInt &ints, bool numpy)
boost::shared_ptr< VecInt2d > VecInt2dFromPyIter(const py::iterable &int2d)
boost::shared_ptr< VecInt > VecIntFromPyIter(const py::iterable &ints)
boost::shared_ptr< VecPt3d > VecPt3dFromPyIter(const py::iterable &pts)
Class to triangulate simple points.