windows fixes

This commit is contained in:
Christoph Wintersteiger 2014-10-08 13:38:13 +00:00
parent f89060e260
commit ffd9f56292

View File

@ -530,34 +530,50 @@ inline string ToString (const T& t)
#include <boost/python.hpp> #include <boost/python.hpp>
namespace bp = boost::python; namespace bp = boost::python;
BOOST_PYTHON_MODULE(libcsgvis) void ExportCSGVis()
{ {
std::string nested_name = "csgvis";
if (bp::scope())
nested_name = bp::extract<std::string>(bp::scope().attr("__name__") + ".csgvis");
bp::object module(bp::handle<>(bp::borrowed(PyImport_AddModule(nested_name.c_str()))));
cout << "exporting csgvis " << nested_name << endl;
bp::object parent = bp::scope() ? bp::scope() : bp::import("__main__");
parent.attr("csgvis") = module;
bp::scope local_scope(module);
using namespace netgen; using namespace netgen;
cout << "exporting csg-vis " << endl; cout << "exporting csg-vis " << endl;
bp::class_<VisualSceneGeometry, shared_ptr<VisualSceneGeometry>> bp::class_<VisualSceneGeometry, shared_ptr<VisualSceneGeometry>>
("VisualSceneGeometry", bp::no_init) ("VisualSceneGeometry", bp::no_init)
.def ("Draw", &VisualSceneGeometry::DrawScene) .def("Draw", &VisualSceneGeometry::DrawScene)
; ;
bp::def ("VS", FunctionPointer bp::def("VS", FunctionPointer
([] (CSGeometry & geom) ([](CSGeometry & geom)
{ {
geom.FindIdenticSurfaces (1e-6); geom.FindIdenticSurfaces(1e-6);
geom.CalcTriangleApproximation (0.01, 20); geom.CalcTriangleApproximation(0.01, 20);
auto vs = make_shared<VisualSceneGeometry>(); auto vs = make_shared<VisualSceneGeometry>();
vs->SetGeometry(&geom); vs->SetGeometry(&geom);
return vs; return vs;
})); }));
bp::def ("MouseMove", FunctionPointer bp::def("MouseMove", FunctionPointer
([] ( VisualSceneGeometry &vsgeom, int oldx, int oldy, int newx, int newy, char mode) ([](VisualSceneGeometry &vsgeom, int oldx, int oldy, int newx, int newy, char mode)
{ {
vsgeom.MouseMove(oldx,oldy,newx,newy,mode); vsgeom.MouseMove(oldx, oldy, newx, newy, mode);
})); }));
}
BOOST_PYTHON_MODULE(libcsgvis)
{
ExportCSGVis();
} }
#endif #endif