| 1118 | } |
| 1119 | |
| 1120 | static void Scene_DuplicateObjectMulti(luxcore::detail::SceneImpl *scene, |
| 1121 | const string &srcObjName, |
| 1122 | const string &dstObjNamePrefix, |
| 1123 | const unsigned int count, |
| 1124 | const boost::python::object &transformations, |
| 1125 | const boost::python::object &objectIDs) { |
| 1126 | if (!PyObject_CheckBuffer(objectIDs.ptr())){ |
| 1127 | const string objType = extract<string>((objectIDs.attr("__class__")).attr("__name__")); |
| 1128 | throw runtime_error("Unsupported data type in Scene.DuplicateObject() method: " + objType); |
| 1129 | } |
| 1130 | if (!PyObject_CheckBuffer(transformations.ptr())) { |
| 1131 | const string objType = extract<string>((transformations.attr("__class__")).attr("__name__")); |
| 1132 | throw runtime_error("Unsupported data type in Scene.DuplicateObject() method: " + objType); |
| 1133 | } |
| 1134 | |
| 1135 | Py_buffer transformationsView; |
| 1136 | if (PyObject_GetBuffer(transformations.ptr(), &transformationsView, PyBUF_SIMPLE)) { |
| 1137 | const string objType = extract<string>((transformations.attr("__class__")).attr("__name__")); |
| 1138 | throw runtime_error("Unable to get a data view in Scene.DuplicateObject() method: " + objType); |
| 1139 | } |
| 1140 | Py_buffer objectIDsView; |
| 1141 | if (PyObject_GetBuffer(objectIDs.ptr(), &objectIDsView, PyBUF_SIMPLE)) { |
| 1142 | PyBuffer_Release(&transformationsView); |
| 1143 | |
| 1144 | const string objType = extract<string>((transformations.attr("__class__")).attr("__name__")); |
| 1145 | throw runtime_error("Unable to get a data view in Scene.DuplicateObject() method: " + objType); |
| 1146 | } |
| 1147 | |
| 1148 | const size_t objectIDsBufferSize = sizeof(u_int) * count; |
| 1149 | if ((size_t)objectIDsView.len < objectIDsBufferSize) { |
| 1150 | const string errorMsg = "Not enough objectIDs in the buffer of Scene.DuplicateObject() method: " + |
| 1151 | luxrays::ToString(objectIDsView.len) + " instead of " + luxrays::ToString(objectIDsBufferSize); |
| 1152 | |
| 1153 | PyBuffer_Release(&objectIDsView); |
| 1154 | PyBuffer_Release(&transformationsView); |
| 1155 | |
| 1156 | throw runtime_error(errorMsg); |
| 1157 | } |
| 1158 | const size_t transformationsBufferSize = sizeof(float) * 16 * count; |
| 1159 | if ((size_t)transformationsView.len < transformationsBufferSize) { |
| 1160 | const string errorMsg = "Not enough matrices in the buffer of Scene.DuplicateObject() method: " + |
| 1161 | luxrays::ToString(transformationsView.len) + " instead of " + luxrays::ToString(transformationsBufferSize); |
| 1162 | |
| 1163 | PyBuffer_Release(&objectIDsView); |
| 1164 | PyBuffer_Release(&transformationsView); |
| 1165 | |
| 1166 | throw runtime_error(errorMsg); |
| 1167 | } |
| 1168 | |
| 1169 | float *transformationsBuffer = (float *)transformationsView.buf; |
| 1170 | u_int *objectIDsBuffer = (u_int *)objectIDsView.buf; |
| 1171 | |
| 1172 | scene->DuplicateObject(srcObjName, dstObjNamePrefix, count, |
| 1173 | transformationsBuffer, objectIDsBuffer); |
| 1174 | |
| 1175 | PyBuffer_Release(&transformationsView); |
| 1176 | PyBuffer_Release(&objectIDsView); |
| 1177 | } |
nothing calls this directly
no test coverage detected