boost::python and documentation updates
parent
2b7ed93923
commit
7f918fd1a1
|
@ -325,7 +325,7 @@ def relax_compiler_settings(env):
|
||||||
# to be that fast)
|
# to be that fast)
|
||||||
env.RemoveFlags(['-g', '/Z7', '-ipo', '/GL'])
|
env.RemoveFlags(['-g', '/Z7', '-ipo', '/GL'])
|
||||||
if env.RemoveFlag('-O3'):
|
if env.RemoveFlag('-O3'):
|
||||||
env.AppendFlag('-O1')
|
env.AppendFlag('-Os')
|
||||||
if env.RemoveFlag('/O2'):
|
if env.RemoveFlag('/O2'):
|
||||||
env.AppendFlag('/O1')
|
env.AppendFlag('/O1')
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,10 @@ Mitsuba is a research-oriented rendering system in the style of PBRT
|
||||||
(\url{www.pbrt.org}), from which it derives much inspiration.
|
(\url{www.pbrt.org}), from which it derives much inspiration.
|
||||||
It is written in portable C++, implements unbiased as well
|
It is written in portable C++, implements unbiased as well
|
||||||
as biased techniques, and contains heavy optimizations targeted
|
as biased techniques, and contains heavy optimizations targeted
|
||||||
towards current CPU architectures.
|
towards current CPU architectures.
|
||||||
|
Mitsuba is extremely modular: it consists of a small set of core libraries
|
||||||
|
and over 100 different plugins that implement functionality ranging
|
||||||
|
from materials and light sources to complete rendering algorithms.
|
||||||
|
|
||||||
In comparison to other open source renderers, Mitsuba places a strong
|
In comparison to other open source renderers, Mitsuba places a strong
|
||||||
emphasis on experimental rendering techniques, such as path-based
|
emphasis on experimental rendering techniques, such as path-based
|
||||||
|
|
|
@ -41,9 +41,9 @@ public:
|
||||||
* \param formatted Formatted string representation of the message
|
* \param formatted Formatted string representation of the message
|
||||||
* \param eta Estimated time until 100% is reached.
|
* \param eta Estimated time until 100% is reached.
|
||||||
* \param ptr Custom pointer payload. This is used to express the
|
* \param ptr Custom pointer payload. This is used to express the
|
||||||
* context of a progress message. When rendering a scene, this
|
* context of a progress message. When rendering a scene, it
|
||||||
* will usually be the associated \c RenderJob.
|
* will usually contain a pointer to the associated \c RenderJob.
|
||||||
* \remark The \c ptr argument is missing in the Python binding
|
* \remark The \c ptr argument is missing in the Python bindings
|
||||||
*/
|
*/
|
||||||
virtual void logProgress(Float progress, const std::string &name,
|
virtual void logProgress(Float progress, const std::string &name,
|
||||||
const std::string &formatted, const std::string &eta,
|
const std::string &formatted, const std::string &eta,
|
||||||
|
|
|
@ -104,6 +104,8 @@ public:
|
||||||
* \param fileName Source file of the message creator
|
* \param fileName Source file of the message creator
|
||||||
* \param lineNumber Source line number of the message creator
|
* \param lineNumber Source line number of the message creator
|
||||||
* \param fmt printf-style string formatter
|
* \param fmt printf-style string formatter
|
||||||
|
* \note This function is not exposed in the Python bindings.
|
||||||
|
* Instead, please use \cc mitsuba.core.Log
|
||||||
*/
|
*/
|
||||||
void log(ELogLevel level, const Class *theClass,
|
void log(ELogLevel level, const Class *theClass,
|
||||||
const char *fileName, int lineNumber,
|
const char *fileName, int lineNumber,
|
||||||
|
@ -115,7 +117,10 @@ public:
|
||||||
* \param name Title of the progress message
|
* \param name Title of the progress message
|
||||||
* \param formatted Formatted string representation of the message
|
* \param formatted Formatted string representation of the message
|
||||||
* \param eta Estimated time until 100% is reached.
|
* \param eta Estimated time until 100% is reached.
|
||||||
* \param ptr Custom pointer payload
|
* \param ptr Custom pointer payload. This is used to express the
|
||||||
|
* context of a progress message. When rendering a scene, it
|
||||||
|
* will usually contain a pointer to the associated \c RenderJob.
|
||||||
|
* \remark The \c ptr argument is missing in the Python bindings
|
||||||
*/
|
*/
|
||||||
void logProgress(Float progress, const std::string &name,
|
void logProgress(Float progress, const std::string &name,
|
||||||
const std::string &formatted, const std::string &eta,
|
const std::string &formatted, const std::string &eta,
|
||||||
|
@ -123,7 +128,7 @@ public:
|
||||||
|
|
||||||
/// Set the log level (everything below will be ignored)
|
/// Set the log level (everything below will be ignored)
|
||||||
void setLogLevel(ELogLevel level);
|
void setLogLevel(ELogLevel level);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the error log level (this level and anything
|
* \brief Set the error log level (this level and anything
|
||||||
* above will throw exceptions).
|
* above will throw exceptions).
|
||||||
|
@ -149,7 +154,7 @@ public:
|
||||||
|
|
||||||
/// Return the number of registered appenders
|
/// Return the number of registered appenders
|
||||||
inline size_t getAppenderCount() const { return m_appenders.size(); }
|
inline size_t getAppenderCount() const { return m_appenders.size(); }
|
||||||
|
|
||||||
/// Return one of the appenders
|
/// Return one of the appenders
|
||||||
inline Appender *getAppender(size_t index) { return m_appenders[index]; }
|
inline Appender *getAppender(size_t index) { return m_appenders[index]; }
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include <mitsuba/mitsuba.h>
|
#include <mitsuba/mitsuba.h>
|
||||||
|
|
||||||
#define DEBUG_ALLOCATIONS 1
|
#define DEBUG_REFCOUNTS 0
|
||||||
|
|
||||||
MTS_NAMESPACE_BEGIN
|
MTS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ Object::Object()
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::incRef() const {
|
void Object::incRef() const {
|
||||||
#if defined(DEBUG_ALLOCATIONS)
|
#if DEBUG_REFCOUNTS == 1
|
||||||
if (Class::rttiIsInitialized())
|
if (Class::rttiIsInitialized())
|
||||||
cout << this << ": Increasing reference count (" << getClass()->getName() << ") -> "
|
cout << this << ": Increasing reference count (" << getClass()->getName() << ") -> "
|
||||||
<< m_refCount + 1 << endl;
|
<< m_refCount + 1 << endl;
|
||||||
|
@ -42,7 +42,7 @@ void Object::incRef() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::decRef() const {
|
void Object::decRef() const {
|
||||||
#if defined(DEBUG_ALLOCATIONS)
|
#if DEBUG_REFCOUNTS == 1
|
||||||
if (Class::rttiIsInitialized()) {
|
if (Class::rttiIsInitialized()) {
|
||||||
cout << this << ": Decreasing reference count (" << getClass()->getName() << ") -> "
|
cout << this << ": Decreasing reference count (" << getClass()->getName() << ") -> "
|
||||||
<< m_refCount - 1 << endl;
|
<< m_refCount - 1 << endl;
|
||||||
|
@ -55,7 +55,7 @@ void Object::decRef() const {
|
||||||
#endif
|
#endif
|
||||||
AssertEx(count >= 0, "Reference count is below zero!");
|
AssertEx(count >= 0, "Reference count is below zero!");
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
#if defined(DEBUG_ALLOCATIONS)
|
#if DEBUG_REFCOUNTS == 1
|
||||||
if (Class::rttiIsInitialized())
|
if (Class::rttiIsInitialized())
|
||||||
cout << this << ": Deleting an instance of " <<
|
cout << this << ": Deleting an instance of " <<
|
||||||
getClass()->getName() << endl;
|
getClass()->getName() << endl;
|
||||||
|
|
|
@ -248,12 +248,12 @@ void Thread::exit() {
|
||||||
std::string Thread::toString() const {
|
std::string Thread::toString() const {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Thread[" << endl
|
oss << "Thread[" << endl
|
||||||
<< " name=\"" << m_name << "\"," << endl
|
<< " name = \"" << m_name << "\"," << endl
|
||||||
<< " running=" << m_running << "," << endl
|
<< " running = " << m_running << "," << endl
|
||||||
<< " joined=" << m_joined << "," << endl
|
<< " joined = " << m_joined << "," << endl
|
||||||
<< " priority=" << m_priority << "," << endl
|
<< " priority = " << m_priority << "," << endl
|
||||||
<< " critical=" << m_critical << "," << endl
|
<< " critical = " << m_critical << "," << endl
|
||||||
<< " stackSize=" << m_stackSize << endl
|
<< " stackSize = " << m_stackSize << endl
|
||||||
<< "]";
|
<< "]";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,7 @@ Import('env', 'sys', 'os', 'hasPython')
|
||||||
pythonEnv = env.Clone()
|
pythonEnv = env.Clone()
|
||||||
pythonEnv.Append(CPPDEFINES = [['MTS_BUILD_MODULE', 'MTS_MODULE_PYTHON']])
|
pythonEnv.Append(CPPDEFINES = [['MTS_BUILD_MODULE', 'MTS_MODULE_PYTHON']])
|
||||||
pythonEnv['SHLIBPREFIX']=''
|
pythonEnv['SHLIBPREFIX']=''
|
||||||
try:
|
pythonEnv.RelaxCompilerSettings()
|
||||||
pythonEnv['CXXFLAGS'].remove('-g')
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if pythonEnv.has_key('PYTHONINCLUDE'):
|
if pythonEnv.has_key('PYTHONINCLUDE'):
|
||||||
pythonEnv.Prepend(CPPPATH=pythonEnv['PYTHONINCLUDE'])
|
pythonEnv.Prepend(CPPPATH=pythonEnv['PYTHONINCLUDE'])
|
||||||
|
|
|
@ -148,15 +148,22 @@ void appender_logProgress(Appender *appender, Float progress, const std::string
|
||||||
const std::string &formatted, const std::string &eta) {
|
const std::string &formatted, const std::string &eta) {
|
||||||
appender->logProgress(progress, name, formatted, eta, NULL);
|
appender->logProgress(progress, name, formatted, eta, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void logger_logProgress(Logger *logger, Float progress, const std::string &name,
|
||||||
|
const std::string &formatted, const std::string &eta) {
|
||||||
|
logger->logProgress(progress, name, formatted, eta, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void mts_log(ELogLevel level, const std::string &msg) {
|
void mts_log(ELogLevel level, const std::string &msg) {
|
||||||
bp::object traceback(bp::import("traceback"));
|
bp::object traceback(bp::import("traceback"));
|
||||||
bp::object extract_stack(traceback.attr("extract_stack"));
|
bp::object extract_stack(traceback.attr("extract_stack"));
|
||||||
bp::object top(extract_stack()[1]);
|
bp::object stack = extract_stack();
|
||||||
|
bp::object top(stack[bp::len(stack)-1]);
|
||||||
Thread::getThread()->getLogger()->log(level,
|
Thread::getThread()->getLogger()->log(level,
|
||||||
NULL, bp::extract<const char *>(top[0]),
|
NULL, bp::extract<const char *>(top[0]),
|
||||||
bp::extract<int>(top[1]),
|
bp::extract<int>(top[1]), "%s(): %s",
|
||||||
"%s: %s", (const char *) bp::extract<const char *>(top[2]), msg.c_str());
|
(const char *) bp::extract<const char *>(top[2]),
|
||||||
|
msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppenderWrapper : public Appender, public bp::wrapper<Appender> {
|
class AppenderWrapper : public Appender, public bp::wrapper<Appender> {
|
||||||
|
@ -214,7 +221,7 @@ void export_core() {
|
||||||
bp::class_<Object, ref<Object>, boost::noncopyable>("Object", bp::no_init)
|
bp::class_<Object, ref<Object>, boost::noncopyable>("Object", bp::no_init)
|
||||||
.def("getRefCount", &Object::getRefCount)
|
.def("getRefCount", &Object::getRefCount)
|
||||||
.def("__str__", &Object::toString);
|
.def("__str__", &Object::toString);
|
||||||
|
|
||||||
BP_CLASS(Stream, Object, bp::no_init)
|
BP_CLASS(Stream, Object, bp::no_init)
|
||||||
.def("setByteOrder", &Stream::setByteOrder)
|
.def("setByteOrder", &Stream::setByteOrder)
|
||||||
.def("getByteOrder", &Stream::getByteOrder)
|
.def("getByteOrder", &Stream::getByteOrder)
|
||||||
|
@ -284,9 +291,8 @@ void export_core() {
|
||||||
|
|
||||||
BP_CLASS(SerializableObject, Stream, bp::no_init)
|
BP_CLASS(SerializableObject, Stream, bp::no_init)
|
||||||
.def("serialize", &SerializableObject::serialize);
|
.def("serialize", &SerializableObject::serialize);
|
||||||
|
|
||||||
typedef Object* (Thread::*get_parent_type)();
|
|
||||||
|
|
||||||
|
Thread *(Thread::*thread_get_parent)() = &Thread::getParent;
|
||||||
BP_CLASS(Thread, Object, bp::no_init)
|
BP_CLASS(Thread, Object, bp::no_init)
|
||||||
.def("getID", &Thread::getID)
|
.def("getID", &Thread::getID)
|
||||||
.def("getStackSize", &Thread::getStackSize)
|
.def("getStackSize", &Thread::getStackSize)
|
||||||
|
@ -296,12 +302,12 @@ void export_core() {
|
||||||
.def("getCritical", &Thread::getCritical)
|
.def("getCritical", &Thread::getCritical)
|
||||||
.def("setName", &Thread::setName)
|
.def("setName", &Thread::setName)
|
||||||
.def("getName", &Thread::getName, BP_RETURN_CONSTREF)
|
.def("getName", &Thread::getName, BP_RETURN_CONSTREF)
|
||||||
// .def("getParent", (get_parent_type) &Thread::getParent)
|
.def("getParent", thread_get_parent, BP_RETURN_VALUE)
|
||||||
// .def("setLogger", &Thread::setLogger)
|
.def("setLogger", &Thread::setLogger)
|
||||||
// .def("getLogger", &Thread::getLogger)
|
.def("getLogger", &Thread::getLogger, BP_RETURN_VALUE)
|
||||||
// .def("setFileResolver", &Thread::setFileResolver)
|
.def("setFileResolver", &Thread::setFileResolver)
|
||||||
// .def("getFileResolver", &Thread::getFileResolver)
|
.def("getFileResolver", &Thread::getFileResolver, BP_RETURN_VALUE)
|
||||||
.def("getThread", &Thread::getThread, bp::return_internal_reference<>())
|
.def("getThread", &Thread::getThread, BP_RETURN_VALUE)
|
||||||
.def("isRunning", &Thread::isRunning)
|
.def("isRunning", &Thread::isRunning)
|
||||||
.def("sleep", &Thread::sleep)
|
.def("sleep", &Thread::sleep)
|
||||||
.def("detach", &Thread::detach)
|
.def("detach", &Thread::detach)
|
||||||
|
@ -326,6 +332,19 @@ void export_core() {
|
||||||
.def("append", &Appender::append)
|
.def("append", &Appender::append)
|
||||||
.def("logProgress", &appender_logProgress);
|
.def("logProgress", &appender_logProgress);
|
||||||
|
|
||||||
|
Appender *(Logger::*logger_get_appender)(size_t) = &Logger::getAppender;
|
||||||
|
BP_CLASS(Logger, Object, bp::init<ELogLevel>())
|
||||||
|
.def("logProgress", logger_logProgress)
|
||||||
|
.def("setLogLevel", &Logger::setLogLevel)
|
||||||
|
.def("getLogLevel", &Logger::getLogLevel)
|
||||||
|
.def("setErrorLevel", &Logger::setErrorLevel)
|
||||||
|
.def("getErrorLevel", &Logger::getErrorLevel)
|
||||||
|
.def("addAppender", &Logger::addAppender)
|
||||||
|
.def("removeAppender", &Logger::removeAppender)
|
||||||
|
.def("getAppenderCount", &Logger::getAppenderCount)
|
||||||
|
.def("getAppender", logger_get_appender, BP_RETURN_VALUE)
|
||||||
|
.def("getWarningCount", &Logger::getWarningCount);
|
||||||
|
|
||||||
BP_CLASS(InstanceManager, Object, bp::init<>())
|
BP_CLASS(InstanceManager, Object, bp::init<>())
|
||||||
.def("serialize", &InstanceManager::serialize)
|
.def("serialize", &InstanceManager::serialize)
|
||||||
.def("getInstance", &instance_manager_getinstance);
|
.def("getInstance", &instance_manager_getinstance);
|
||||||
|
@ -410,7 +429,7 @@ void export_core() {
|
||||||
.def("__setitem__", &properties_wrapper::set)
|
.def("__setitem__", &properties_wrapper::set)
|
||||||
.def("__contains__", &Properties::hasProperty)
|
.def("__contains__", &Properties::hasProperty)
|
||||||
.def("__str__", &Properties::toString);
|
.def("__str__", &Properties::toString);
|
||||||
|
|
||||||
BP_SETSCOPE(properties);
|
BP_SETSCOPE(properties);
|
||||||
bp::enum_<Properties::EPropertyType>("EPropertyType")
|
bp::enum_<Properties::EPropertyType>("EPropertyType")
|
||||||
.value("EBoolean", Properties::EBoolean)
|
.value("EBoolean", Properties::EBoolean)
|
||||||
|
@ -422,8 +441,6 @@ void export_core() {
|
||||||
.value("EString", Properties::EString)
|
.value("EString", Properties::EString)
|
||||||
.value("EData", Properties::EData)
|
.value("EData", Properties::EData)
|
||||||
.export_values();
|
.export_values();
|
||||||
|
|
||||||
|
|
||||||
BP_SETSCOPE(coreModule);
|
BP_SETSCOPE(coreModule);
|
||||||
|
|
||||||
BP_STRUCT(Vector2, bp::init<>())
|
BP_STRUCT(Vector2, bp::init<>())
|
||||||
|
|
|
@ -23,14 +23,17 @@
|
||||||
|
|
||||||
#define BP_STRUCT(Name, Init) \
|
#define BP_STRUCT(Name, Init) \
|
||||||
bp::class_<Name> Name ##_struct(#Name, Init); \
|
bp::class_<Name> Name ##_struct(#Name, Init); \
|
||||||
|
bp::register_ptr_to_python<Name*>(); \
|
||||||
Name ##_struct
|
Name ##_struct
|
||||||
|
|
||||||
#define BP_CLASS(Name, Base, Init) \
|
#define BP_CLASS(Name, Base, Init) \
|
||||||
bp::class_<Name, ref<Name>, bp::bases<Base>, boost::noncopyable> Name ##_class(#Name, Init); \
|
bp::class_<Name, ref<Name>, bp::bases<Base>, boost::noncopyable> Name ##_class(#Name, Init); \
|
||||||
|
bp::register_ptr_to_python<Name*>(); \
|
||||||
Name ##_class
|
Name ##_class
|
||||||
|
|
||||||
#define BP_WRAPPED_CLASS(Name, Wrapper, Base, Init) \
|
#define BP_WRAPPED_CLASS(Name, Wrapper, Base, Init) \
|
||||||
bp::class_<Name, ref<Wrapper>, bp::bases<Base>, boost::noncopyable> Name ##_class(#Name, Init); \
|
bp::class_<Name, ref<Wrapper>, bp::bases<Base>, boost::noncopyable> Name ##_class(#Name, Init); \
|
||||||
|
bp::register_ptr_to_python<Name*>(); \
|
||||||
Name ##_class
|
Name ##_class
|
||||||
|
|
||||||
#define BP_IMPLEMENT_VECTOR_OPS(Name, Scalar, Size) \
|
#define BP_IMPLEMENT_VECTOR_OPS(Name, Scalar, Size) \
|
||||||
|
@ -81,7 +84,9 @@
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#define BP_RETURN_CONSTREF bp::return_value_policy<bp::copy_const_reference>()
|
#define BP_RETURN_CONSTREF bp::return_value_policy<bp::copy_const_reference>()
|
||||||
#define BP_RETURN_INTREF bp::return_internal_reference<>
|
#define BP_RETURN_NONCONSTREF bp::return_value_policy<bp::copy_non_const_reference>()
|
||||||
|
#define BP_RETURN_VALUE bp::return_value_policy<bp::return_by_value>()
|
||||||
|
#define BP_RETURN_INTREF bp::return_internal_reference<>()
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace python {
|
namespace python {
|
||||||
|
|
Loading…
Reference in New Issue