From 1c7db2c39371b111805752e4525d2be0bd60618c Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Wed, 1 Oct 2014 12:07:09 +0000 Subject: [PATCH] print python solid --- Makefile.am | 2 +- libsrc/csg/python_csg.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index f5d800b3..929fd301 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4 METASOURCES = AUTO -SUBDIRS = libsrc ng tutorials doc windows nglib +SUBDIRS = libsrc ng tutorials python doc windows nglib # nglib # TESTS = ng/netgen -batchmode diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 66c7335f..38a72bdf 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -63,6 +63,7 @@ public: } Solid * GetSolid() { return solid; } + const Solid * GetSolid() const { return solid; } void GiveUpOwner() { @@ -99,6 +100,11 @@ private: optyp op; }; +inline ostream & operator<< (ostream & ost, const SPSolid & sol) +{ + ost << *sol.GetSolid(); + return ost; +} namespace netgen { @@ -152,11 +158,13 @@ void ExportCSG() bp::class_, boost::noncopyable> ("Solid", bp::no_init) + .def ("__str__", &ToString) .def ("__add__", FunctionPointer( [] ( shared_ptr self, shared_ptr other ) { return make_shared (SPSolid::UNION, self, other); } ) ) .def ("__mul__", FunctionPointer( [] ( shared_ptr self, shared_ptr other ) { return make_shared (SPSolid::SECTION, self, other); } ) ) .def ("__sub__", FunctionPointer( [] ( shared_ptr self, shared_ptr other ) { return make_shared (SPSolid::SECTION, self, make_shared (SPSolid::SUB, other, nullptr)); } ) ) // .def ("__neg__", FunctionPointer( [] ( shared_ptr self ) { return make_shared (SPSolid::SUB, self); } ) ) COMPLEMENT? + .def ("bc", FunctionPointer([](shared_ptr & self, int nr) -> shared_ptr { self->SetBC(nr); return self; })) ;