boost::python and documentation updates

metadata
Wenzel Jakob 2011-08-19 00:16:57 -04:00
parent 2b7ed93923
commit 7f918fd1a1
9 changed files with 65 additions and 38 deletions

View File

@ -325,7 +325,7 @@ def relax_compiler_settings(env):
# to be that fast)
env.RemoveFlags(['-g', '/Z7', '-ipo', '/GL'])
if env.RemoveFlag('-O3'):
env.AppendFlag('-O1')
env.AppendFlag('-Os')
if env.RemoveFlag('/O2'):
env.AppendFlag('/O1')

View File

@ -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.
It is written in portable C++, implements unbiased as well
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
emphasis on experimental rendering techniques, such as path-based

View File

@ -41,9 +41,9 @@ public:
* \param formatted Formatted string representation of the message
* \param eta Estimated time until 100% is reached.
* \param ptr Custom pointer payload. This is used to express the
* context of a progress message. When rendering a scene, this
* will usually be the associated \c RenderJob.
* \remark The \c ptr argument is missing in the Python binding
* 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
*/
virtual void logProgress(Float progress, const std::string &name,
const std::string &formatted, const std::string &eta,

View File

@ -104,6 +104,8 @@ public:
* \param fileName Source file of the message creator
* \param lineNumber Source line number of the message creator
* \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,
const char *fileName, int lineNumber,
@ -115,7 +117,10 @@ public:
* \param name Title of the progress message
* \param formatted Formatted string representation of the message
* \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,
const std::string &formatted, const std::string &eta,
@ -123,7 +128,7 @@ public:
/// Set the log level (everything below will be ignored)
void setLogLevel(ELogLevel level);
/**
* \brief Set the error log level (this level and anything
* above will throw exceptions).
@ -149,7 +154,7 @@ public:
/// Return the number of registered appenders
inline size_t getAppenderCount() const { return m_appenders.size(); }
/// Return one of the appenders
inline Appender *getAppender(size_t index) { return m_appenders[index]; }

View File

@ -18,7 +18,7 @@
#include <mitsuba/mitsuba.h>
#define DEBUG_ALLOCATIONS 1
#define DEBUG_REFCOUNTS 0
MTS_NAMESPACE_BEGIN
@ -29,7 +29,7 @@ Object::Object()
}
void Object::incRef() const {
#if defined(DEBUG_ALLOCATIONS)
#if DEBUG_REFCOUNTS == 1
if (Class::rttiIsInitialized())
cout << this << ": Increasing reference count (" << getClass()->getName() << ") -> "
<< m_refCount + 1 << endl;
@ -42,7 +42,7 @@ void Object::incRef() const {
}
void Object::decRef() const {
#if defined(DEBUG_ALLOCATIONS)
#if DEBUG_REFCOUNTS == 1
if (Class::rttiIsInitialized()) {
cout << this << ": Decreasing reference count (" << getClass()->getName() << ") -> "
<< m_refCount - 1 << endl;
@ -55,7 +55,7 @@ void Object::decRef() const {
#endif
AssertEx(count >= 0, "Reference count is below zero!");
if (count == 0) {
#if defined(DEBUG_ALLOCATIONS)
#if DEBUG_REFCOUNTS == 1
if (Class::rttiIsInitialized())
cout << this << ": Deleting an instance of " <<
getClass()->getName() << endl;

View File

@ -248,12 +248,12 @@ void Thread::exit() {
std::string Thread::toString() const {
std::ostringstream oss;
oss << "Thread[" << endl
<< " name=\"" << m_name << "\"," << endl
<< " running=" << m_running << "," << endl
<< " joined=" << m_joined << "," << endl
<< " priority=" << m_priority << "," << endl
<< " critical=" << m_critical << "," << endl
<< " stackSize=" << m_stackSize << endl
<< " name = \"" << m_name << "\"," << endl
<< " running = " << m_running << "," << endl
<< " joined = " << m_joined << "," << endl
<< " priority = " << m_priority << "," << endl
<< " critical = " << m_critical << "," << endl
<< " stackSize = " << m_stackSize << endl
<< "]";
return oss.str();
}

View File

@ -3,10 +3,7 @@ Import('env', 'sys', 'os', 'hasPython')
pythonEnv = env.Clone()
pythonEnv.Append(CPPDEFINES = [['MTS_BUILD_MODULE', 'MTS_MODULE_PYTHON']])
pythonEnv['SHLIBPREFIX']=''
try:
pythonEnv['CXXFLAGS'].remove('-g')
except:
pass
pythonEnv.RelaxCompilerSettings()
if pythonEnv.has_key('PYTHONINCLUDE'):
pythonEnv.Prepend(CPPPATH=pythonEnv['PYTHONINCLUDE'])

View File

@ -148,15 +148,22 @@ void appender_logProgress(Appender *appender, Float progress, const std::string
const std::string &formatted, const std::string &eta) {
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) {
bp::object traceback(bp::import("traceback"));
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,
NULL, bp::extract<const char *>(top[0]),
bp::extract<int>(top[1]),
"%s: %s", (const char *) bp::extract<const char *>(top[2]), msg.c_str());
bp::extract<int>(top[1]), "%s(): %s",
(const char *) bp::extract<const char *>(top[2]),
msg.c_str());
}
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)
.def("getRefCount", &Object::getRefCount)
.def("__str__", &Object::toString);
BP_CLASS(Stream, Object, bp::no_init)
.def("setByteOrder", &Stream::setByteOrder)
.def("getByteOrder", &Stream::getByteOrder)
@ -284,9 +291,8 @@ void export_core() {
BP_CLASS(SerializableObject, Stream, bp::no_init)
.def("serialize", &SerializableObject::serialize);
typedef Object* (Thread::*get_parent_type)();
Thread *(Thread::*thread_get_parent)() = &Thread::getParent;
BP_CLASS(Thread, Object, bp::no_init)
.def("getID", &Thread::getID)
.def("getStackSize", &Thread::getStackSize)
@ -296,12 +302,12 @@ void export_core() {
.def("getCritical", &Thread::getCritical)
.def("setName", &Thread::setName)
.def("getName", &Thread::getName, BP_RETURN_CONSTREF)
// .def("getParent", (get_parent_type) &Thread::getParent)
// .def("setLogger", &Thread::setLogger)
// .def("getLogger", &Thread::getLogger)
// .def("setFileResolver", &Thread::setFileResolver)
// .def("getFileResolver", &Thread::getFileResolver)
.def("getThread", &Thread::getThread, bp::return_internal_reference<>())
.def("getParent", thread_get_parent, BP_RETURN_VALUE)
.def("setLogger", &Thread::setLogger)
.def("getLogger", &Thread::getLogger, BP_RETURN_VALUE)
.def("setFileResolver", &Thread::setFileResolver)
.def("getFileResolver", &Thread::getFileResolver, BP_RETURN_VALUE)
.def("getThread", &Thread::getThread, BP_RETURN_VALUE)
.def("isRunning", &Thread::isRunning)
.def("sleep", &Thread::sleep)
.def("detach", &Thread::detach)
@ -326,6 +332,19 @@ void export_core() {
.def("append", &Appender::append)
.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<>())
.def("serialize", &InstanceManager::serialize)
.def("getInstance", &instance_manager_getinstance);
@ -410,7 +429,7 @@ void export_core() {
.def("__setitem__", &properties_wrapper::set)
.def("__contains__", &Properties::hasProperty)
.def("__str__", &Properties::toString);
BP_SETSCOPE(properties);
bp::enum_<Properties::EPropertyType>("EPropertyType")
.value("EBoolean", Properties::EBoolean)
@ -422,8 +441,6 @@ void export_core() {
.value("EString", Properties::EString)
.value("EData", Properties::EData)
.export_values();
BP_SETSCOPE(coreModule);
BP_STRUCT(Vector2, bp::init<>())

View File

@ -23,14 +23,17 @@
#define BP_STRUCT(Name, Init) \
bp::class_<Name> Name ##_struct(#Name, Init); \
bp::register_ptr_to_python<Name*>(); \
Name ##_struct
#define BP_CLASS(Name, Base, Init) \
bp::class_<Name, ref<Name>, bp::bases<Base>, boost::noncopyable> Name ##_class(#Name, Init); \
bp::register_ptr_to_python<Name*>(); \
Name ##_class
#define BP_WRAPPED_CLASS(Name, Wrapper, Base, Init) \
bp::class_<Name, ref<Wrapper>, bp::bases<Base>, boost::noncopyable> Name ##_class(#Name, Init); \
bp::register_ptr_to_python<Name*>(); \
Name ##_class
#define BP_IMPLEMENT_VECTOR_OPS(Name, Scalar, Size) \
@ -81,7 +84,9 @@
} while (0);
#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 python {