From c8e51c4ebc598d19d99deb2675334ba84f9f122a Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Mon, 31 Aug 2015 18:24:52 -0400 Subject: [PATCH] python - CloseSurfaces with user-defined slices --- libsrc/csg/python_csg.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 1362a614..26850a6e 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -362,6 +362,42 @@ DLL_HEADER void ExportCSG() (bp::arg("self"), bp::arg("solid"), bp::arg("bcmod")=bp::list()) ) + .def("CloseSurfaces", FunctionPointer + ([] (CSGeometry & self, shared_ptr s1, shared_ptr s2, bp::list aslices ) + { + Array si1, si2; + s1->GetSolid()->GetSurfaceIndices (si1); + s2->GetSolid()->GetSurfaceIndices (si2); + cout << "surface ids1 = " << si1 << endl; + cout << "surface ids2 = " << si2 << endl; + + Flags flags; + + try + { + int n = bp::len(aslices); + Array slices(n); + for(int i=0; i(aslices[i])(); + } + flags.SetFlag("slices", slices); + } + catch( bp::error_already_set const & ) { + cout << "caught python error:" << endl; + PyErr_Print(); + } + + const TopLevelObject * domain = nullptr; + self.AddIdentification + (new CloseSurfaceIdentification + (self.GetNIdentifications()+1, self, + self.GetSurface (si1[0]), self.GetSurface (si2[0]), + domain, + flags)); + }), + (bp::arg("self"), bp::arg("solid1"), bp::arg("solid2"), bp::arg("slices")) + ) .def("CloseSurfaces", FunctionPointer ([] (CSGeometry & self, shared_ptr s1, shared_ptr s2, int reflevels) {