From 5de14c63a4bd4a984b60e05bb3c57a77a31474ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Fri, 1 Sep 2017 09:12:50 +0200 Subject: [PATCH] set color of CSG top-level object --- libsrc/csg/python_csg.cpp | 12 ++++++++++-- python/csg.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 41bb7376..83e33f5e 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -374,7 +374,8 @@ DLL_HEADER void ExportCSG(py::module &m) self.Save (filename); })) .def("Add", - [] (CSGeometry & self, shared_ptr solid, py::list bcmod, double maxh) + [] (CSGeometry & self, shared_ptr solid, py::list bcmod, double maxh, + py::tuple col) { solid->AddSurfaces (self); solid->GiveUpOwner(); @@ -384,6 +385,12 @@ DLL_HEADER void ExportCSG(py::module &m) self.GetTopLevelObject(tlonr)->SetTransparent(solid->IsTransparent()); self.GetTopLevelObject(tlonr)->SetMaxH(maxh); + // cout << "rgb = " << py::len(rgb) << endl; + if (py::len(col)==3) + self.GetTopLevelObject(tlonr) -> SetRGB(py::cast(col[0]), + py::cast(col[1]), + py::cast(col[2])); + // bcmod is list of tuples ( solid, bcnr ) for (int i = 0; i < py::len(bcmod); i++) { @@ -412,7 +419,8 @@ DLL_HEADER void ExportCSG(py::module &m) } return tlonr; }, - py::arg("solid"), py::arg("bcmod")=py::list(), py::arg("maxh")=1e99 + py::arg("solid"), py::arg("bcmod")=py::list(), py::arg("maxh")=1e99, + py::arg("col")=py::tuple() ) .def("AddSurface", FunctionPointer diff --git a/python/csg.py b/python/csg.py index dff88d9b..6378c1c6 100644 --- a/python/csg.py +++ b/python/csg.py @@ -35,6 +35,6 @@ p3 = Plane(Pnt(0,0,0),Vec(0,-1,0)).bc("left") p4 = Plane(Pnt(1,1,1),Vec(0,1,0)).bc("right") p5 = Plane(Pnt(0,0,0),Vec(0,0,-1)).bc("bottom") p6 = Plane(Pnt(1,1,1),Vec(0,0,1)).bc("top") -unit_cube.Add (p1*p2*p3*p4*p5*p6) +unit_cube.Add (p1*p2*p3*p4*p5*p6, col=(0,0,1)) # unit_cube.Add (OrthoBrick(Pnt(0,0,0), Pnt(1,1,1)))