set color of CSG top-level object

This commit is contained in:
Joachim Schöberl 2017-09-01 09:12:50 +02:00
parent 7e83edabf1
commit 5de14c63a4
2 changed files with 11 additions and 3 deletions

View File

@ -374,7 +374,8 @@ DLL_HEADER void ExportCSG(py::module &m)
self.Save (filename);
}))
.def("Add",
[] (CSGeometry & self, shared_ptr<SPSolid> solid, py::list bcmod, double maxh)
[] (CSGeometry & self, shared_ptr<SPSolid> 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<double>(col[0]),
py::cast<double>(col[1]),
py::cast<double>(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

View File

@ -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)))