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

Function Image_write

Code/Source/PythonAPI/ImagingImage_PyClass.cxx:971–1004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

969");
970
971static PyObject *
972Image_write(PyImage* self, PyObject* args, PyObject* kwargs)
973{
974 auto api = PyUtilApiFunction("s", PyRunTimeErr, __func__);
975 static char *keywords[] = {"file_name", NULL};
976 char* fileName = NULL;
977
978 if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &fileName)) {
979 return api.argsError();
980 }
981
982 if (!CheckImageData(api, self)) {
983 return nullptr;
984 }
985
986 // Check that you can write to the file.
987 ofstream cfile;
988 cfile.open(fileName);
989 if (!cfile.is_open()) {
990 api.error("Unable to write the image to the file named '" + std::string(fileName) + "'.");
991 return nullptr;
992 } else {
993 cfile.close();
994 }
995
996 try {
997 WriteImage(self, std::string(fileName));
998 } catch (std::exception &e) {
999 api.error(e.what());
1000 return nullptr;
1001 }
1002
1003 Py_RETURN_NONE;
1004}
1005
1006//----------------------------
1007// Image_write_transformation

Callers

nothing calls this directly

Calls 5

CheckImageDataFunction · 0.85
argsErrorMethod · 0.80
errorMethod · 0.80
closeMethod · 0.80
WriteImageFunction · 0.70

Tested by

no test coverage detected