| 372 | "); |
| 373 | |
| 374 | static PyObject * |
| 375 | Vmtk_centerlines(PyObject* self, PyObject* args, PyObject* kwargs) |
| 376 | { |
| 377 | //std::cout << "========== Vmtk_centerlines ==========" << std::endl; |
| 378 | auto api = PyUtilApiFunction("OO!O!|O!O!", PyRunTimeErr, __func__); |
| 379 | static char *keywords[] = {"surface", "inlet_ids", "outlet_ids", "split", "use_face_ids", NULL}; |
| 380 | PyObject* surfaceArg; |
| 381 | PyObject* inletIdsArg; |
| 382 | PyObject* outletIdsArg; |
| 383 | PyObject* splitArg = nullptr; |
| 384 | bool splitCenterlines = true; |
| 385 | PyObject* useFaceIdsArg = nullptr; |
| 386 | bool useFaceIds = false; |
| 387 | |
| 388 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &surfaceArg, &PyList_Type, &inletIdsArg, |
| 389 | &PyList_Type, &outletIdsArg, &PyBool_Type, &splitArg, &PyBool_Type, &useFaceIdsArg)) { |
| 390 | return api.argsError(); |
| 391 | } |
| 392 | |
| 393 | // Check inlet IDs. |
| 394 | // |
| 395 | // [TODO:DaveP] Add this as a util function. |
| 396 | // |
| 397 | std::vector<int> sources; |
| 398 | int numInletIds = PyList_Size(inletIdsArg); |
| 399 | if (numInletIds == 0) { |
| 400 | api.error("The 'inlet_ids' argument is empty."); |
| 401 | return nullptr; |
| 402 | } |
| 403 | for (int i = 0; i < numInletIds; i++) { |
| 404 | auto item = PyList_GetItem(inletIdsArg, i); |
| 405 | if (!PyLong_Check(item)) { |
| 406 | api.error("The 'inlet_ids' argument is not a list of integers."); |
| 407 | return nullptr; |
| 408 | } |
| 409 | int id = PyLong_AsLong(item); |
| 410 | //std::cout << "[Vmtk_centerlines] ID: " << id << std::endl; |
| 411 | sources.push_back(id); |
| 412 | } |
| 413 | |
| 414 | // Get the target IDs. |
| 415 | // |
| 416 | int numOutletIds = PyList_Size(outletIdsArg); |
| 417 | std::vector<int> targets; |
| 418 | if (numOutletIds == 0) { |
| 419 | api.error("The 'outlet_ids' argument is empty."); |
| 420 | return nullptr; |
| 421 | } |
| 422 | for (int i = 0; i < numOutletIds; i++) { |
| 423 | auto item = PyList_GetItem(outletIdsArg, i); |
| 424 | if (!PyLong_Check(item)) { |
| 425 | api.error("The 'outlet_ids' argument is not a list of integers."); |
| 426 | return nullptr; |
| 427 | } |
| 428 | int id = PyLong_AsLong(item); |
| 429 | targets.push_back(id); |
| 430 | } |
| 431 |
nothing calls this directly
no test coverage detected