py3: ported Raytracing to python3
This commit is contained in:
parent
a39ef71dfc
commit
125fd78fa3
|
@ -27,6 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
#include <Base/PyObjectBase.h>
|
||||||
#include <Base/Interpreter.h>
|
#include <Base/Interpreter.h>
|
||||||
|
|
||||||
#include "RayFeature.h"
|
#include "RayFeature.h"
|
||||||
|
@ -40,7 +41,7 @@ namespace Raytracing {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC initRaytracing()
|
PyMOD_INIT_FUNC(Raytracing)
|
||||||
{
|
{
|
||||||
// load dependent module
|
// load dependent module
|
||||||
try {
|
try {
|
||||||
|
@ -48,7 +49,7 @@ PyMODINIT_FUNC initRaytracing()
|
||||||
}
|
}
|
||||||
catch(const Base::Exception& e) {
|
catch(const Base::Exception& e) {
|
||||||
PyErr_SetString(PyExc_ImportError, e.what());
|
PyErr_SetString(PyExc_ImportError, e.what());
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Raytracing::RaySegment ::init();
|
Raytracing::RaySegment ::init();
|
||||||
|
@ -58,6 +59,7 @@ PyMODINIT_FUNC initRaytracing()
|
||||||
Raytracing::LuxProject ::init();
|
Raytracing::LuxProject ::init();
|
||||||
|
|
||||||
|
|
||||||
(void) Raytracing::initModule();
|
PyObject* mod = Raytracing::initModule();
|
||||||
Base::Console().Log("Loading Raytracing module... done\n");
|
Base::Console().Log("Loading Raytracing module... done\n");
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,8 +201,10 @@ private:
|
||||||
vecs[i][l] = PyFloat_AsDouble(temp);
|
vecs[i][l] = PyFloat_AsDouble(temp);
|
||||||
else if (PyLong_Check(temp))
|
else if (PyLong_Check(temp))
|
||||||
vecs[i][l] = (double) PyLong_AsLong(temp);
|
vecs[i][l] = (double) PyLong_AsLong(temp);
|
||||||
|
#if PY_MAJOR_VERSION < 3
|
||||||
else if (PyInt_Check(temp))
|
else if (PyInt_Check(temp))
|
||||||
vecs[i][l] = (double) PyInt_AsLong(temp);
|
vecs[i][l] = (double) PyInt_AsLong(temp);
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
throw Py::ValueError("Wrong parameter format, four Tuple of three floats needed!");
|
throw Py::ValueError("Wrong parameter format, four Tuple of three floats needed!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,11 @@ namespace RaytracingGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC initRaytracingGui()
|
PyMOD_INIT_FUNC(RaytracingGui)
|
||||||
{
|
{
|
||||||
if (!Gui::Application::Instance) {
|
if (!Gui::Application::Instance) {
|
||||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -63,9 +63,9 @@ PyMODINIT_FUNC initRaytracingGui()
|
||||||
}
|
}
|
||||||
catch(const Base::Exception& e) {
|
catch(const Base::Exception& e) {
|
||||||
PyErr_SetString(PyExc_ImportError, e.what());
|
PyErr_SetString(PyExc_ImportError, e.what());
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
(void) RaytracingGui::initModule();
|
PyObject* mod = RaytracingGui::initModule();
|
||||||
Base::Console().Log("Loading GUI of Raytracing module... done\n");
|
Base::Console().Log("Loading GUI of Raytracing module... done\n");
|
||||||
|
|
||||||
// instantiating the commands
|
// instantiating the commands
|
||||||
|
@ -79,4 +79,6 @@ PyMODINIT_FUNC initRaytracingGui()
|
||||||
|
|
||||||
// add resources and reloads the translators
|
// add resources and reloads the translators
|
||||||
loadRaytracingResource();
|
loadRaytracingResource();
|
||||||
|
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user