MCPcopy Create free account
hub / github.com/Kitware/VTK / GetObjectFromPointer

Method GetObjectFromPointer

Wrapping/PythonCore/vtkPythonUtil.cxx:425–456  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

423
424//------------------------------------------------------------------------------
425PyObject* vtkPythonUtil::GetObjectFromPointer(vtkObjectBase* ptr)
426{
427 PyObject* obj = vtkPythonUtil::FindObject(ptr);
428
429 if (obj == nullptr)
430 {
431 // create a new object
432 PyVTKClass* vtkclass = nullptr;
433 vtkPythonClassMap::iterator k = vtkPythonMap->ClassMap->find(ptr->GetClassName());
434 if (k != vtkPythonMap->ClassMap->end())
435 {
436 vtkclass = &k->second;
437 }
438
439 // if the class was not in the map, then find the nearest base class
440 // that is, and associate ptr->GetClassName() with that base class
441 if (vtkclass == nullptr)
442 {
443 const char* classname = ptr->GetClassName();
444 vtkclass = vtkPythonUtil::FindNearestBaseClass(ptr);
445 vtkPythonClassMap::iterator i = vtkPythonMap->ClassMap->find(classname);
446 if (i == vtkPythonMap->ClassMap->end())
447 {
448 vtkPythonMap->ClassMap->insert(i, vtkPythonClassMap::value_type(classname, *vtkclass));
449 }
450 }
451
452 obj = PyVTKObject_FromPointer(vtkclass->py_type, nullptr, ptr);
453 }
454
455 return obj;
456}
457
458//------------------------------------------------------------------------------
459const char* vtkPythonUtil::PythonicClassName(const char* classname)

Callers

nothing calls this directly

Calls 5

PyVTKObject_FromPointerFunction · 0.85
findMethod · 0.45
GetClassNameMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected