Commit ad29f1e1 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[python][shapewrappers] add constructor from other wrappers

parent 73ccd2b8
......@@ -51,6 +51,24 @@ private:
Shape shape_;
// Wrapper class around TopoDS_Shape is constructible from other wrappers
class BRepWrapper<TopoDS_Shape>
//! export underlying shape type
using Shape = TopoDS_Shape;
template<class S>
BRepWrapper(const BRepWrapper<S>& wrapper) : shape_(wrapper.get()) {}
BRepWrapper(const Shape& shape) : shape_(shape) {}
BRepWrapper(Shape&& shape) : shape_(std::move(shape)) {}
const Shape& get() const { return shape_; }
std::string name() const { return geometryName(get()) + "_Wrapper"; }
Shape shape_;
// Wrapper around TopoDS_Compound
class BRepWrapper<TopoDS_Compound>
......@@ -19,6 +19,7 @@
#include <type_traits>
#include <pybind11/pybind11.h>
#include "brepwrapper.hh"
......@@ -34,6 +35,20 @@ namespace Detail {
using Wrapper = OCCUtilities::BRepWrapper<Shape>;
pybind11::class_<Wrapper> cls(module, className.c_str());
cls.def("name", &Wrapper::name, "return the name of the wrapper");
// add constructor from other shape wrappers
if constexpr(std::is_same_v<Shape, TopoDS_Shape>)
namespace py = pybind11;
cls.def(py::init<OCCUtilities::ShapeWrapper>(), "construction from another brep wrapper");
cls.def(py::init<OCCUtilities::VertexWrapper>(), "construction from another brep wrapper");
cls.def(py::init<OCCUtilities::EdgeWrapper>(), "construction from another brep wrapper");
cls.def(py::init<OCCUtilities::WireWrapper>(), "construction from another brep wrapper");
cls.def(py::init<OCCUtilities::FaceWrapper>(), "construction from another brep wrapper");
cls.def(py::init<OCCUtilities::ShellWrapper>(), "construction from another brep wrapper");
cls.def(py::init<OCCUtilities::SolidWrapper>(), "construction from another brep wrapper");
cls.def(py::init<OCCUtilities::CompoundWrapper>(), "construction from another brep wrapper");
void registerCompoundWrapper(pybind11::module& module)
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