MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / Vmtk_centerlines

Function Vmtk_centerlines

Code/Source/PythonAPI/Vmtk_PyModule.cxx:374–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372");
373
374static PyObject *
375Vmtk_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

Callers

nothing calls this directly

Calls 9

ConvertFaceIdsToNodeIdsFunction · 0.85
sys_geom_centerlinesFunction · 0.85
argsErrorMethod · 0.80
errorMethod · 0.80
sizeMethod · 0.80
dataMethod · 0.80
GetVtkPolyDataFunction · 0.70
GetVtkPolyDataMethod · 0.45

Tested by

no test coverage detected