diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 59dd4e9c..77c63bd0 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -54,6 +54,8 @@ public: solid = new Solid (Solid::UNION, s1->GetSolid(), s2->GetSolid()); else if (aop == SECTION) solid = new Solid (Solid::SECTION, s1->GetSolid(), s2->GetSolid()); + else if (aop == SUB) + solid = new Solid (Solid::SUB, s1->GetSolid(), s2->GetSolid()); } Solid * GetSolid() { return solid; } @@ -99,15 +101,40 @@ void ExportCSG() bp::scope local_scope(module); + bp::class_> ("Point2d", bp::init()) + .def(bp::self+Vec<2>()) + ; + bp::class_> ("Point3d", bp::init()) .def(bp::self+Vec<3>()) ; - bp::class_> ("Vec3d", bp::init()) + + bp::def ("Pnt", FunctionPointer( [] (double x, double y, double z) { return Point<3>(x,y,z); } ) ); + bp::def ("Pnt", FunctionPointer( [] (double x, double y) { return Point<2>(x,y); } ) ); + + bp::class_> ("Vec2d", bp::init()) .def(bp::self+bp::self) +// .def(bp::self*double()) + .def(double()*bp::self) ; + bp::class_> ("Vec3d", bp::init()) + .def(bp::self+bp::self) +// .def(bp::self*double()) + .def(double()*bp::self) + ; - bp::class_, boost::noncopyable> ("Solid", bp::no_init) ; + bp::def ("Vec", FunctionPointer( [] (double x, double y, double z) { return Vec<3>(x,y,z); } ) ); + bp::def ("Vec", FunctionPointer( [] (double x, double y) { return Vec<2>(x,y); } ) ); + + + + bp::class_, boost::noncopyable> ("Solid", bp::no_init) + .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::SUB, self, other); } ) ) +// .def ("__neg__", FunctionPointer( [] ( shared_ptr self ) { return make_shared (SPSolid::SUB, self); } ) ) COMPLEMENT? + ; bp::def ("Sphere", FunctionPointer([](const Point<3> c, double r) {