mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 22:20:35 +05:00
ngpython
This commit is contained in:
parent
b0bf8ed1a5
commit
11c641b038
@ -1,39 +1,13 @@
|
||||
#ifdef NG_PYTHON
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <../general/ngpython.hpp>
|
||||
#include <csg.hpp>
|
||||
|
||||
|
||||
using namespace netgen;
|
||||
namespace bp = boost::python;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Lambda to function pointer conversion
|
||||
template <typename Function>
|
||||
struct function_traits
|
||||
: public function_traits<decltype(&Function::operator())> {};
|
||||
|
||||
template <typename ClassType, typename ReturnType, typename... Args>
|
||||
struct function_traits<ReturnType(ClassType::*)(Args...) const> {
|
||||
typedef ReturnType (*pointer)(Args...);
|
||||
typedef ReturnType return_type;
|
||||
};
|
||||
|
||||
template <typename Function>
|
||||
typename function_traits<Function>::pointer
|
||||
FunctionPointer (const Function& lambda) {
|
||||
return static_cast<typename function_traits<Function>::pointer>(lambda);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline string ToString (const T& t)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << t;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
// a shadow solid tree using shared pointers.
|
||||
|
||||
|
40
libsrc/general/ngpython.hpp
Normal file
40
libsrc/general/ngpython.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
#ifdef NG_PYTHON
|
||||
|
||||
#include <boost/python.hpp>
|
||||
namespace bp = boost::python;
|
||||
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Lambda to function pointer conversion
|
||||
template <typename Function>
|
||||
struct function_traits
|
||||
: public function_traits<decltype(&Function::operator())> {};
|
||||
|
||||
template <typename ClassType, typename ReturnType, typename... Args>
|
||||
struct function_traits<ReturnType(ClassType::*)(Args...) const> {
|
||||
typedef ReturnType (*pointer)(Args...);
|
||||
typedef ReturnType return_type;
|
||||
};
|
||||
|
||||
template <typename Function>
|
||||
typename function_traits<Function>::pointer
|
||||
FunctionPointer (const Function& lambda) {
|
||||
return static_cast<typename function_traits<Function>::pointer>(lambda);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline std::string ToString (const T& t)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << t;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user