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

Function initpyMeshObject

Code/Source/PythonAPI/Meshing_PyModule.cxx:508–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506//----------------
507#if PYTHON_MAJOR_VERSION == 2
508PyMODINIT_FUNC initpyMeshObject()
509
510{
511 // Associate the mesh registrar with the python interpreter so it can be
512 // retrieved by the DLLs.
513 if (gRepository==NULL)
514 {
515 gRepository = new cvRepository();
516 fprintf(stdout,"New gRepository created from cv_mesh_init\n");
517 }
518 int (*kernel)(cvMeshObject::KernelType, cvMeshSystem*)=(&cvMeshSystem::RegisterKernel);
519 if (Py_BuildValue("i",kernel)==nullptr)
520 {
521 fprintf(stdout,"Unable to create MeshSystemRegistrar\n");
522 return;
523
524 }
525 if(PySys_SetObject("MeshSystemRegistrar",Py_BuildValue("i",kernel))<0)
526 {
527 fprintf(stdout, "Unable to register MeshSystemRegistrar\n");
528 return;
529
530 }
531 // Initialize
532 cvMeshSystem::SetCurrentKernel( cvMeshObject::KERNEL_INVALID );
533
534 pyMeshObjectType.tp_new=PyType_GenericNew;
535 if (PyType_Ready(&pyMeshObjectType)<0)
536 {
537 fprintf(stdout,"Error in pyMeshObjectType\n");
538 return;
539
540 }
541 PyObject* pythonC;
542 pythonC = Py_InitModule("pyMeshObject",pyMeshObjectModule_methods);
543
544 if(pythonC==NULL)
545 {
546 fprintf(stdout,"Error in initializing pyMeshObject\n");
547 return;
548
549 }
550 PyRunTimeErr = PyErr_NewException("pyMeshObject.error",NULL,NULL);
551 PyModule_AddObject(pythonC,"error",PyRunTimeErr);
552 Py_INCREF(&pyMeshObjectType);
553 PyModule_AddObject(pythonC,"pyMeshObject",(PyObject*)&pyMeshObjectType);
554 return;
555
556}
557#endif
558

Callers 1

SimVascular_pyInitFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected