+ if (isProblem && aDump.get()) {
+ std::cout << "Dump feature error " << aDump->error() << std::endl;
+ Events_InfoMessage anErrorMsg(theErrorMsgContext, aDump->error());
+ anErrorMsg.send();
+ }
+ theSession->finishOperation();
+ return !isProblem;
+}
+
+static bool checkDump(SessionPtr theSession,
+ char* theFilename,
+ Storage& theStorage,
+ const std::string& theErrorMsgContext)
+{
+
+ // close all before importation of the script
+ theSession->closeAll();
+
+ // execute the dumped
+ PyGILState_STATE gstate = PyGILState_Ensure(); /* acquire python thread */
+ static char aReadMode[] = "r";
+ FILE* PyFileObject = _Py_fopen(theFilename, aReadMode);
+ PyRun_SimpleFileEx(PyFileObject, theFilename, 1);
+ PyGILState_Release(gstate); /* release python thread */
+
+ // compare with the stored data
+ std::string anError = storeFeatures(
+ theSession->moduleDocument()->kind(), theSession->moduleDocument(), theStorage, true);
+ if (!anError.empty()) {
+ std::cout << anError << std::endl;
+ Events_InfoMessage anErrorMsg(theErrorMsgContext, anError);
+ anErrorMsg.send();
+ return false;
+ }
+
+ return true;
+}
+
+bool checkPythonDump(const checkDumpType theCheckType)
+{
+ static const std::string anErrorByNaming("checkPythonDump by naming");
+ static const std::string anErrorByGeometry("checkPythonDump by geometry");
+ static const std::string anErrorByWeak("checkPythonDump by weak naming");
+
+ static char aFileForNamingDump[] = "./check_dump.py";
+ static char aFileForGeometryDump[] = "./check_dump_geo.py";
+ static char aFileForWeakDump[] = "./check_dump_weak.py";
+
+ SessionPtr aSession = ModelAPI_Session::get();
+ // dump with the specified types
+ char* aFileName = theCheckType == CHECK_GEOMETRICAL ? aFileForGeometryDump :
+ (theCheckType == CHECK_WEAK ? aFileForWeakDump : aFileForNamingDump);
+ if (!dumpToPython(aSession, aFileName, theCheckType, anErrorByNaming))
+ return false;