| 192 | "); |
| 193 | |
| 194 | static PyObject * |
| 195 | Vmtk_cap(PyObject* self, PyObject* args, PyObject* kwargs) |
| 196 | { |
| 197 | auto api = PyUtilApiFunction("O|O!", PyRunTimeErr, __func__); |
| 198 | static char *keywords[] = {"surface", "use_center", NULL}; |
| 199 | PyObject* surfaceArg; |
| 200 | PyObject* useCenterArg = nullptr; |
| 201 | |
| 202 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &surfaceArg, &PyBool_Type, &useCenterArg)) { |
| 203 | return api.argsError(); |
| 204 | } |
| 205 | |
| 206 | // Set cap type. |
| 207 | // |
| 208 | // This determines whether to cap regularly or cap with a point each hole center. |
| 209 | // 0 - regular, |
| 210 | // 1 - point in center |
| 211 | // |
| 212 | bool radialFill = false; |
| 213 | if ((useCenterArg != nullptr) && PyObject_IsTrue(useCenterArg)) { |
| 214 | radialFill = true; |
| 215 | } |
| 216 | |
| 217 | // Get the vtkPolyData object from the Python object. |
| 218 | // |
| 219 | auto surfPolydata = GetVtkPolyData(api, surfaceArg); |
| 220 | if (surfPolydata == nullptr) { |
| 221 | return nullptr; |
| 222 | } |
| 223 | cvPolyData cvSurfPolydata(surfPolydata); |
| 224 | |
| 225 | // Perform cap operation. |
| 226 | // |
| 227 | std::vector<int> centerIDs; |
| 228 | cvPolyData *cappedSurface = NULL; |
| 229 | int numIds, *ids; |
| 230 | if (sys_geom_cap(&cvSurfPolydata, radialFill, centerIDs, &cappedSurface) != SV_OK) { |
| 231 | api.error("Error capping model."); |
| 232 | return nullptr; |
| 233 | } |
| 234 | |
| 235 | /* |
| 236 | // [TODO:DaveP] what are the IDs that were not found? |
| 237 | if (numIds == 0) { |
| 238 | api.error("No cap IDs were found."); |
| 239 | return nullptr; |
| 240 | } |
| 241 | |
| 242 | // Build return list of IDs. |
| 243 | // |
| 244 | PyObject* pyList = PyList_New(numIds); |
| 245 | for (int i = 0; i < numIds; i++) { |
| 246 | PyObject* pint = Py_BuildValue("i", ids[i]); |
| 247 | PyList_SetItem(pyList, i, pint); |
| 248 | } |
| 249 | |
| 250 | delete [] ids; |
| 251 | return pyList; |
nothing calls this directly
no test coverage detected