Skip to content

Commit

Permalink
Merge pull request #240 from stewartboogert/oct780
Browse files Browse the repository at this point in the history
TopoDS now namesapce (OCT 7.9.0), create sub-module (with same name as former class TopoDSClass) to preserve interface in older versions of OCT.
  • Loading branch information
stewartboogert authored Feb 24, 2025
2 parents 75485ec + 83b07d2 commit cd5d5a3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pyg4ometry/pyoce/TopoDS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ PYBIND
PYBIND11_DECLARE_HOLDER_TYPE(T, opencascade::handle<T>, true)

PYBIND11_MODULE(TopoDS, m) {

#if OCC_VERSION_MAJOR == 7 && OCC_VERSION_MINOR <= 8
py::class_<TopoDS>(m, "TopoDSClass")
.def_static("CompSolid",
[](TopoDS_Shape &shape) { return TopoDS::CompSolid(shape); })
Expand All @@ -45,7 +47,19 @@ PYBIND11_MODULE(TopoDS, m) {
[](TopoDS_Shape &shape) { return TopoDS::Wire(shape); })
.def_static("Vertex",
[](TopoDS_Shape &shape) { return TopoDS::Vertex(shape); });

#else
auto m_ns = m.def_submodule("TopoDSClass", "TopoDS namespace");
m_ns.def("CompSolid",
[](TopoDS_Shape &shape) { return TopoDS::CompSolid(shape); });
m_ns.def("Compound",
[](TopoDS_Shape &shape) { return TopoDS::Compound(shape); });
m_ns.def("Edge", [](TopoDS_Shape &shape) { return TopoDS::Edge(shape); });
m_ns.def("Face", [](TopoDS_Shape &shape) { return TopoDS::Face(shape); });
m_ns.def("Shell", [](TopoDS_Shape &shape) { return TopoDS::Shell(shape); });
m_ns.def("Solid", [](TopoDS_Shape &shape) { return TopoDS::Solid(shape); });
m_ns.def("Wire", [](TopoDS_Shape &shape) { return TopoDS::Wire(shape); });
m_ns.def("Vertex", [](TopoDS_Shape &shape) { return TopoDS::Vertex(shape); });
#endif
py::class_<TopoDS_Builder>(m, "TopoDS_Builder")
.def(py::init<>())
.def("MakeWire", &TopoDS_Builder::MakeWire)
Expand Down

0 comments on commit cd5d5a3

Please sign in to comment.