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

[python][occ] add name to shape wrappers

parent 7fd65a49
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <frackit/geometryutilities/name.hh>
namespace Frackit::Python::OCCUtilities { namespace Frackit::Python::OCCUtilities {
// Wrapper class to be used around occ brep classes // Wrapper class to be used around occ brep classes
...@@ -41,6 +43,7 @@ public: ...@@ -41,6 +43,7 @@ public:
BRepWrapper(const Shape& shape) : shape_(shape) {} BRepWrapper(const Shape& shape) : shape_(shape) {}
const Shape& get() const { return shape_; } const Shape& get() const { return shape_; }
std::string name() const { return geometryName(get()) + "_Wrapper"; }
private: private:
Shape shape_; Shape shape_;
}; };
...@@ -72,6 +75,10 @@ public: ...@@ -72,6 +75,10 @@ public:
const Compound& get() const const Compound& get() const
{ return compound_; } { return compound_; }
//! return the name of the wrapper class
std::string name() const
{ return "TopoDS_Compound_Wrapper"; }
//! add a wrapped shape to the compound //! add a wrapped shape to the compound
template<class ShapeWrapper> template<class ShapeWrapper>
void add(const ShapeWrapper& shape) void add(const ShapeWrapper& shape)
......
...@@ -33,6 +33,7 @@ namespace Detail { ...@@ -33,6 +33,7 @@ namespace Detail {
{ {
using Wrapper = OCCUtilities::BRepWrapper<Shape>; using Wrapper = OCCUtilities::BRepWrapper<Shape>;
pybind11::class_<Wrapper> cls(module, className.c_str()); pybind11::class_<Wrapper> cls(module, className.c_str());
cls.def("name", &Wrapper::name, "return the name of the wrapper");
} }
void registerCompoundWrapper(pybind11::module& module) void registerCompoundWrapper(pybind11::module& module)
...@@ -43,6 +44,7 @@ namespace Detail { ...@@ -43,6 +44,7 @@ namespace Detail {
// functions to add shapes to the compound // functions to add shapes to the compound
using namespace Frackit::Python::OCCUtilities; using namespace Frackit::Python::OCCUtilities;
cls.def("name", &Wrapper::name, "return the name of the wrapper");
cls.def("add", &Wrapper::add<ShapeWrapper>, "Add a shape to the compound"); cls.def("add", &Wrapper::add<ShapeWrapper>, "Add a shape to the compound");
cls.def("add", &Wrapper::add<VertexWrapper>, "Add a vertex to the compound"); cls.def("add", &Wrapper::add<VertexWrapper>, "Add a vertex to the compound");
cls.def("add", &Wrapper::add<EdgeWrapper>, "Add an edge to the compound"); cls.def("add", &Wrapper::add<EdgeWrapper>, "Add an edge to the compound");
......
Supports Markdown
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