Skip to content

Commit

Permalink
WIP: Add Polygon(s) in C++ (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Jan 21, 2025
1 parent 6889db5 commit 30bc857
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/lib/include/xtgeo/xyz.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef XTGEO_XYZ_HPP
#define XTGEO_XYZ_HPP

#include <pybind11/pybind11.h>
#include <xtgeo/types.hpp>

namespace py = pybind11;

namespace xtgeo {
namespace xyz {

inline void
init(py::module &m)
{
auto m_points =
m.def_submodule("points", "Internal functions for operations on point(s).");

py::class_<Point>(m_points, "Point")
.def(py::init<>())
.def(py::init<double, double>()) // Constructor with 2 arguments
.def(py::init<double, double, double>()) // Constructor with 3 arguments

.def_readwrite("x", &Point::x)
.def_readwrite("y", &Point::y)
.def_readwrite("z", &Point::z);

py::class_<Polygon>(m, "Polygon")
.def(py::init<>())
.def(py::init<const std::vector<xtgeo::xyz::Point> &>())
.def(py::init<const py::array_t<double> &>())
.def("add_point", &xtgeo::xyz::Polygon::add_point)
.def("size", &xtgeo::xyz::Polygon::size)
.def_readwrite("points", &xtgeo::xyz::Polygon::points);
}

} // namespace xyz
} // namespace xtgeo

#endif // XTGEO_XYZ_HPP

0 comments on commit 30bc857

Please sign in to comment.