Salome HOME
Quick correction to do not build coincidence to central point of reentrant tangent arc
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Tools.cpp
index c19f474096e4178bc5be903561c2523a8f951a07..23f65ebc61497dc1e3c0066451243f2feb610068 100644 (file)
@@ -43,6 +43,9 @@
 
 #include <Events_InfoMessage.h>
 
+// Have to be included before std headers
+#include <Python.h>
+
 #include <algorithm>
 #include <iostream>
 
@@ -173,6 +176,13 @@ void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
 {
   theAttribute->clear();
+
+  if(!theValue.empty()) {
+    std::string aSelectionType;
+    const ModelHighAPI_Selection& aSelection = theValue.front();
+    theAttribute->setSelectionType(aSelection.shapeType());
+  }
+
   for (auto it = theValue.begin(); it != theValue.end(); ++it)
     it->appendToList(theAttribute);
 }
@@ -309,7 +319,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc,
         }
       }
       return "For document '" + theDocName + 
-        "' the number of features becomes smaller, there is no feature '" + aLostName + "'";
+        "' the number of features is decreased, there is no feature '" + aLostName + "'";
     }
   }
   return ""; // ok
@@ -337,22 +347,25 @@ bool checkPythonDump()
   std::string anError = storeFeatures(
     aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, false);
   if (!anError.empty()) {
-    Events_InfoMessage anError("checkPythonDump", anError);
-    anError.send();
+    Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError);
+    anErrorMsg.send();
     return false;
   }
   // close all before importation of the script
   aSession->closeAll();
   // execute the dumped
-  Config_ModuleReader::loadScript("check_dump");
+  PyGILState_STATE gstate = PyGILState_Ensure(); /* acquire python thread */
+  PyObject* PyFileObject = PyFile_FromString("./check_dump.py", "r");
+  PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), "./check_dump.py", 1);
+  PyGILState_Release(gstate); /* release python thread */
 
   // compare with the stored data
   anError = storeFeatures(
     aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, true);
   if (!anError.empty()) {
     std::cout<<anError<<std::endl;
-    Events_InfoMessage anError("checkPythonDump", anError);
-    anError.send();
+    Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError);
+    anErrorMsg.send();
     return false;
   }